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
30cf86bc
Commit
30cf86bc
authored
Dec 16, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ticket #576: builtin 'str' type must be 'unicode' type in -3 mode
parent
4d98733e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+13
-0
tests/run/cython3.pyx
tests/run/cython3.pyx
+13
-0
No files found.
Cython/Compiler/Symtab.py
View file @
30cf86bc
...
@@ -733,6 +733,13 @@ class BuiltinScope(Scope):
...
@@ -733,6 +733,13 @@ class BuiltinScope(Scope):
cname, type = definition
cname, type = definition
self.declare_var(name, type, None, cname)
self.declare_var(name, type, None, cname)
def lookup(self, name, language_level=None):
# 'language_level' is passed by ModuleScope
if language_level == 3:
if name == 'str':
name = 'unicode'
return Scope.lookup(self, name)
def declare_builtin(self, name, pos):
def declare_builtin(self, name, pos):
if not hasattr(builtins, name):
if not hasattr(builtins, name):
if self.outer_scope is not None:
if self.outer_scope is not None:
...
@@ -882,6 +889,12 @@ class ModuleScope(Scope):
...
@@ -882,6 +889,12 @@ class ModuleScope(Scope):
def global_scope(self):
def global_scope(self):
return self
return self
def lookup(self, name):
entry = self.lookup_here(name)
if entry is not None:
return entry
return self.outer_scope.lookup(name, language_level = self.context.language_level)
def declare_builtin(self, name, pos):
def declare_builtin(self, name, pos):
if not hasattr(builtins, name) and name != 'xrange':
if not hasattr(builtins, name) and name != 'xrange':
# 'xrange' is special cased in Code.py
# 'xrange' is special cased in Code.py
...
...
tests/run/cython3.pyx
View file @
30cf86bc
...
@@ -66,6 +66,19 @@ def unicode_literals():
...
@@ -66,6 +66,19 @@ def unicode_literals():
print
(
isinstance
(
ustring
,
unicode
)
or
type
(
ustring
))
print
(
isinstance
(
ustring
,
unicode
)
or
type
(
ustring
))
return
ustring
return
ustring
def
str_type_is_unicode
():
"""
>>> str_type, s = str_type_is_unicode()
>>> isinstance(s, type(ustring)) or (s, str_type)
True
>>> isinstance(s, str_type) or (s, str_type)
True
>>> isinstance(ustring, str_type) or str_type
True
"""
cdef
str
s
=
'abc'
return
str
,
s
def
list_comp
():
def
list_comp
():
"""
"""
>>> list_comp()
>>> list_comp()
...
...
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