Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
67ee1fff
Commit
67ee1fff
authored
Oct 17, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid redundant recoding during code comment injection by configuring input codec directly
parent
07e897e9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+3
-2
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+14
-5
No files found.
Cython/Compiler/Code.py
View file @
67ee1fff
...
@@ -747,8 +747,9 @@ class GlobalState(object):
...
@@ -747,8 +747,9 @@ class GlobalState(object):
u'*/', u'*[inserted by cython to avoid comment closer]/'
u'*/', u'*[inserted by cython to avoid comment closer]/'
).replace(
).replace(
u'/*', u'/[inserted by cython to avoid comment start]*'
u'/*', u'/[inserted by cython to avoid comment start]*'
).encode('ASCII', 'replace').decode('ASCII')
)
for line in source_desc.get_lines()]
for line in source_desc.get_lines(encoding='ASCII',
error_handling='replace')]
if len(F) == 0: F.append(u'')
if len(F) == 0: F.append(u'')
self.input_file_contents[source_desc] = F
self.input_file_contents[source_desc] = F
return F
return F
...
...
Cython/Compiler/Scanning.py
View file @
67ee1fff
...
@@ -9,6 +9,7 @@ import os
...
@@ -9,6 +9,7 @@ import os
import
platform
import
platform
import
stat
import
stat
import
sys
import
sys
import
codecs
from
time
import
time
from
time
import
time
import
cython
import
cython
...
@@ -279,8 +280,12 @@ class FileSourceDescriptor(SourceDescriptor):
...
@@ -279,8 +280,12 @@ class FileSourceDescriptor(SourceDescriptor):
self
.
filename
=
filename
self
.
filename
=
filename
self
.
_cmp_name
=
filename
self
.
_cmp_name
=
filename
def
get_lines
(
self
):
def
get_lines
(
self
,
encoding
=
None
,
error_handling
=
None
):
if
not
encoding
:
return
Utils
.
open_source_file
(
self
.
filename
)
return
Utils
.
open_source_file
(
self
.
filename
)
else
:
return
codecs
.
open
(
self
.
filename
,
"rU"
,
encoding
=
encoding
,
errors
=
error_handling
)
def
get_description
(
self
):
def
get_description
(
self
):
return
self
.
filename
return
self
.
filename
...
@@ -307,8 +312,12 @@ class StringSourceDescriptor(SourceDescriptor):
...
@@ -307,8 +312,12 @@ class StringSourceDescriptor(SourceDescriptor):
self
.
codelines
=
[
x
+
"
\
n
"
for
x
in
code
.
split
(
"
\
n
"
)]
self
.
codelines
=
[
x
+
"
\
n
"
for
x
in
code
.
split
(
"
\
n
"
)]
self
.
_cmp_name
=
name
self
.
_cmp_name
=
name
def
get_lines
(
self
):
def
get_lines
(
self
,
encoding
=
None
,
error_handling
=
None
):
if
not
encoding
:
return
self
.
codelines
return
self
.
codelines
else
:
return
[
line
.
encode
(
encoding
,
error_handling
).
decode
(
encoding
)
for
line
in
self
.
codelines
]
def
get_description
(
self
):
def
get_description
(
self
):
return
self
.
name
return
self
.
name
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment