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
Kirill Smelkov
cython
Commits
ed02fd9b
Commit
ed02fd9b
authored
Apr 21, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blacklist for uncachable builtins
parent
f3972ce8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+7
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+5
-8
No files found.
Cython/Compiler/Code.py
View file @
ed02fd9b
...
...
@@ -25,12 +25,19 @@ except ImportError:
non_portable_builtins_map
=
{
# builtins that have different names in different Python versions
'bytes'
:
(
'PY_MAJOR_VERSION < 3'
,
'str'
),
'unicode'
:
(
'PY_MAJOR_VERSION >= 3'
,
'str'
),
'xrange'
:
(
'PY_MAJOR_VERSION >= 3'
,
'range'
),
'BaseException'
:
(
'PY_VERSION_HEX < 0x02050000'
,
'Exception'
),
}
uncachable_builtins
=
[
# builtin names that cannot be cached because they may or may not
# be available at import time
'WindowsError'
,
]
class
UtilityCode
(
object
):
# Stores utility code to add during code generation.
#
...
...
Cython/Compiler/Symtab.py
View file @
ed02fd9b
...
...
@@ -916,21 +916,18 @@ class ModuleScope(Scope):
return self.outer_scope.lookup(name, language_level = self.context.language_level)
def declare_builtin(self, name, pos):
if not hasattr(builtins, name) and name not in Code.non_portable_builtins_map:
# 'xrange' and 'BaseException' are special cased in Code.py
if not hasattr(builtins, name)
\
and name not in Code.non_portable_builtins_map
\
and name not in Code.uncachable_builtins:
if self.has_import_star:
entry = self.declare_var(name, py_object_type, pos)
return entry
## elif self.outer_scope is not None:
## entry = self.outer_scope.declare_builtin(name, pos)
## print entry
## return entry
else:
# unknown - assume it's builtin and look it up at runtime
if Options.error_on_unknown_names:
error(pos, "
undeclared
name
not
builtin
:
%
s
" % name)
else:
warning(pos, "
undeclared
name
not
builtin
:
%
s
" % name, 2)
# unknown - assume it's builtin and look it up at runtime
entry = self.declare(name, None, py_object_type, pos, 'private')
entry.is_builtin = 1
return entry
...
...
@@ -939,7 +936,7 @@ class ModuleScope(Scope):
if entry.name == name:
return entry
entry = self.declare(None, None, py_object_type, pos, 'private')
if Options.cache_builtins:
if Options.cache_builtins
and name not in Code.uncachable_builtins
:
entry.is_builtin = 1
entry.is_const = 1 # cached
entry.name = 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