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
16ac5bf9
Commit
16ac5bf9
authored
Jul 06, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Py3 fixes
parent
98fd5b4a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+11
-3
Cython/Utils.py
Cython/Utils.py
+6
-1
No files found.
Cython/Compiler/Code.py
View file @
16ac5bf9
...
@@ -317,7 +317,7 @@ class StringConst(object):
...
@@ -317,7 +317,7 @@ class StringConst(object):
if identifier:
if identifier:
intern = True
intern = True
elif identifier is None:
elif identifier is None:
if is
_unicode
:
if is
instance(text, unicode)
:
intern = bool(possible_unicode_identifier(text))
intern = bool(possible_unicode_identifier(text))
else:
else:
intern = bool(possible_bytes_identifier(text))
intern = bool(possible_bytes_identifier(text))
...
@@ -353,6 +353,9 @@ class PyStringConst(object):
...
@@ -353,6 +353,9 @@ class PyStringConst(object):
self.unicode = is_unicode
self.unicode = is_unicode
self.intern = intern
self.intern = intern
def __lt__(self, other):
return self.cname < other.cname
class GlobalState(object):
class GlobalState(object):
# filename_table {string : int} for finding filename table indexes
# filename_table {string : int} for finding filename table indexes
...
@@ -544,7 +547,7 @@ class GlobalState(object):
...
@@ -544,7 +547,7 @@ class GlobalState(object):
return py_string
return py_string
def new_string_const(self, text, byte_string):
def new_string_const(self, text, byte_string):
cname = self.new_string_const_cname(
text
)
cname = self.new_string_const_cname(
byte_string
)
c = StringConst(cname, text, byte_string)
c = StringConst(cname, text, byte_string)
self.string_const_index[byte_string] = c
self.string_const_index[byte_string] = c
return c
return c
...
@@ -561,8 +564,13 @@ class GlobalState(object):
...
@@ -561,8 +564,13 @@ class GlobalState(object):
self.py_constants.append(c)
self.py_constants.append(c)
return c
return c
def new_string_const_cname(self, value, intern=None):
def new_string_const_cname(self,
bytes_
value, intern=None):
# Create a new globally-unique nice name for a C string constant.
# Create a new globally-unique nice name for a C string constant.
try:
value = bytes_value.decode('ASCII')
except UnicodeError:
return self.new_const_cname()
if len(value) < 20 and nice_identifier(value):
if len(value) < 20 and nice_identifier(value):
return "
%
s
%
s
" % (Naming.const_prefix, value)
return "
%
s
%
s
" % (Naming.const_prefix, value)
else:
else:
...
...
Cython/Utils.py
View file @
16ac5bf9
...
@@ -14,7 +14,12 @@ def open_new_file(path):
...
@@ -14,7 +14,12 @@ def open_new_file(path):
# Make sure to create a new file here so we can
# Make sure to create a new file here so we can
# safely hard link the output files.
# safely hard link the output files.
os
.
unlink
(
path
)
os
.
unlink
(
path
)
return
open
(
path
,
"w"
)
# we use the ISO-8859-1 encoding here because we only write pure
# ASCII strings or (e.g. for file names) byte encoded strings as
# Unicode, so we need a direct mapping from the first 256 Unicode
# characters to a byte sequence, which ISO-8859-1 provides
return
codecs
.
open
(
path
,
"w"
,
encoding
=
"ISO-8859-1"
)
def
castrate_file
(
path
,
st
):
def
castrate_file
(
path
,
st
):
# Remove junk contents from an output file after a
# Remove junk contents from an output file after a
...
...
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