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
Boxiang Sun
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
Hide 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):
if identifier:
intern = True
elif identifier is None:
if is
_unicode
:
if is
instance(text, unicode)
:
intern = bool(possible_unicode_identifier(text))
else:
intern = bool(possible_bytes_identifier(text))
...
...
@@ -353,6 +353,9 @@ class PyStringConst(object):
self.unicode = is_unicode
self.intern = intern
def __lt__(self, other):
return self.cname < other.cname
class GlobalState(object):
# filename_table {string : int} for finding filename table indexes
...
...
@@ -544,7 +547,7 @@ class GlobalState(object):
return py_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)
self.string_const_index[byte_string] = c
return c
...
...
@@ -561,8 +564,13 @@ class GlobalState(object):
self.py_constants.append(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.
try:
value = bytes_value.decode('ASCII')
except UnicodeError:
return self.new_const_cname()
if len(value) < 20 and nice_identifier(value):
return "
%
s
%
s
" % (Naming.const_prefix, value)
else:
...
...
Cython/Utils.py
View file @
16ac5bf9
...
...
@@ -14,7 +14,12 @@ def open_new_file(path):
# Make sure to create a new file here so we can
# safely hard link the output files.
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
):
# 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