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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
cd9d08f3
Commit
cd9d08f3
authored
May 09, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved code for filename encoding to Utils.py to make it reusable elsewhere
parent
9f23dd4e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+1
-10
Cython/Utils.py
Cython/Utils.py
+12
-0
No files found.
Cython/Compiler/Main.py
View file @
cd9d08f3
...
...
@@ -138,16 +138,7 @@ class Context:
return
scope
def
parse
(
self
,
source_filename
,
type_names
,
pxd
,
full_module_name
):
try
:
name
=
source_filename
if
not
isinstance
(
source_filename
,
unicode
):
filename_encoding
=
sys
.
getfilesystemencoding
()
if
filename_encoding
is
None
:
filename_encoding
=
sys
.
getdefaultencoding
()
name
=
source_filename
.
decode
(
filename_encoding
)
except
UnicodeDecodeError
:
pass
name
=
Utils
.
encode_filename
(
source_filename
)
# Parse the given source file and return a parse tree.
try
:
f
=
Utils
.
open_source_file
(
source_filename
,
"rU"
)
...
...
Cython/Utils.py
View file @
cd9d08f3
...
...
@@ -35,6 +35,18 @@ def castrate_file(path, st):
# support for source file encoding detection and unicode decoding
def
encode_filename
(
filename
):
if
isinstance
(
filename
,
unicode
):
return
filename
try
:
filename_encoding
=
sys
.
getfilesystemencoding
()
if
filename_encoding
is
None
:
filename_encoding
=
sys
.
getdefaultencoding
()
filename
=
filename
.
decode
(
filename_encoding
)
except
UnicodeDecodeError
:
pass
return
filename
_match_file_encoding
=
re
.
compile
(
u"coding[:=]
\
s*([-
\
w.]+)"
).
search
def
detect_file_encoding
(
source_filename
):
...
...
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