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
a8af26e0
Commit
a8af26e0
authored
Mar 28, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.24.x'
parents
9ef17d2e
642b09e7
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
679 additions
and
743 deletions
+679
-743
Cython/CodeWriter.py
Cython/CodeWriter.py
+3
-3
Cython/Compiler/AutoDocTransforms.py
Cython/Compiler/AutoDocTransforms.py
+2
-2
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+18
-21
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+187
-202
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+406
-457
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+17
-8
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+5
-6
Cython/Compiler/UtilityCode.py
Cython/Compiler/UtilityCode.py
+19
-24
Cython/Compiler/Visitor.py
Cython/Compiler/Visitor.py
+5
-8
Cython/Shadow.py
Cython/Shadow.py
+11
-8
Cython/__init__.py
Cython/__init__.py
+5
-3
pylintrc
pylintrc
+1
-1
No files found.
Cython/CodeWriter.py
View file @
a8af26e0
...
...
@@ -32,7 +32,7 @@ class DeclarationWriter(TreeVisitor):
indent_string
=
u" "
def
__init__
(
self
,
result
=
None
):
def
__init__
(
self
,
result
=
None
):
super
(
DeclarationWriter
,
self
).
__init__
()
if
result
is
None
:
result
=
LinesResult
()
...
...
@@ -51,7 +51,7 @@ class DeclarationWriter(TreeVisitor):
def
dedent
(
self
):
self
.
numindents
-=
1
def
startline
(
self
,
s
=
u""
):
def
startline
(
self
,
s
=
u""
):
self
.
result
.
put
(
self
.
indent_string
*
self
.
numindents
+
s
)
def
put
(
self
,
s
):
...
...
@@ -60,7 +60,7 @@ class DeclarationWriter(TreeVisitor):
def
putline
(
self
,
s
):
self
.
result
.
putline
(
self
.
indent_string
*
self
.
numindents
+
s
)
def
endline
(
self
,
s
=
u""
):
def
endline
(
self
,
s
=
u""
):
self
.
result
.
putline
(
s
)
def
line
(
self
,
s
):
...
...
Cython/Compiler/AutoDocTransforms.py
View file @
a8af26e0
...
...
@@ -70,7 +70,7 @@ class EmbedSignature(CythonTransform):
except
Exception
:
try
:
return
self
.
_fmt_expr_node
(
default_val
)
except
AttributeError
as
e
:
except
AttributeError
:
return
'<???>'
def
_fmt_arg
(
self
,
arg
):
...
...
@@ -190,7 +190,7 @@ class EmbedSignature(CythonTransform):
old_doc
=
node
.
py_func
.
entry
.
doc
else
:
old_doc
=
None
new_doc
=
self
.
_embed_signature
(
signature
,
old_doc
)
new_doc
=
self
.
_embed_signature
(
signature
,
old_doc
)
doc_holder
.
doc
=
EncodedString
(
new_doc
)
if
not
is_constructor
and
getattr
(
node
,
'py_func'
,
None
)
is
not
None
:
node
.
py_func
.
entry
.
doc
=
EncodedString
(
new_doc
)
...
...
Cython/Compiler/Code.py
View file @
a8af26e0
...
...
@@ -40,7 +40,7 @@ try:
except
ImportError
:
from
builtins
import
str
as
basestring
KEYWORDS_MUST_BE_BYTES
=
sys
.
version_info
<
(
2
,
7
)
KEYWORDS_MUST_BE_BYTES
=
sys
.
version_info
<
(
2
,
7
)
non_portable_builtins_map
=
{
...
...
@@ -392,12 +392,12 @@ class UtilityCode(UtilityCodeBase):
requires = [r.specialize(data) for r in self.requires]
s = self._cache[key] = UtilityCode(
self.none_or_sub(self.proto, data),
self.none_or_sub(self.impl, data),
self.none_or_sub(self.init, data),
self.none_or_sub(self.cleanup, data),
requires,
self.proto_block)
self.none_or_sub(self.proto, data),
self.none_or_sub(self.impl, data),
self.none_or_sub(self.init, data),
self.none_or_sub(self.cleanup, data),
requires,
self.proto_block)
self.specialize_list.append(s)
return s
...
...
@@ -481,7 +481,7 @@ class UtilityCode(UtilityCodeBase):
is_specialised1, impl = self.inject_string_constants(impl, output)
is_specialised2, impl = self.inject_unbound_methods(impl, output)
writer = output['
utility_code_def
']
writer.putln("/* %s */" % self.name)
;
writer.putln("/* %s */" % self.name)
if not (is_specialised1 or is_specialised2):
# no module specific adaptations => can be reused
writer.put_or_include(impl, '
%
s_impl
' % self.name)
...
...
@@ -773,8 +773,8 @@ class FunctionState(object):
"""Return a list of (cname, type) tuples of refcount-managed Python objects.
"""
return [(cname, type)
for cname, type, manage_ref, static in self.temps_allocated
if manage_ref]
for cname, type, manage_ref, static in self.temps_allocated
if manage_ref]
def all_free_managed_temps(self):
"""Return a list of (cname, type) tuples of refcount-managed Python
...
...
@@ -849,7 +849,7 @@ class StringConst(object):
def add_py_version(self, version):
if not version:
self.py_versions = [2,3]
self.py_versions = [2,
3]
elif version not in self.py_versions:
self.py_versions.append(version)
...
...
@@ -1280,8 +1280,8 @@ class GlobalState(object):
self
.
generate_object_constant_decls
()
def
generate_object_constant_decls
(
self
):
consts
=
[
(
len
(
c
.
cname
),
c
.
cname
,
c
)
for
c
in
self
.
py_constants
]
consts
=
[(
len
(
c
.
cname
),
c
.
cname
,
c
)
for
c
in
self
.
py_constants
]
consts
.
sort
()
decls_writer
=
self
.
parts
[
'decls'
]
for
_
,
cname
,
c
in
consts
:
...
...
@@ -1345,12 +1345,11 @@ class GlobalState(object):
py_strings
.
sort
()
w
=
self
.
parts
[
'pystring_table'
]
w
.
putln
(
""
)
w
.
putln
(
"static __Pyx_StringTabEntry %s[] = {"
%
Naming
.
stringtab_cname
)
w
.
putln
(
"static __Pyx_StringTabEntry %s[] = {"
%
Naming
.
stringtab_cname
)
for
c_cname
,
_
,
py_string
in
py_strings
:
if
not
py_string
.
is_str
or
not
py_string
.
encoding
or
\
py_string
.
encoding
in
(
'ASCII'
,
'USASCII'
,
'US-ASCII'
,
'UTF8'
,
'UTF-8'
):
py_string
.
encoding
in
(
'ASCII'
,
'USASCII'
,
'US-ASCII'
,
'UTF8'
,
'UTF-8'
):
encoding
=
'0'
else
:
encoding
=
'"%s"'
%
py_string
.
encoding
.
lower
()
...
...
@@ -1359,8 +1358,7 @@ class GlobalState(object):
"static PyObject *%s;"
%
py_string
.
cname
)
if
py_string
.
py3str_cstring
:
w
.
putln
(
"#if PY_MAJOR_VERSION >= 3"
)
w
.
putln
(
"{&%s, %s, sizeof(%s), %s, %d, %d, %d},"
%
(
w
.
putln
(
"{&%s, %s, sizeof(%s), %s, %d, %d, %d},"
%
(
py_string
.
cname
,
py_string
.
py3str_cstring
.
cname
,
py_string
.
py3str_cstring
.
cname
,
...
...
@@ -1368,8 +1366,7 @@ class GlobalState(object):
py_string
.
intern
))
w
.
putln
(
"#else"
)
w
.
putln
(
"{&%s, %s, sizeof(%s), %s, %d, %d, %d},"
%
(
w
.
putln
(
"{&%s, %s, sizeof(%s), %s, %d, %d, %d},"
%
(
py_string
.
cname
,
c_cname
,
c_cname
,
...
...
Cython/Compiler/ModuleNode.py
View file @
a8af26e0
This diff is collapsed.
Click to expand it.
Cython/Compiler/Nodes.py
View file @
a8af26e0
This diff is collapsed.
Click to expand it.
Cython/Compiler/Options.py
View file @
a8af26e0
...
...
@@ -263,6 +263,7 @@ directive_scopes = { # defaults to available everywhere
'language_level'
:
(
'module'
,),
}
def
parse_directive_value
(
name
,
value
,
relaxed_bool
=
False
):
"""
Parses value as an option value for the given name and returns
...
...
@@ -292,16 +293,21 @@ def parse_directive_value(name, value, relaxed_bool=False):
ValueError: c_string_type directive must be one of ('bytes', 'bytearray', 'str', 'unicode'), got 'unnicode'
"""
type
=
directive_types
.
get
(
name
)
if
not
type
:
return
None
if
not
type
:
return
None
orig_value
=
value
if
type
is
bool
:
value
=
str
(
value
)
if
value
==
'True'
:
return
True
if
value
==
'False'
:
return
False
if
value
==
'True'
:
return
True
if
value
==
'False'
:
return
False
if
relaxed_bool
:
value
=
value
.
lower
()
if
value
in
(
"true"
,
"yes"
):
return
True
elif
value
in
(
"false"
,
"no"
):
return
False
if
value
in
(
"true"
,
"yes"
):
return
True
elif
value
in
(
"false"
,
"no"
):
return
False
raise
ValueError
(
"%s directive must be set to True or False, got '%s'"
%
(
name
,
orig_value
))
elif
type
is
int
:
...
...
@@ -317,6 +323,7 @@ def parse_directive_value(name, value, relaxed_bool=False):
else
:
assert
False
def
parse_directive_list
(
s
,
relaxed_bool
=
False
,
ignore_unknown
=
False
,
current_settings
=
None
):
"""
...
...
@@ -352,9 +359,11 @@ def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False,
result
=
current_settings
for
item
in
s
.
split
(
','
):
item
=
item
.
strip
()
if
not
item
:
continue
if
not
'='
in
item
:
raise
ValueError
(
'Expected "=" in option "%s"'
%
item
)
name
,
value
=
[
s
.
strip
()
for
s
in
item
.
strip
().
split
(
'='
,
1
)
]
if
not
item
:
continue
if
not
'='
in
item
:
raise
ValueError
(
'Expected "=" in option "%s"'
%
item
)
name
,
value
=
[
s
.
strip
()
for
s
in
item
.
strip
().
split
(
'='
,
1
)]
if
name
not
in
directive_defaults
:
found
=
False
if
name
.
endswith
(
'.all'
):
...
...
Cython/Compiler/Scanning.py
View file @
a8af26e0
...
...
@@ -68,7 +68,7 @@ class Method(object):
class
CompileTimeScope
(
object
):
def
__init__
(
self
,
outer
=
None
):
def
__init__
(
self
,
outer
=
None
):
self
.
entries
=
{}
self
.
outer
=
outer
...
...
@@ -97,8 +97,7 @@ class CompileTimeScope(object):
def
initial_compile_time_env
():
benv
=
CompileTimeScope
()
names
=
(
'UNAME_SYSNAME'
,
'UNAME_NODENAME'
,
'UNAME_RELEASE'
,
'UNAME_VERSION'
,
'UNAME_MACHINE'
)
names
=
(
'UNAME_SYSNAME'
,
'UNAME_NODENAME'
,
'UNAME_RELEASE'
,
'UNAME_VERSION'
,
'UNAME_MACHINE'
)
for
name
,
value
in
zip
(
names
,
platform
.
uname
()):
benv
.
declare
(
name
,
value
)
try
:
...
...
@@ -272,8 +271,8 @@ class StringSourceDescriptor(SourceDescriptor):
if
not
encoding
:
return
self
.
codelines
else
:
return
[
line
.
encode
(
encoding
,
error_handling
).
decode
(
encoding
)
for
line
in
self
.
codelines
]
return
[
line
.
encode
(
encoding
,
error_handling
).
decode
(
encoding
)
for
line
in
self
.
codelines
]
def
get_description
(
self
):
return
self
.
name
...
...
@@ -487,7 +486,7 @@ class PyrexScanner(Scanner):
else
:
self
.
expected
(
what
,
message
)
def
expected
(
self
,
what
,
message
=
None
):
def
expected
(
self
,
what
,
message
=
None
):
if
message
:
self
.
error
(
message
)
else
:
...
...
Cython/Compiler/UtilityCode.py
View file @
a8af26e0
...
...
@@ -17,8 +17,7 @@ class NonManglingModuleScope(Symtab.ModuleScope):
def
add_imported_entry
(
self
,
name
,
entry
,
pos
):
entry
.
used
=
True
return
super
(
NonManglingModuleScope
,
self
).
add_imported_entry
(
name
,
entry
,
pos
)
return
super
(
NonManglingModuleScope
,
self
).
add_imported_entry
(
name
,
entry
,
pos
)
def
mangle
(
self
,
prefix
,
name
=
None
):
if
name
:
...
...
@@ -137,26 +136,22 @@ class CythonUtilityCode(Code.UtilityCodeBase):
pipeline
=
Pipeline
.
insert_into_pipeline
(
pipeline
,
transform
,
before
=
before
)
if
self
.
from_scope
:
def
scope_transform
(
module_node
):
module_node
.
scope
.
merge_in
(
s
elf
.
from_s
cope
)
def
merge_scope
(
scope
)
:
def
merge_
scope_transform
(
module_node
):
module_node
.
scope
.
merge_in
(
scope
)
return
module_node
return
merge_scope_transform
transform
=
ParseTreeTransforms
.
AnalyseDeclarationsTransform
pipeline
=
Pipeline
.
insert_into_pipeline
(
pipeline
,
scope_transform
,
before
=
transform
)
if
self
.
from_scope
:
pipeline
=
Pipeline
.
insert_into_pipeline
(
pipeline
,
merge_scope
(
self
.
from_scope
),
before
=
ParseTreeTransforms
.
AnalyseDeclarationsTransform
)
for
dep
in
self
.
requires
:
if
(
isinstance
(
dep
,
CythonUtilityCode
)
and
hasattr
(
dep
,
'tree'
)
and
not
cython_scope
):
def
scope_transform
(
module_node
):
module_node
.
scope
.
merge_in
(
dep
.
tree
.
scope
)
return
module_node
transform
=
ParseTreeTransforms
.
AnalyseDeclarationsTransform
pipeline
=
Pipeline
.
insert_into_pipeline
(
pipeline
,
scope_transform
,
before
=
transform
)
if
isinstance
(
dep
,
CythonUtilityCode
)
and
hasattr
(
dep
,
'tree'
)
and
not
cython_scope
:
pipeline
=
Pipeline
.
insert_into_pipeline
(
pipeline
,
merge_scope
(
dep
.
tree
.
scope
),
before
=
ParseTreeTransforms
.
AnalyseDeclarationsTransform
)
if
self
.
outer_module_scope
:
# inject outer module between utility code module and builtin module
...
...
@@ -164,9 +159,9 @@ class CythonUtilityCode(Code.UtilityCodeBase):
module_node
.
scope
.
outer_scope
=
self
.
outer_module_scope
return
module_node
transform
=
ParseTreeTransforms
.
AnalyseDeclarationsTransform
pipeline
=
Pipeline
.
insert_into_pipeline
(
pipeline
,
scope_transform
,
before
=
t
ransform
)
pipeline
=
Pipeline
.
insert_into_pipeline
(
pipeline
,
scope_transform
,
before
=
ParseTreeTransforms
.
AnalyseDeclarationsT
ransform
)
(
err
,
tree
)
=
Pipeline
.
run_pipeline
(
pipeline
,
tree
,
printtree
=
False
)
assert
not
err
,
err
...
...
@@ -199,13 +194,12 @@ class CythonUtilityCode(Code.UtilityCodeBase):
entries
.
pop
(
'__builtins__'
)
entries
.
pop
(
'__doc__'
)
for
name
,
entry
in
entries
.
item
s
():
for
entry
in
entries
.
value
s
():
entry
.
utility_code_definition
=
self
entry
.
used
=
used
original_scope
=
tree
.
scope
dest_scope
.
merge_in
(
original_scope
,
merge_unused
=
True
,
whitelist
=
whitelist
)
dest_scope
.
merge_in
(
original_scope
,
merge_unused
=
True
,
whitelist
=
whitelist
)
tree
.
scope
=
dest_scope
for
dep
in
self
.
requires
:
...
...
@@ -214,6 +208,7 @@ class CythonUtilityCode(Code.UtilityCodeBase):
return
original_scope
def
declare_declarations_in_scope
(
declaration_string
,
env
,
private_type
=
True
,
*
args
,
**
kwargs
):
"""
...
...
Cython/Compiler/Visitor.py
View file @
a8af26e0
...
...
@@ -77,9 +77,8 @@ class TreeVisitor(object):
self
.
access_path
=
[]
def
dump_node
(
self
,
node
,
indent
=
0
):
ignored
=
list
(
node
.
child_attrs
or
[])
+
[
u'child_attrs'
,
u'pos'
,
u'gil_message'
,
u'cpp_message'
,
u'subexprs'
]
ignored
=
list
(
node
.
child_attrs
or
[])
+
[
u'child_attrs'
,
u'pos'
,
u'gil_message'
,
u'cpp_message'
,
u'subexprs'
]
values
=
[]
pos
=
getattr
(
node
,
'pos'
,
None
)
if
pos
:
...
...
@@ -93,7 +92,7 @@ class TreeVisitor(object):
for
attr
in
attribute_names
:
if
attr
in
ignored
:
continue
if
attr
.
startswith
(
u'_'
)
or
attr
.
endswith
(
u
'_'
):
if
attr
.
startswith
(
'_'
)
or
attr
.
endswith
(
'_'
):
continue
try
:
value
=
getattr
(
node
,
attr
)
...
...
@@ -108,8 +107,7 @@ class TreeVisitor(object):
else
:
value
=
repr
(
value
)
values
.
append
(
u'%s = %s'
%
(
attr
,
value
))
return
u'%s(%s)'
%
(
node
.
__class__
.
__name__
,
u',
\
n
'
.
join
(
values
))
return
u'%s(%s)'
%
(
node
.
__class__
.
__name__
,
u',
\
n
'
.
join
(
values
))
def
_find_node_path
(
self
,
stacktrace
):
import
os.path
...
...
@@ -129,7 +127,6 @@ class TreeVisitor(object):
return
(
last_traceback
,
nodes
)
def
_raise_compiler_error
(
self
,
child
,
e
):
import
sys
trace
=
[
''
]
for
parent
,
attribute
,
index
in
self
.
access_path
:
node
=
getattr
(
parent
,
attribute
)
...
...
@@ -389,7 +386,7 @@ class EnvTransform(CythonTransform):
def
visit_CArgDeclNode
(
self
,
node
):
# default arguments are evaluated in the outer scope
if
node
.
default
:
attrs
=
[
attr
for
attr
in
node
.
child_attrs
if
attr
!=
'default'
]
attrs
=
[
attr
for
attr
in
node
.
child_attrs
if
attr
!=
'default'
]
self
.
visitchildren
(
node
,
attrs
)
self
.
enter_scope
(
node
,
self
.
current_env
().
outer_scope
)
self
.
visitchildren
(
node
,
(
'default'
,))
...
...
Cython/Shadow.py
View file @
a8af26e0
...
...
@@ -110,8 +110,8 @@ cclass = ccall = cfunc = _EmptyDecoratorAndManager()
returns
=
wraparound
=
boundscheck
=
initializedcheck
=
nonecheck
=
\
overflowcheck
=
embedsignature
=
cdivision
=
cdivision_warnings
=
\
always_allows_keywords
=
profile
=
linetrace
=
infer_type
=
\
type_version_tag
=
unraisable_tracebacks
=
freelist
=
\
lambda
arg
:
_EmptyDecoratorAndManager
()
unraisable_tracebacks
=
freelist
=
\
lambda
arg
:
_EmptyDecoratorAndManager
()
optimization
=
_Optimization
()
...
...
@@ -120,18 +120,21 @@ overflowcheck.fold = optimization.use_switch = \
final
=
internal
=
type_version_tag
=
no_gc_clear
=
_empty_decorator
def
inline
(
f
,
*
args
,
**
kwds
):
if
isinstance
(
f
,
basestring
):
from
Cython.Build.Inline
import
cython_inline
return
cython_inline
(
f
,
*
args
,
**
kwds
)
else
:
assert
len
(
args
)
==
len
(
kwds
)
==
0
return
f
if
isinstance
(
f
,
basestring
):
from
Cython.Build.Inline
import
cython_inline
return
cython_inline
(
f
,
*
args
,
**
kwds
)
else
:
assert
len
(
args
)
==
len
(
kwds
)
==
0
return
f
def
compile
(
f
):
from
Cython.Build.Inline
import
RuntimeCompiledFunction
return
RuntimeCompiledFunction
(
f
)
# Special functions
def
cdiv
(
a
,
b
):
...
...
Cython/__init__.py
View file @
a8af26e0
from
Cython.Shadow
import
__version__
from
__future__
import
absolute_import
from
.Shadow
import
__version__
# Void cython.* directives (for case insensitive operating systems).
from
Cython
.Shadow
import
*
from
.Shadow
import
*
def
load_ipython_extension
(
ip
):
"""Load the extension in IPython."""
from
Cython
.Build.IpythonMagic
import
CythonMagics
# pylint: disable=cyclic-import
from
.Build.IpythonMagic
import
CythonMagics
# pylint: disable=cyclic-import
ip
.
register_magics
(
CythonMagics
)
pylintrc
View file @
a8af26e0
...
...
@@ -103,7 +103,7 @@ function-rgx=[a-z_][a-z0-9_]{2,30}$
method-rgx=[a-z_][a-z0-9_]{2,30}|visit_[A-Za-z]+$
# Regular expression which should only match correct instance attribute names
attr-rgx=[a-z_][a-z0-9_]{2,30}$
attr-rgx=[a-z_][a-z0-9_]{2,30}
|sy
$
# Regular expression which should only match correct argument names
argument-rgx=[a-z_][a-z0-9_]{0,30}$
...
...
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