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
a0fff9f2
Commit
a0fff9f2
authored
Aug 05, 2011
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some Python 2.3 cleanup.
parent
5ace507f
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
49 additions
and
115 deletions
+49
-115
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+7
-15
Cython/Build/Inline.py
Cython/Build/Inline.py
+0
-1
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+0
-5
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+4
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+0
-1
Cython/Compiler/FlowControl.py
Cython/Compiler/FlowControl.py
+4
-6
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+0
-6
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+0
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+0
-1
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+0
-1
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+8
-8
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+3
-3
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+2
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+0
-5
Cython/Compiler/TypeInference.py
Cython/Compiler/TypeInference.py
+0
-6
Cython/Shadow.py
Cython/Shadow.py
+0
-11
runtests.py
runtests.py
+21
-39
No files found.
Cython/Build/Dependencies.py
View file @
a0fff9f2
from
glob
import
glob
from
glob
import
glob
import
re
,
os
,
sys
import
re
,
os
,
sys
from
cython
import
set
from
distutils.extension
import
Extension
from
distutils.extension
import
Extension
...
@@ -8,7 +7,6 @@ from distutils.extension import Extension
...
@@ -8,7 +7,6 @@ from distutils.extension import Extension
from
Cython
import
Utils
from
Cython
import
Utils
from
Cython.Compiler.Main
import
Context
,
CompilationOptions
,
default_options
from
Cython.Compiler.Main
import
Context
,
CompilationOptions
,
default_options
# Unfortunately, Python 2.3 doesn't support decorators.
def
cached_method
(
f
):
def
cached_method
(
f
):
cache_name
=
'__%s_cache'
%
f
.
__name__
cache_name
=
'__%s_cache'
%
f
.
__name__
def
wrapper
(
self
,
*
args
):
def
wrapper
(
self
,
*
args
):
...
@@ -254,12 +252,11 @@ class DependencyTree(object):
...
@@ -254,12 +252,11 @@ class DependencyTree(object):
self
.
context
=
context
self
.
context
=
context
self
.
_transitive_cache
=
{}
self
.
_transitive_cache
=
{}
#
@cached_method
@
cached_method
def
parse_dependencies
(
self
,
source_filename
):
def
parse_dependencies
(
self
,
source_filename
):
return
parse_dependencies
(
source_filename
)
return
parse_dependencies
(
source_filename
)
parse_dependencies
=
cached_method
(
parse_dependencies
)
#
@cached_method
@
cached_method
def
cimports_and_externs
(
self
,
filename
):
def
cimports_and_externs
(
self
,
filename
):
cimports
,
includes
,
externs
=
self
.
parse_dependencies
(
filename
)[:
3
]
cimports
,
includes
,
externs
=
self
.
parse_dependencies
(
filename
)[:
3
]
cimports
=
set
(
cimports
)
cimports
=
set
(
cimports
)
...
@@ -275,25 +272,22 @@ class DependencyTree(object):
...
@@ -275,25 +272,22 @@ class DependencyTree(object):
else
:
else
:
print
(
"Unable to locate '%s' referenced from '%s'"
%
(
filename
,
include
))
print
(
"Unable to locate '%s' referenced from '%s'"
%
(
filename
,
include
))
return
tuple
(
cimports
),
tuple
(
externs
)
return
tuple
(
cimports
),
tuple
(
externs
)
cimports_and_externs
=
cached_method
(
cimports_and_externs
)
def
cimports
(
self
,
filename
):
def
cimports
(
self
,
filename
):
return
self
.
cimports_and_externs
(
filename
)[
0
]
return
self
.
cimports_and_externs
(
filename
)[
0
]
#
@cached_method
@
cached_method
def
package
(
self
,
filename
):
def
package
(
self
,
filename
):
dir
=
os
.
path
.
dirname
(
filename
)
dir
=
os
.
path
.
dirname
(
filename
)
if
os
.
path
.
exists
(
os
.
path
.
join
(
dir
,
'__init__.py'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
dir
,
'__init__.py'
)):
return
self
.
package
(
dir
)
+
(
os
.
path
.
basename
(
dir
),)
return
self
.
package
(
dir
)
+
(
os
.
path
.
basename
(
dir
),)
else
:
else
:
return
()
return
()
package
=
cached_method
(
package
)
#
@cached_method
@
cached_method
def
fully_qualifeid_name
(
self
,
filename
):
def
fully_qualifeid_name
(
self
,
filename
):
module
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
filename
))[
0
]
module
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
filename
))[
0
]
return
'.'
.
join
(
self
.
package
(
filename
)
+
(
module
,))
return
'.'
.
join
(
self
.
package
(
filename
)
+
(
module
,))
fully_qualifeid_name
=
cached_method
(
fully_qualifeid_name
)
def
find_pxd
(
self
,
module
,
filename
=
None
):
def
find_pxd
(
self
,
module
,
filename
=
None
):
if
module
[
0
]
==
'.'
:
if
module
[
0
]
==
'.'
:
...
@@ -306,7 +300,7 @@ class DependencyTree(object):
...
@@ -306,7 +300,7 @@ class DependencyTree(object):
return
self
.
context
.
find_pxd_file
(
module
,
None
)
return
self
.
context
.
find_pxd_file
(
module
,
None
)
find_pxd
=
cached_method
(
find_pxd
)
find_pxd
=
cached_method
(
find_pxd
)
#
@cached_method
@
cached_method
def
cimported_files
(
self
,
filename
):
def
cimported_files
(
self
,
filename
):
if
filename
[
-
4
:]
==
'.pyx'
and
os
.
path
.
exists
(
filename
[:
-
4
]
+
'.pxd'
):
if
filename
[
-
4
:]
==
'.pyx'
and
os
.
path
.
exists
(
filename
[:
-
4
]
+
'.pxd'
):
self_pxd
=
[
filename
[:
-
4
]
+
'.pxd'
]
self_pxd
=
[
filename
[:
-
4
]
+
'.pxd'
]
...
@@ -319,7 +313,6 @@ class DependencyTree(object):
...
@@ -319,7 +313,6 @@ class DependencyTree(object):
print
(
"
\
n
\
t
"
.
join
(
a
))
print
(
"
\
n
\
t
"
.
join
(
a
))
print
(
"
\
n
\
t
"
.
join
(
b
))
print
(
"
\
n
\
t
"
.
join
(
b
))
return
tuple
(
self_pxd
+
filter
(
None
,
[
self
.
find_pxd
(
m
,
filename
)
for
m
in
self
.
cimports
(
filename
)]))
return
tuple
(
self_pxd
+
filter
(
None
,
[
self
.
find_pxd
(
m
,
filename
)
for
m
in
self
.
cimports
(
filename
)]))
cimported_files
=
cached_method
(
cimported_files
)
def
immediate_dependencies
(
self
,
filename
):
def
immediate_dependencies
(
self
,
filename
):
all
=
list
(
self
.
cimported_files
(
filename
))
all
=
list
(
self
.
cimported_files
(
filename
))
...
@@ -327,10 +320,9 @@ class DependencyTree(object):
...
@@ -327,10 +320,9 @@ class DependencyTree(object):
all
.
append
(
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
filename
),
extern
)))
all
.
append
(
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
filename
),
extern
)))
return
tuple
(
all
)
return
tuple
(
all
)
#
@cached_method
@
cached_method
def
timestamp
(
self
,
filename
):
def
timestamp
(
self
,
filename
):
return
os
.
path
.
getmtime
(
filename
)
return
os
.
path
.
getmtime
(
filename
)
timestamp
=
cached_method
(
timestamp
)
def
extract_timestamp
(
self
,
filename
):
def
extract_timestamp
(
self
,
filename
):
# TODO: .h files from extern blocks
# TODO: .h files from extern blocks
...
...
Cython/Build/Inline.py
View file @
a0fff9f2
import
tempfile
import
tempfile
import
sys
,
os
,
re
,
inspect
import
sys
,
os
,
re
,
inspect
from
cython
import
set
try
:
try
:
import
hashlib
import
hashlib
...
...
Cython/Compiler/Buffer.py
View file @
a0fff9f2
...
@@ -10,11 +10,6 @@ import PyrexTypes
...
@@ -10,11 +10,6 @@ import PyrexTypes
import
Naming
import
Naming
import
Symtab
import
Symtab
try
:
set
except
NameError
:
from
sets
import
Set
as
set
import
textwrap
import
textwrap
def
dedent
(
text
,
reindent
=
0
):
def
dedent
(
text
,
reindent
=
0
):
...
...
Cython/Compiler/Code.py
View file @
a0fff9f2
...
@@ -118,13 +118,13 @@ class FunctionState(object):
...
@@ -118,13 +118,13 @@ class FunctionState(object):
# exc_vars (string * 3) exception variables for reraise, or None
# exc_vars (string * 3) exception variables for reraise, or None
# Not used for now, perhaps later
# Not used for now, perhaps later
def
__init__
(
self
,
owner
,
names_taken
=
cython
.
set
()):
def
__init__
(
self
,
owner
,
names_taken
=
set
()):
self
.
names_taken
=
names_taken
self
.
names_taken
=
names_taken
self
.
owner
=
owner
self
.
owner
=
owner
self
.
error_label
=
None
self
.
error_label
=
None
self
.
label_counter
=
0
self
.
label_counter
=
0
self
.
labels_used
=
cython
.
set
()
self
.
labels_used
=
set
()
self
.
return_label
=
self
.
new_label
()
self
.
return_label
=
self
.
new_label
()
self
.
new_error_label
()
self
.
new_error_label
()
self
.
continue_label
=
None
self
.
continue_label
=
None
...
@@ -309,7 +309,7 @@ class FunctionState(object):
...
@@ -309,7 +309,7 @@ class FunctionState(object):
"""
"""
Useful to find out which temps were used in a code block
Useful to find out which temps were used in a code block
"""
"""
self
.
collect_temps_stack
.
append
(
cython
.
set
())
self
.
collect_temps_stack
.
append
(
set
())
def
stop_collecting_temps
(
self
):
def
stop_collecting_temps
(
self
):
return
self
.
collect_temps_stack
.
pop
()
return
self
.
collect_temps_stack
.
pop
()
...
@@ -504,7 +504,7 @@ class GlobalState(object):
...
@@ -504,7 +504,7 @@ class GlobalState(object):
self.filename_table = {}
self.filename_table = {}
self.filename_list = []
self.filename_list = []
self.input_file_contents = {}
self.input_file_contents = {}
self.utility_codes =
cython.
set()
self.utility_codes = set()
self.declared_cnames = {}
self.declared_cnames = {}
self.in_utility_code_generation = False
self.in_utility_code_generation = False
self.emit_linenums = emit_linenums
self.emit_linenums = emit_linenums
...
...
Cython/Compiler/ExprNodes.py
View file @
a0fff9f2
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
#
#
import
cython
import
cython
from
cython
import
set
cython
.
declare
(
error
=
object
,
warning
=
object
,
warn_once
=
object
,
InternalError
=
object
,
cython
.
declare
(
error
=
object
,
warning
=
object
,
warn_once
=
object
,
InternalError
=
object
,
CompileError
=
object
,
UtilityCode
=
object
,
StringEncoding
=
object
,
operator
=
object
,
CompileError
=
object
,
UtilityCode
=
object
,
StringEncoding
=
object
,
operator
=
object
,
Naming
=
object
,
Nodes
=
object
,
PyrexTypes
=
object
,
py_object_type
=
object
,
Naming
=
object
,
Nodes
=
object
,
PyrexTypes
=
object
,
py_object_type
=
object
,
...
...
Cython/Compiler/FlowControl.py
View file @
a0fff9f2
...
@@ -13,8 +13,6 @@ from PyrexTypes import py_object_type, unspecified_type
...
@@ -13,8 +13,6 @@ from PyrexTypes import py_object_type, unspecified_type
from
Visitor
import
TreeVisitor
,
CythonTransform
from
Visitor
import
TreeVisitor
,
CythonTransform
from
Errors
import
error
,
warning
,
CompileError
,
InternalError
from
Errors
import
error
,
warning
,
CompileError
,
InternalError
from
cython
import
set
class
TypedExprNode
(
ExprNodes
.
ExprNode
):
class
TypedExprNode
(
ExprNodes
.
ExprNode
):
# Used for declaring assignments of a specified type whithout a known entry.
# Used for declaring assignments of a specified type whithout a known entry.
def
__init__
(
self
,
type
):
def
__init__
(
self
,
type
):
...
@@ -215,7 +213,7 @@ class ControlFlow(object):
...
@@ -215,7 +213,7 @@ class ControlFlow(object):
offset
=
0
offset
=
0
for
entry
in
self
.
entries
:
for
entry
in
self
.
entries
:
assmts
=
AssignmentList
()
assmts
=
AssignmentList
()
assmts
.
bit
=
1
L
<<
offset
assmts
.
bit
=
1
<<
offset
assmts
.
mask
=
assmts
.
bit
assmts
.
mask
=
assmts
.
bit
self
.
assmts
[
entry
]
=
assmts
self
.
assmts
[
entry
]
=
assmts
offset
+=
1
offset
+=
1
...
@@ -223,7 +221,7 @@ class ControlFlow(object):
...
@@ -223,7 +221,7 @@ class ControlFlow(object):
for
block
in
self
.
blocks
:
for
block
in
self
.
blocks
:
for
stat
in
block
.
stats
:
for
stat
in
block
.
stats
:
if
isinstance
(
stat
,
NameAssignment
):
if
isinstance
(
stat
,
NameAssignment
):
stat
.
bit
=
1
L
<<
offset
stat
.
bit
=
1
<<
offset
assmts
=
self
.
assmts
[
stat
.
entry
]
assmts
=
self
.
assmts
[
stat
.
entry
]
assmts
.
stats
.
append
(
stat
)
assmts
.
stats
.
append
(
stat
)
assmts
.
mask
|=
stat
.
bit
assmts
.
mask
|=
stat
.
bit
...
@@ -561,7 +559,7 @@ class CreateControlFlowGraph(CythonTransform):
...
@@ -561,7 +559,7 @@ class CreateControlFlowGraph(CythonTransform):
self
.
gv_ctx
=
GVContext
()
self
.
gv_ctx
=
GVContext
()
# Set of NameNode reductions
# Set of NameNode reductions
self
.
reductions
=
cython
.
set
()
self
.
reductions
=
set
()
self
.
env_stack
=
[]
self
.
env_stack
=
[]
self
.
env
=
node
.
scope
self
.
env
=
node
.
scope
...
@@ -857,7 +855,7 @@ class CreateControlFlowGraph(CythonTransform):
...
@@ -857,7 +855,7 @@ class CreateControlFlowGraph(CythonTransform):
# if node.target is None or not a NameNode, an error will have
# if node.target is None or not a NameNode, an error will have
# been previously issued
# been previously issued
if
hasattr
(
node
.
target
,
'entry'
):
if
hasattr
(
node
.
target
,
'entry'
):
self
.
reductions
=
cython
.
set
(
reductions
)
self
.
reductions
=
set
(
reductions
)
for
private_node
in
node
.
assigned_nodes
:
for
private_node
in
node
.
assigned_nodes
:
private_node
.
entry
.
error_on_uninitialized
=
True
private_node
.
entry
.
error_on_uninitialized
=
True
...
...
Cython/Compiler/Main.py
View file @
a0fff9f2
...
@@ -7,12 +7,6 @@ if sys.version_info[:2] < (2, 3):
...
@@ -7,12 +7,6 @@ if sys.version_info[:2] < (2, 3):
sys
.
stderr
.
write
(
"Sorry, Cython requires Python 2.3 or later
\
n
"
)
sys
.
stderr
.
write
(
"Sorry, Cython requires Python 2.3 or later
\
n
"
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
try
:
set
except
NameError
:
# Python 2.3
from
sets
import
Set
as
set
import
itertools
import
itertools
import
Code
import
Code
...
...
Cython/Compiler/ModuleNode.py
View file @
a0fff9f2
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
#
#
import
cython
import
cython
from
cython
import
set
cython
.
declare
(
Naming
=
object
,
Options
=
object
,
PyrexTypes
=
object
,
TypeSlots
=
object
,
cython
.
declare
(
Naming
=
object
,
Options
=
object
,
PyrexTypes
=
object
,
TypeSlots
=
object
,
error
=
object
,
warning
=
object
,
py_object_type
=
object
,
UtilityCode
=
object
,
error
=
object
,
warning
=
object
,
py_object_type
=
object
,
UtilityCode
=
object
,
EncodedString
=
object
)
EncodedString
=
object
)
...
...
Cython/Compiler/Nodes.py
View file @
a0fff9f2
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
# Pyrex - Parse tree nodes
# Pyrex - Parse tree nodes
#
#
import
cython
import
cython
from
cython
import
set
cython
.
declare
(
sys
=
object
,
os
=
object
,
time
=
object
,
copy
=
object
,
cython
.
declare
(
sys
=
object
,
os
=
object
,
time
=
object
,
copy
=
object
,
Builtin
=
object
,
error
=
object
,
warning
=
object
,
Naming
=
object
,
PyrexTypes
=
object
,
Builtin
=
object
,
error
=
object
,
warning
=
object
,
Naming
=
object
,
PyrexTypes
=
object
,
py_object_type
=
object
,
ModuleScope
=
object
,
LocalScope
=
object
,
ClosureScope
=
object
,
\
py_object_type
=
object
,
ModuleScope
=
object
,
LocalScope
=
object
,
ClosureScope
=
object
,
\
...
...
Cython/Compiler/Optimize.py
View file @
a0fff9f2
import
cython
import
cython
from
cython
import
set
cython
.
declare
(
UtilityCode
=
object
,
EncodedString
=
object
,
BytesLiteral
=
object
,
cython
.
declare
(
UtilityCode
=
object
,
EncodedString
=
object
,
BytesLiteral
=
object
,
Nodes
=
object
,
ExprNodes
=
object
,
PyrexTypes
=
object
,
Builtin
=
object
,
Nodes
=
object
,
ExprNodes
=
object
,
PyrexTypes
=
object
,
Builtin
=
object
,
UtilNodes
=
object
,
Naming
=
object
)
UtilNodes
=
object
,
Naming
=
object
)
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
a0fff9f2
...
@@ -339,7 +339,7 @@ def eliminate_rhs_duplicates(expr_list_list, ref_node_sequence):
...
@@ -339,7 +339,7 @@ def eliminate_rhs_duplicates(expr_list_list, ref_node_sequence):
and appends them to ref_node_sequence. The input list is modified
and appends them to ref_node_sequence. The input list is modified
in-place.
in-place.
"""
"""
seen_nodes
=
cython
.
set
()
seen_nodes
=
set
()
ref_nodes
=
{}
ref_nodes
=
{}
def
find_duplicates
(
node
):
def
find_duplicates
(
node
):
if
node
.
is_literal
or
node
.
is_name
:
if
node
.
is_literal
or
node
.
is_name
:
...
@@ -610,11 +610,11 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
...
@@ -610,11 +610,11 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
'operator.comma'
:
ExprNodes
.
c_binop_constructor
(
','
),
'operator.comma'
:
ExprNodes
.
c_binop_constructor
(
','
),
}
}
special_methods
=
cython
.
set
([
'declare'
,
'union'
,
'struct'
,
'typedef'
,
'sizeof'
,
special_methods
=
set
([
'declare'
,
'union'
,
'struct'
,
'typedef'
,
'sizeof'
,
'cast'
,
'pointer'
,
'compiled'
,
'NULL'
,
'parallel'
])
'cast'
,
'pointer'
,
'compiled'
,
'NULL'
,
'parallel'
])
special_methods
.
update
(
unop_method_nodes
.
keys
())
special_methods
.
update
(
unop_method_nodes
.
keys
())
valid_parallel_directives
=
cython
.
set
([
valid_parallel_directives
=
set
([
"parallel"
,
"parallel"
,
"prange"
,
"prange"
,
"threadid"
,
"threadid"
,
...
@@ -626,7 +626,7 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
...
@@ -626,7 +626,7 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
self
.
compilation_directive_defaults
=
{}
self
.
compilation_directive_defaults
=
{}
for
key
,
value
in
compilation_directive_defaults
.
items
():
for
key
,
value
in
compilation_directive_defaults
.
items
():
self
.
compilation_directive_defaults
[
unicode
(
key
)]
=
copy
.
deepcopy
(
value
)
self
.
compilation_directive_defaults
[
unicode
(
key
)]
=
copy
.
deepcopy
(
value
)
self
.
cython_module_names
=
cython
.
set
()
self
.
cython_module_names
=
set
()
self
.
directive_names
=
{}
self
.
directive_names
=
{}
self
.
parallel_directives
=
{}
self
.
parallel_directives
=
{}
...
@@ -1380,7 +1380,7 @@ if VALUE is not None:
...
@@ -1380,7 +1380,7 @@ if VALUE is not None:
return
node
return
node
def
visit_ModuleNode
(
self
,
node
):
def
visit_ModuleNode
(
self
,
node
):
self
.
seen_vars_stack
.
append
(
cython
.
set
())
self
.
seen_vars_stack
.
append
(
set
())
node
.
analyse_declarations
(
self
.
env_stack
[
-
1
])
node
.
analyse_declarations
(
self
.
env_stack
[
-
1
])
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
self
.
seen_vars_stack
.
pop
()
self
.
seen_vars_stack
.
pop
()
...
@@ -1412,7 +1412,7 @@ if VALUE is not None:
...
@@ -1412,7 +1412,7 @@ if VALUE is not None:
return
node
return
node
def
visit_FuncDefNode
(
self
,
node
):
def
visit_FuncDefNode
(
self
,
node
):
self
.
seen_vars_stack
.
append
(
cython
.
set
())
self
.
seen_vars_stack
.
append
(
set
())
lenv
=
node
.
local_scope
lenv
=
node
.
local_scope
node
.
declare_arguments
(
lenv
)
node
.
declare_arguments
(
lenv
)
for
var
,
type_node
in
node
.
directive_locals
.
items
():
for
var
,
type_node
in
node
.
directive_locals
.
items
():
...
@@ -1446,7 +1446,7 @@ if VALUE is not None:
...
@@ -1446,7 +1446,7 @@ if VALUE is not None:
node
.
analyse_declarations
(
env
)
node
.
analyse_declarations
(
env
)
# the node may or may not have a local scope
# the node may or may not have a local scope
if
node
.
has_local_scope
:
if
node
.
has_local_scope
:
self
.
seen_vars_stack
.
append
(
cython
.
set
(
self
.
seen_vars_stack
[
-
1
]))
self
.
seen_vars_stack
.
append
(
set
(
self
.
seen_vars_stack
[
-
1
]))
self
.
env_stack
.
append
(
node
.
expr_scope
)
self
.
env_stack
.
append
(
node
.
expr_scope
)
node
.
analyse_scoped_declarations
(
node
.
expr_scope
)
node
.
analyse_scoped_declarations
(
node
.
expr_scope
)
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
...
@@ -2345,7 +2345,7 @@ class DebugTransform(CythonTransform):
...
@@ -2345,7 +2345,7 @@ class DebugTransform(CythonTransform):
def
__init__
(
self
,
context
,
options
,
result
):
def
__init__
(
self
,
context
,
options
,
result
):
super
(
DebugTransform
,
self
).
__init__
(
context
)
super
(
DebugTransform
,
self
).
__init__
(
context
)
self
.
visited
=
cython
.
set
()
self
.
visited
=
set
()
# our treebuilder and debug output writer
# our treebuilder and debug output writer
# (see Cython.Debugger.debug_output.CythonDebugWriter)
# (see Cython.Debugger.debug_output.CythonDebugWriter)
self
.
tb
=
self
.
context
.
gdb_debug_outputwriter
self
.
tb
=
self
.
context
.
gdb_debug_outputwriter
...
...
Cython/Compiler/Parsing.py
View file @
a0fff9f2
...
@@ -875,7 +875,7 @@ def p_comp_for(s, body):
...
@@ -875,7 +875,7 @@ def p_comp_for(s, body):
pos
=
s
.
position
()
pos
=
s
.
position
()
s
.
next
()
s
.
next
()
kw
=
p_for_bounds
(
s
,
allow_testlist
=
False
)
kw
=
p_for_bounds
(
s
,
allow_testlist
=
False
)
kw
.
update
(
dict
(
else_clause
=
None
,
body
=
p_comp_iter
(
s
,
body
)
))
kw
.
update
(
else_clause
=
None
,
body
=
p_comp_iter
(
s
,
body
))
return
Nodes
.
ForStatNode
(
pos
,
**
kw
)
return
Nodes
.
ForStatNode
(
pos
,
**
kw
)
def
p_comp_if
(
s
,
body
):
def
p_comp_if
(
s
,
body
):
...
@@ -1404,7 +1404,7 @@ def p_for_statement(s):
...
@@ -1404,7 +1404,7 @@ def p_for_statement(s):
kw
=
p_for_bounds
(
s
,
allow_testlist
=
True
)
kw
=
p_for_bounds
(
s
,
allow_testlist
=
True
)
body
=
p_suite
(
s
)
body
=
p_suite
(
s
)
else_clause
=
p_else_clause
(
s
)
else_clause
=
p_else_clause
(
s
)
kw
.
update
(
dict
(
body
=
body
,
else_clause
=
else_clause
)
)
kw
.
update
(
body
=
body
,
else_clause
=
else_clause
)
return
Nodes
.
ForStatNode
(
pos
,
**
kw
)
return
Nodes
.
ForStatNode
(
pos
,
**
kw
)
def
p_for_bounds
(
s
,
allow_testlist
=
True
):
def
p_for_bounds
(
s
,
allow_testlist
=
True
):
...
@@ -2187,7 +2187,7 @@ def p_c_func_declarator(s, pos, ctx, base, cmethod_flag):
...
@@ -2187,7 +2187,7 @@ def p_c_func_declarator(s, pos, ctx, base, cmethod_flag):
exception_value
=
exc_val
,
exception_check
=
exc_check
,
exception_value
=
exc_val
,
exception_check
=
exc_check
,
nogil
=
nogil
or
ctx
.
nogil
or
with_gil
,
with_gil
=
with_gil
)
nogil
=
nogil
or
ctx
.
nogil
or
with_gil
,
with_gil
=
with_gil
)
supported_overloaded_operators
=
cython
.
set
([
supported_overloaded_operators
=
set
([
'+'
,
'-'
,
'*'
,
'/'
,
'%'
,
'+'
,
'-'
,
'*'
,
'/'
,
'%'
,
'++'
,
'--'
,
'~'
,
'|'
,
'&'
,
'^'
,
'<<'
,
'>>'
,
','
,
'++'
,
'--'
,
'~'
,
'|'
,
'&'
,
'^'
,
'<<'
,
'>>'
,
','
,
'=='
,
'!='
,
'>='
,
'>'
,
'<='
,
'<'
,
'=='
,
'!='
,
'>='
,
'>'
,
'<='
,
'<'
,
...
...
Cython/Compiler/Scanning.py
View file @
a0fff9f2
...
@@ -282,10 +282,10 @@ class PyrexScanner(Scanner):
...
@@ -282,10 +282,10 @@ class PyrexScanner(Scanner):
self
.
source_encoding
=
source_encoding
self
.
source_encoding
=
source_encoding
if
filename
.
is_python_file
():
if
filename
.
is_python_file
():
self
.
in_python_file
=
True
self
.
in_python_file
=
True
self
.
keywords
=
cython
.
set
(
py_reserved_words
)
self
.
keywords
=
set
(
py_reserved_words
)
else
:
else
:
self
.
in_python_file
=
False
self
.
in_python_file
=
False
self
.
keywords
=
cython
.
set
(
pyx_reserved_words
)
self
.
keywords
=
set
(
pyx_reserved_words
)
self
.
trace
=
trace_scanner
self
.
trace
=
trace_scanner
self
.
indentation_stack
=
[
0
]
self
.
indentation_stack
=
[
0
]
self
.
indentation_char
=
None
self
.
indentation_char
=
None
...
...
Cython/Compiler/Symtab.py
View file @
a0fff9f2
...
@@ -15,11 +15,6 @@ from TypeSlots import \
...
@@ -15,11 +15,6 @@ from TypeSlots import \
get_special_method_signature
,
get_property_accessor_signature
get_special_method_signature
,
get_property_accessor_signature
import
Code
import
Code
import
__builtin__
as
builtins
import
__builtin__
as
builtins
try
:
set
except
NameError
:
from
sets
import
Set
as
set
import
copy
possible_identifier
=
re
.
compile
(
ur"(?![0-9])\
w+$
", re.U).match
possible_identifier
=
re
.
compile
(
ur"(?![0-9])\
w+$
", re.U).match
nice_identifier = re.compile('^[a-zA-Z0-0_]+$').match
nice_identifier = re.compile('^[a-zA-Z0-0_]+$').match
...
...
Cython/Compiler/TypeInference.py
View file @
a0fff9f2
...
@@ -7,12 +7,6 @@ from Cython import Utils
...
@@ -7,12 +7,6 @@ from Cython import Utils
from
PyrexTypes
import
py_object_type
,
unspecified_type
from
PyrexTypes
import
py_object_type
,
unspecified_type
from
Visitor
import
CythonTransform
from
Visitor
import
CythonTransform
try
:
set
except
NameError
:
# Python 2.3
from
sets
import
Set
as
set
class
TypedExprNode
(
ExprNodes
.
ExprNode
):
class
TypedExprNode
(
ExprNodes
.
ExprNode
):
# Used for declaring assignments of a specified type whithout a known entry.
# Used for declaring assignments of a specified type whithout a known entry.
...
...
Cython/Shadow.py
View file @
a0fff9f2
...
@@ -239,17 +239,6 @@ py_float = float
...
@@ -239,17 +239,6 @@ py_float = float
py_complex
=
complex
py_complex
=
complex
try
:
# Python 3
from
builtins
import
set
,
frozenset
except
ImportError
:
try
:
# Python 2.4+
from
__builtin__
import
set
,
frozenset
except
ImportError
:
# Py 2.3
from
sets
import
Set
as
set
,
ImmutableSet
as
frozenset
# Predefined types
# Predefined types
int_types
=
[
'char'
,
'short'
,
'Py_UNICODE'
,
'int'
,
'long'
,
'longlong'
,
'Py_ssize_t'
,
'size_t'
]
int_types
=
[
'char'
,
'short'
,
'Py_UNICODE'
,
'int'
,
'long'
,
'longlong'
,
'Py_ssize_t'
,
'size_t'
]
...
...
runtests.py
View file @
a0fff9f2
...
@@ -11,9 +11,11 @@ import time
...
@@ -11,9 +11,11 @@ import time
import
unittest
import
unittest
import
doctest
import
doctest
import
operator
import
operator
import
subprocess
import
tempfile
import
tempfile
import
warnings
import
traceback
import
traceback
import
warnings
try
:
try
:
from
StringIO
import
StringIO
from
StringIO
import
StringIO
except
ImportError
:
except
ImportError
:
...
@@ -115,17 +117,6 @@ def get_openmp_compiler_flags(language):
...
@@ -115,17 +117,6 @@ def get_openmp_compiler_flags(language):
cc
=
cc
.
split
()[
0
]
cc
=
cc
.
split
()[
0
]
matcher
=
re
.
compile
(
r"gcc version (\
d+
\.\
d+)
").search
matcher
=
re
.
compile
(
r"gcc version (\
d+
\.\
d+)
").search
try:
import subprocess
except ImportError:
try:
in_, out_err = os.popen4([cc, "
-
v
"])
except EnvironmentError:
warnings.warn("
Unable
to
find
the
%
s
compiler
:
%
s
:
%
s
" %
(language, os.strerror(sys.exc_info()[1].errno), cc))
return None
output = out_err.read()
else:
try:
try:
p = subprocess.Popen([cc, "
-
v
"], stderr=subprocess.PIPE)
p = subprocess.Popen([cc, "
-
v
"], stderr=subprocess.PIPE)
except EnvironmentError:
except EnvironmentError:
...
@@ -1036,8 +1027,6 @@ class EndToEndTest(unittest.TestCase):
...
@@ -1036,8 +1027,6 @@ class EndToEndTest(unittest.TestCase):
old_path = os.environ.get('PYTHONPATH')
old_path = os.environ.get('PYTHONPATH')
os.environ['PYTHONPATH'] = self.cython_syspath + os.pathsep + os.path.join(self.cython_syspath, (old_path or ''))
os.environ['PYTHONPATH'] = self.cython_syspath + os.pathsep + os.path.join(self.cython_syspath, (old_path or ''))
for command in commands.split('
\
n
'):
for command in commands.split('
\
n
'):
if sys.version_info[:2] >= (2,4):
import subprocess
p = subprocess.Popen(commands,
p = subprocess.Popen(commands,
stderr=subprocess.PIPE,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
stdout=subprocess.PIPE,
...
@@ -1048,8 +1037,6 @@ class EndToEndTest(unittest.TestCase):
...
@@ -1048,8 +1037,6 @@ class EndToEndTest(unittest.TestCase):
print(command)
print(command)
print(out)
print(out)
print(err)
print(err)
else:
res = os.system(command)
self.assertEqual(0, res, "
non
-
zero
exit
status
")
self.assertEqual(0, res, "
non
-
zero
exit
status
")
finally:
finally:
if old_path:
if old_path:
...
@@ -1238,11 +1225,6 @@ def check_thread_termination(ignore_seen=True):
...
@@ -1238,11 +1225,6 @@ def check_thread_termination(ignore_seen=True):
def subprocess_output(cmd):
def subprocess_output(cmd):
try:
try:
try:
import subprocess
except:
return os.popen4(cmd)[1].read()
else:
return subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
return subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
except OSError:
except OSError:
return ''
return ''
...
...
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