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
6223893a
Commit
6223893a
authored
Nov 26, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix several Py3 and import issues in the compiled modules
parent
c8ccb5b1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
20 deletions
+36
-20
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+7
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+11
-9
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+7
-2
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+11
-7
No files found.
Cython/Compiler/ExprNodes.py
View file @
6223893a
...
...
@@ -36,6 +36,11 @@ from Cython.Debugging import print_call_chain
from
DebugFlags
import
debug_disposal_code
,
debug_temp_alloc
,
\
debug_coercion
try
:
from
__builtin__
import
basestring
except
ImportError
:
basestring
=
str
# Python 3
class
NotConstant
(
object
):
def
__repr__
(
self
):
return
"<NOT CONSTANT>"
...
...
@@ -2986,7 +2991,7 @@ class SimpleCallNode(CallNode):
return
"<error>"
formal_args
=
func_type
.
args
arg_list_code
=
[]
args
=
zip
(
formal_args
,
self
.
args
)
args
=
list
(
zip
(
formal_args
,
self
.
args
)
)
max_nargs
=
len
(
func_type
.
args
)
expected_nargs
=
max_nargs
-
func_type
.
optional_arg_count
actual_nargs
=
len
(
self
.
args
)
...
...
@@ -3031,7 +3036,7 @@ class SimpleCallNode(CallNode):
self
.
opt_arg_struct
,
Naming
.
pyrex_prefix
+
"n"
,
len
(
self
.
args
)
-
expected_nargs
))
args
=
zip
(
func_type
.
args
,
self
.
args
)
args
=
list
(
zip
(
func_type
.
args
,
self
.
args
)
)
for
formal_arg
,
actual_arg
in
args
[
expected_nargs
:
actual_nargs
]:
code
.
putln
(
"%s.%s = %s;"
%
(
self
.
opt_arg_struct
,
...
...
Cython/Compiler/Nodes.py
View file @
6223893a
...
...
@@ -3,15 +3,17 @@
# Pyrex - Parse tree nodes
#
import
sys
,
os
,
time
,
copy
import
cython
from
cython
import
set
cython
.
declare
(
sys
=
object
,
os
=
object
,
time
=
object
,
copy
=
object
,
Builtin
=
object
,
error
=
object
,
warning
=
object
,
Naming
=
object
,
PyrexTypes
=
object
,
py_object_type
=
object
,
ModuleScope
=
object
,
LocalScope
=
object
,
ClosureScope
=
object
,
\
StructOrUnionScope
=
object
,
PyClassScope
=
object
,
CClassScope
=
object
,
CppClassScope
=
object
,
UtilityCode
=
object
,
EncodedString
=
object
,
absolute_path_length
=
cython
.
Py_ssize_t
)
try
:
set
except
NameError
:
# Python 2.3
from
sets
import
Set
as
set
import
sys
,
os
,
time
,
copy
import
Code
import
Builtin
from
Errors
import
error
,
warning
,
InternalError
import
Naming
...
...
@@ -253,7 +255,7 @@ class Node(object):
return
repr
(
x
)
attrs
=
[(
key
,
value
)
for
key
,
value
in
self
.
__dict__
.
ite
rite
ms
()
if
key
not
in
filter_out
]
attrs
=
[(
key
,
value
)
for
key
,
value
in
self
.
__dict__
.
items
()
if
key
not
in
filter_out
]
if
len
(
attrs
)
==
0
:
return
"<%s (0x%x)>"
%
(
self
.
__class__
.
__name__
,
id
(
self
))
else
:
...
...
@@ -858,7 +860,7 @@ class TemplatedTypeNode(CBaseTypeNode):
if
sys
.
version_info
[
0
]
<
3
:
# Py 2.x enforces byte strings as keyword arguments ...
options
=
dict
([
(
name
.
encode
(
'ASCII'
),
value
)
for
name
,
value
in
options
.
ite
rite
ms
()
])
for
name
,
value
in
options
.
items
()
])
self
.
type
=
PyrexTypes
.
BufferType
(
base_type
,
**
options
)
...
...
Cython/Compiler/Optimize.py
View file @
6223893a
...
...
@@ -28,6 +28,11 @@ try:
except
ImportError
:
from
functools
import
reduce
try
:
from
__builtin__
import
basestring
except
ImportError
:
basestring
=
str
# Python 3
class
FakePythonEnv
(
object
):
"A fake environment for creating type test nodes etc."
nogil
=
False
...
...
@@ -751,7 +756,7 @@ class SwitchTransform(Visitor.VisitorTransform):
def
extract_in_string_conditions
(
self
,
string_literal
):
if
isinstance
(
string_literal
,
ExprNodes
.
UnicodeNode
):
charvals
=
map
(
ord
,
set
(
string_literal
.
value
))
charvals
=
list
(
map
(
ord
,
set
(
string_literal
.
value
)
))
charvals
.
sort
()
return
[
ExprNodes
.
IntNode
(
string_literal
.
pos
,
value
=
str
(
charval
),
constant_result
=
charval
)
...
...
@@ -2937,7 +2942,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
# check if all children are constant
children
=
self
.
visitchildren
(
node
)
for
child_result
in
children
.
iter
values
():
for
child_result
in
children
.
values
():
if
type
(
child_result
)
is
list
:
for
child
in
child_result
:
if
getattr
(
child
,
'constant_result'
,
not_a_constant
)
is
not_a_constant
:
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
6223893a
import
cython
from
cython
import
set
cython
.
declare
(
copy
=
object
,
ModuleNode
=
object
,
TreeFragment
=
object
,
TemplateTransform
=
object
,
EncodedString
=
object
,
error
=
object
,
PyrexTypes
=
object
,
Naming
=
object
)
from
Cython.Compiler.Visitor
import
VisitorTransform
,
TreeVisitor
from
Cython.Compiler.Visitor
import
CythonTransform
,
EnvTransform
,
ScopeTrackingTransform
from
Cython.Compiler.ModuleNode
import
ModuleNode
...
...
@@ -7,10 +13,8 @@ from Cython.Compiler.UtilNodes import *
from
Cython.Compiler.TreeFragment
import
TreeFragment
,
TemplateTransform
from
Cython.Compiler.StringEncoding
import
EncodedString
from
Cython.Compiler.Errors
import
error
,
CompileError
try
:
set
except
NameError
:
from
sets
import
Set
as
set
from
Cython.Compiler
import
PyrexTypes
,
Naming
import
copy
...
...
@@ -572,12 +576,12 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
special_methods
=
set
([
'declare'
,
'union'
,
'struct'
,
'typedef'
,
'sizeof'
,
'cast'
,
'pointer'
,
'compiled'
,
'NULL'
]
+
unop_method_nodes
.
keys
(
))
+
list
(
unop_method_nodes
.
keys
()
))
def
__init__
(
self
,
context
,
compilation_directive_defaults
):
super
(
InterpretCompilerDirectives
,
self
).
__init__
(
context
)
self
.
compilation_directive_defaults
=
{}
for
key
,
value
in
compilation_directive_defaults
.
ite
rite
ms
():
for
key
,
value
in
compilation_directive_defaults
.
items
():
self
.
compilation_directive_defaults
[
unicode
(
key
)]
=
value
self
.
cython_module_names
=
set
()
self
.
directive_names
=
{}
...
...
@@ -593,7 +597,7 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
# Set up processing and handle the cython: comments.
def
visit_ModuleNode
(
self
,
node
):
for
key
,
value
in
node
.
directive_comments
.
ite
rite
ms
():
for
key
,
value
in
node
.
directive_comments
.
items
():
if
not
self
.
check_directive_scope
(
node
.
pos
,
key
,
'module'
):
self
.
wrong_scope_error
(
node
.
pos
,
key
,
'module'
)
del
node
.
directive_comments
[
key
]
...
...
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