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
b820fbba
Commit
b820fbba
authored
Jan 06, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge 0.12 release.
parents
55bc639d
0b8b1fb9
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
253 additions
and
52 deletions
+253
-52
.hgtags
.hgtags
+2
-0
Cython/Compiler/CmdLine.py
Cython/Compiler/CmdLine.py
+1
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+43
-19
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+2
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+6
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+9
-6
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+4
-2
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+1
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+13
-1
Cython/Compiler/Version.py
Cython/Compiler/Version.py
+1
-1
runtests.py
runtests.py
+26
-13
setup.py
setup.py
+23
-3
setupegg.py
setupegg.py
+4
-0
tests/bugs.txt
tests/bugs.txt
+2
-1
tests/run/contains_T455.pyx
tests/run/contains_T455.pyx
+97
-0
tests/run/float_floor_division_T260.pyx
tests/run/float_floor_division_T260.pyx
+2
-2
tests/run/tp_new.pyx
tests/run/tp_new.pyx
+1
-1
tests/run/tp_new_T454.pyx
tests/run/tp_new_T454.pyx
+16
-0
No files found.
.hgtags
View file @
b820fbba
...
@@ -18,3 +18,5 @@ af6f1bed8cd40a2edefb57d3eacbc9274a8788b4 0.11.2.rc1
...
@@ -18,3 +18,5 @@ af6f1bed8cd40a2edefb57d3eacbc9274a8788b4 0.11.2.rc1
eb00d00a73c13b6aa8b440fe07cd7acb52a060e8 0.11.3.rc0
eb00d00a73c13b6aa8b440fe07cd7acb52a060e8 0.11.3.rc0
7c695fe49fd6912f52d995fe512d66baacf90ee6 0.11.3
7c695fe49fd6912f52d995fe512d66baacf90ee6 0.11.3
4208042ceeae634f5c0999b8ab75f69faf46b6db 0.12.alpha0
4208042ceeae634f5c0999b8ab75f69faf46b6db 0.12.alpha0
e77827f09af67560aa82a18feab778f71ca0a9d3 0.12.rc0
fae19937e4945c59a5d9d62c63f1c3b09046c3a3 0.12
Cython/Compiler/CmdLine.py
View file @
b820fbba
...
@@ -126,6 +126,7 @@ def parse_command_line(args):
...
@@ -126,6 +126,7 @@ def parse_command_line(args):
sys
.
stderr
.
write
(
"Error in compiler directive: %s
\
n
"
%
e
.
message
)
sys
.
stderr
.
write
(
"Error in compiler directive: %s
\
n
"
%
e
.
message
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
else
:
else
:
sys
.
stderr
.
write
(
"Unknown compiler flag: %s
\
n
"
%
option
)
bad_usage
()
bad_usage
()
else
:
else
:
arg
=
pop_arg
()
arg
=
pop_arg
()
...
...
Cython/Compiler/ExprNodes.py
View file @
b820fbba
...
@@ -3091,6 +3091,11 @@ class AttributeNode(ExprNode):
...
@@ -3091,6 +3091,11 @@ class AttributeNode(ExprNode):
rhs
.
py_result
()))
rhs
.
py_result
()))
rhs
.
generate_disposal_code
(
code
)
rhs
.
generate_disposal_code
(
code
)
rhs
.
free_temps
(
code
)
rhs
.
free_temps
(
code
)
elif
self
.
obj
.
type
.
is_complex
:
code
.
putln
(
"__Pyx_SET_C%s(%s, %s);"
%
(
self
.
member
.
upper
(),
self
.
obj
.
result_as
(
self
.
obj
.
type
),
rhs
.
result_as
(
self
.
ctype
())))
else
:
else
:
if
(
self
.
obj
.
type
.
is_extension_type
if
(
self
.
obj
.
type
.
is_extension_type
and
self
.
needs_none_check
and
self
.
needs_none_check
...
@@ -5317,9 +5322,16 @@ class CmpNode(object):
...
@@ -5317,9 +5322,16 @@ class CmpNode(object):
coerce_result
=
"__Pyx_PyBool_FromLong"
coerce_result
=
"__Pyx_PyBool_FromLong"
else
:
else
:
coerce_result
=
""
coerce_result
=
""
if
'not'
in
op
:
negation
=
"!"
if
'not'
in
op
:
else
:
negation
=
""
negation
=
"!"
else
:
negation
=
""
if
op
==
'in'
or
op
==
'not_in'
:
if
op
==
'in'
or
op
==
'not_in'
:
code
.
globalstate
.
use_utility_code
(
contians_utility_code
)
if
self
.
type
is
PyrexTypes
.
py_object_type
:
coerce_result
=
"__Pyx_PyBoolOrNull_FromLong"
if
op
==
'not_in'
:
negation
=
"__Pyx_NegateNonNeg"
if
operand2
.
type
is
dict_type
:
if
operand2
.
type
is
dict_type
:
code
.
globalstate
.
use_utility_code
(
code
.
globalstate
.
use_utility_code
(
raise_none_iter_error_utility_code
)
raise_none_iter_error_utility_code
)
...
@@ -5327,24 +5339,28 @@ class CmpNode(object):
...
@@ -5327,24 +5339,28 @@ class CmpNode(object):
code
.
putln
(
"__Pyx_RaiseNoneNotIterableError(); %s"
%
code
.
putln
(
"__Pyx_RaiseNoneNotIterableError(); %s"
%
code
.
error_goto
(
self
.
pos
))
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"} else {"
)
code
.
putln
(
"} else {"
)
code
.
putln
(
method
=
"PyDict_Contains"
"%s = %s(%sPyDict_Contains(%s, %s)); %s"
%
(
result_code
,
coerce_result
,
negation
,
operand2
.
py_result
(),
operand1
.
py_result
(),
code
.
error_goto_if_neg
(
result_code
,
self
.
pos
)))
code
.
putln
(
"}"
)
else
:
else
:
code
.
putln
(
method
=
"PySequence_Contains"
"%s = %s(%sPySequence_Contains(%s, %s)); %s"
%
(
if
self
.
type
is
PyrexTypes
.
py_object_type
:
result_code
,
error_clause
=
code
.
error_goto_if_null
coerce_result
,
got_ref
=
"__Pyx_XGOTREF(%s); "
%
result_code
negation
,
else
:
operand2
.
py_result
(),
error_clause
=
code
.
error_goto_if_neg
operand1
.
py_result
(),
got_ref
=
""
code
.
error_goto_if_neg
(
result_code
,
self
.
pos
)))
code
.
putln
(
"%s = %s(%s(%s(%s, %s))); %s%s"
%
(
result_code
,
coerce_result
,
negation
,
method
,
operand2
.
py_result
(),
operand1
.
py_result
(),
got_ref
,
error_clause
(
result_code
,
self
.
pos
)))
if
operand2
.
type
is
dict_type
:
code
.
putln
(
"}"
)
elif
(
operand1
.
type
.
is_pyobject
elif
(
operand1
.
type
.
is_pyobject
and
op
not
in
(
'is'
,
'is_not'
)):
and
op
not
in
(
'is'
,
'is_not'
)):
code
.
putln
(
"%s = PyObject_RichCompare(%s, %s, %s); %s"
%
(
code
.
putln
(
"%s = PyObject_RichCompare(%s, %s, %s); %s"
%
(
...
@@ -5393,6 +5409,14 @@ class CmpNode(object):
...
@@ -5393,6 +5409,14 @@ class CmpNode(object):
else
:
else
:
return
op
return
op
contians_utility_code
=
UtilityCode
(
proto
=
"""
static INLINE long __Pyx_NegateNonNeg(long b) { return unlikely(b < 0) ? b : !b; }
static INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
}
"""
)
class
PrimaryCmpNode
(
ExprNode
,
CmpNode
):
class
PrimaryCmpNode
(
ExprNode
,
CmpNode
):
# Non-cascaded comparison or first comparison of
# Non-cascaded comparison or first comparison of
...
...
Cython/Compiler/Main.py
View file @
b820fbba
...
@@ -743,6 +743,8 @@ def compile(source, options = None, c_compile = 0, c_link = 0,
...
@@ -743,6 +743,8 @@ def compile(source, options = None, c_compile = 0, c_link = 0,
# Main command-line entry point
# Main command-line entry point
#
#
#------------------------------------------------------------------------
#------------------------------------------------------------------------
def
setuptools_main
():
return
main
(
command_line
=
1
)
def
main
(
command_line
=
0
):
def
main
(
command_line
=
0
):
args
=
sys
.
argv
[
1
:]
args
=
sys
.
argv
[
1
:]
...
...
Cython/Compiler/ModuleNode.py
View file @
b820fbba
...
@@ -458,7 +458,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -458,7 +458,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
" #define PyVarObject_HEAD_INIT(type, size)
\
\
"
)
code
.
putln
(
" #define PyVarObject_HEAD_INIT(type, size)
\
\
"
)
code
.
putln
(
" PyObject_HEAD_INIT(type) size,"
)
code
.
putln
(
" PyObject_HEAD_INIT(type) size,"
)
code
.
putln
(
" #define PyType_Modified(t)"
)
code
.
putln
(
" #define PyType_Modified(t)"
)
code
.
putln
(
" #define PyBytes_CheckExact PyString_CheckExact"
)
code
.
putln
(
""
)
code
.
putln
(
""
)
code
.
putln
(
" typedef struct {"
)
code
.
putln
(
" typedef struct {"
)
code
.
putln
(
" void *buf;"
)
code
.
putln
(
" void *buf;"
)
...
@@ -501,6 +500,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -501,6 +500,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
" #define PyBaseString_Type PyUnicode_Type"
)
code
.
putln
(
" #define PyBaseString_Type PyUnicode_Type"
)
code
.
putln
(
" #define PyString_Type PyUnicode_Type"
)
code
.
putln
(
" #define PyString_Type PyUnicode_Type"
)
code
.
putln
(
" #define PyString_CheckExact PyUnicode_CheckExact"
)
code
.
putln
(
" #define PyString_CheckExact PyUnicode_CheckExact"
)
code
.
putln
(
"#else"
)
code
.
putln
(
" #define PyBytes_Type PyString_Type"
)
code
.
putln
(
" #define PyBytes_CheckExact PyString_CheckExact"
)
code
.
putln
(
"#endif"
)
code
.
putln
(
"#if PY_MAJOR_VERSION >= 3"
)
code
.
putln
(
" #define PyInt_Type PyLong_Type"
)
code
.
putln
(
" #define PyInt_Type PyLong_Type"
)
code
.
putln
(
" #define PyInt_Check(op) PyLong_Check(op)"
)
code
.
putln
(
" #define PyInt_Check(op) PyLong_Check(op)"
)
code
.
putln
(
" #define PyInt_CheckExact(op) PyLong_CheckExact(op)"
)
code
.
putln
(
" #define PyInt_CheckExact(op) PyLong_CheckExact(op)"
)
...
@@ -523,7 +528,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -523,7 +528,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
else
:
else
:
code
.
putln
(
" #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)"
)
code
.
putln
(
" #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)"
)
code
.
putln
(
" #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)"
)
code
.
putln
(
" #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)"
)
code
.
putln
(
" #define PyBytes_Type PyString_Type"
)
code
.
putln
(
"#endif"
)
code
.
putln
(
"#endif"
)
code
.
putln
(
"#if PY_MAJOR_VERSION >= 3"
)
code
.
putln
(
"#if PY_MAJOR_VERSION >= 3"
)
...
...
Cython/Compiler/Nodes.py
View file @
b820fbba
...
@@ -1104,10 +1104,10 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1104,10 +1104,10 @@ class FuncDefNode(StatNode, BlockNode):
env
.
use_utility_code
(
force_init_threads_utility_code
)
env
.
use_utility_code
(
force_init_threads_utility_code
)
code
.
putln
(
"PyGILState_STATE _save = PyGILState_Ensure();"
)
code
.
putln
(
"PyGILState_STATE _save = PyGILState_Ensure();"
)
# ----- Automatic lead-ins for certain special functions
# ----- Automatic lead-ins for certain special functions
if
profile
:
code
.
put_trace_call
(
self
.
entry
.
name
,
self
.
pos
)
if
not
lenv
.
nogil
:
if
not
lenv
.
nogil
:
code
.
put_setup_refcount_context
(
self
.
entry
.
name
)
code
.
put_setup_refcount_context
(
self
.
entry
.
name
)
if
profile
:
code
.
put_trace_call
(
self
.
entry
.
name
,
self
.
pos
)
if
is_getbuffer_slot
:
if
is_getbuffer_slot
:
self
.
getbuffer_init
(
code
)
self
.
getbuffer_init
(
code
)
# ----- Create closure scope object
# ----- Create closure scope object
...
@@ -1257,18 +1257,19 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1257,18 +1257,19 @@ class FuncDefNode(StatNode, BlockNode):
if
self
.
return_type
.
is_pyobject
:
if
self
.
return_type
.
is_pyobject
:
code
.
put_xgiveref
(
self
.
return_type
.
as_pyobject
(
Naming
.
retval_cname
))
code
.
put_xgiveref
(
self
.
return_type
.
as_pyobject
(
Naming
.
retval_cname
))
code
.
put_finish_refcount_context
()
if
self
.
entry
.
is_special
and
self
.
entry
.
name
==
"__hash__"
:
if
self
.
entry
.
is_special
and
self
.
entry
.
name
==
"__hash__"
:
# Returning -1 for __hash__ is supposed to signal an error
# Returning -1 for __hash__ is supposed to signal an error
# We do as Python instances and coerce -1 into -2.
# We do as Python instances and coerce -1 into -2.
code
.
putln
(
"if (unlikely(%s == -1) && !PyErr_Occurred()) %s = -2;"
%
(
Naming
.
retval_cname
,
Naming
.
retval_cname
))
code
.
putln
(
"if (unlikely(%s == -1) && !PyErr_Occurred()) %s = -2;"
%
(
Naming
.
retval_cname
,
Naming
.
retval_cname
))
if
profile
:
if
profile
:
if
self
.
return_type
.
is_pyobject
:
if
self
.
return_type
.
is_pyobject
:
code
.
put_trace_return
(
Naming
.
retval_cname
)
code
.
put_trace_return
(
Naming
.
retval_cname
)
else
:
else
:
code
.
put_trace_return
(
"Py_None"
)
code
.
put_trace_return
(
"Py_None"
)
if
not
lenv
.
nogil
:
code
.
put_finish_refcount_context
()
if
acquire_gil
:
if
acquire_gil
:
code
.
putln
(
"PyGILState_Release(_save);"
)
code
.
putln
(
"PyGILState_Release(_save);"
)
...
@@ -1424,6 +1425,7 @@ class CFuncDefNode(FuncDefNode):
...
@@ -1424,6 +1425,7 @@ class CFuncDefNode(FuncDefNode):
if
not
env
.
is_module_scope
or
Options
.
lookup_module_cpdef
:
if
not
env
.
is_module_scope
or
Options
.
lookup_module_cpdef
:
self
.
override
=
OverrideCheckNode
(
self
.
pos
,
py_func
=
self
.
py_func
)
self
.
override
=
OverrideCheckNode
(
self
.
pos
,
py_func
=
self
.
py_func
)
self
.
body
=
StatListNode
(
self
.
pos
,
stats
=
[
self
.
override
,
self
.
body
])
self
.
body
=
StatListNode
(
self
.
pos
,
stats
=
[
self
.
override
,
self
.
body
])
self
.
create_local_scope
(
env
)
def
call_self_node
(
self
,
omit_optional_args
=
0
,
is_module_scope
=
0
):
def
call_self_node
(
self
,
omit_optional_args
=
0
,
is_module_scope
=
0
):
import
ExprNodes
import
ExprNodes
...
@@ -1756,6 +1758,7 @@ class DefNode(FuncDefNode):
...
@@ -1756,6 +1758,7 @@ class DefNode(FuncDefNode):
self
.
declare_pyfunction
(
env
)
self
.
declare_pyfunction
(
env
)
self
.
analyse_signature
(
env
)
self
.
analyse_signature
(
env
)
self
.
return_type
=
self
.
entry
.
signature
.
return_type
()
self
.
return_type
=
self
.
entry
.
signature
.
return_type
()
self
.
create_local_scope
(
env
)
def
analyse_signature
(
self
,
env
):
def
analyse_signature
(
self
,
env
):
any_type_tests_needed
=
0
any_type_tests_needed
=
0
...
@@ -5115,7 +5118,7 @@ raise_error:
...
@@ -5115,7 +5118,7 @@ raise_error:
return;
return;
}
}
#else /
/ Python 3+
#else /
* Python 3+ */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
if (tb == Py_None) {
if (tb == Py_None) {
...
...
Cython/Compiler/Optimize.py
View file @
b820fbba
...
@@ -1068,8 +1068,10 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
...
@@ -1068,8 +1068,10 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
# different types - may or may not lead to an error at runtime
# different types - may or may not lead to an error at runtime
return
node
return
node
# FIXME: we could potentially look up the actual tp_new C method
# FIXME: we could potentially look up the actual tp_new C
# of the extension type and call that instead of the generic slot
# method of the extension type and call that instead of the
# generic slot. That would also allow us to pass parameters
# efficiently.
if
not
type_arg
.
type_entry
:
if
not
type_arg
.
type_entry
:
# arbitrary variable, needs a None check for safety
# arbitrary variable, needs a None check for safety
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
b820fbba
...
@@ -733,7 +733,7 @@ property NAME:
...
@@ -733,7 +733,7 @@ property NAME:
def
visit_FuncDefNode
(
self
,
node
):
def
visit_FuncDefNode
(
self
,
node
):
self
.
seen_vars_stack
.
append
(
set
())
self
.
seen_vars_stack
.
append
(
set
())
lenv
=
node
.
create_local_scope
(
self
.
env_stack
[
-
1
])
lenv
=
node
.
local_scope
node
.
body
.
analyse_control_flow
(
lenv
)
# this will be totally refactored
node
.
body
.
analyse_control_flow
(
lenv
)
# this will be totally refactored
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
():
...
...
Cython/Compiler/PyrexTypes.py
View file @
b820fbba
...
@@ -202,7 +202,11 @@ class CTypedefType(BaseType):
...
@@ -202,7 +202,11 @@ class CTypedefType(BaseType):
def
declaration_code
(
self
,
entity_code
,
def
declaration_code
(
self
,
entity_code
,
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
name
=
self
.
declaration_name
(
for_display
,
pyrex
)
name
=
self
.
declaration_name
(
for_display
,
pyrex
)
return
self
.
base_declaration_code
(
name
,
entity_code
)
if
pyrex
or
for_display
:
base_code
=
name
else
:
base_code
=
public_decl
(
name
,
dll_linkage
)
return
self
.
base_declaration_code
(
base_code
,
entity_code
)
def
declaration_name
(
self
,
for_display
=
0
,
pyrex
=
0
):
def
declaration_name
(
self
,
for_display
=
0
,
pyrex
=
0
):
if
pyrex
or
for_display
:
if
pyrex
or
for_display
:
...
@@ -1053,6 +1057,14 @@ proto="""
...
@@ -1053,6 +1057,14 @@ proto="""
#define __Pyx_CREAL(z) ((z).real)
#define __Pyx_CREAL(z) ((z).real)
#define __Pyx_CIMAG(z) ((z).imag)
#define __Pyx_CIMAG(z) ((z).imag)
#endif
#endif
#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX
#define __Pyx_SET_CREAL(z,x) ((z).real(x))
#define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
#define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
#define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif
"""
)
"""
)
complex_type_utility_code
=
UtilityCode
(
complex_type_utility_code
=
UtilityCode
(
...
...
Cython/Compiler/Version.py
View file @
b820fbba
version
=
'0.12
.alpha0
'
version
=
'0.12'
runtests.py
View file @
b820fbba
...
@@ -9,6 +9,7 @@ import shutil
...
@@ -9,6 +9,7 @@ import shutil
import
unittest
import
unittest
import
doctest
import
doctest
import
operator
import
operator
import
tempfile
try
:
try
:
from
StringIO
import
StringIO
from
StringIO
import
StringIO
except
ImportError
:
except
ImportError
:
...
@@ -401,12 +402,12 @@ class CythonRunTestCase(CythonCompileTestCase):
...
@@ -401,12 +402,12 @@ class CythonRunTestCase(CythonCompileTestCase):
return
return
# fork to make sure we do not keep the tested module loaded
# fork to make sure we do not keep the tested module loaded
input
,
output
=
os
.
pipe
()
result_handle
,
result_file
=
tempfile
.
mkstemp
()
child_id
=
os
.
fork
()
child_id
=
os
.
fork
()
if
not
child_id
:
if
not
child_id
:
result_code
=
0
result_code
=
0
try
:
try
:
output
=
os
.
fdopen
(
output
,
'wb'
)
output
=
os
.
fdopen
(
result_handle
,
'wb'
)
tests
=
None
tests
=
None
try
:
try
:
partial_result
=
PartialTestResult
(
result
)
partial_result
=
PartialTestResult
(
result
)
...
@@ -423,29 +424,38 @@ class CythonRunTestCase(CythonCompileTestCase):
...
@@ -423,29 +424,38 @@ class CythonRunTestCase(CythonCompileTestCase):
partial_result
.
addError
(
tests
,
sys
.
exc_info
())
partial_result
.
addError
(
tests
,
sys
.
exc_info
())
result_code
=
1
result_code
=
1
pickle
.
dump
(
partial_result
.
data
(),
output
)
pickle
.
dump
(
partial_result
.
data
(),
output
)
except
:
import
traceback
traceback
.
print_exc
()
finally
:
finally
:
try
:
output
.
close
()
try
:
output
.
close
()
except
:
pass
except
:
pass
os
.
_exit
(
result_code
)
os
.
_exit
(
result_code
)
cid
,
result_code
=
os
.
waitpid
(
child_id
,
0
)
try
:
if
result_code
in
(
0
,
1
):
cid
,
result_code
=
os
.
waitpid
(
child_id
,
0
)
input
=
os
.
fdopen
(
input
,
'rb'
)
if
result_code
in
(
0
,
1
):
try
:
input
=
open
(
result_file
,
'rb'
)
PartialTestResult
.
join_results
(
result
,
pickle
.
load
(
input
))
try
:
finally
:
PartialTestResult
.
join_results
(
result
,
pickle
.
load
(
input
))
input
.
close
()
finally
:
if
result_code
:
input
.
close
()
raise
Exception
(
"Tests in module '%s' exited with status %d"
%
if
result_code
:
(
module_name
,
result_code
>>
8
))
raise
Exception
(
"Tests in module '%s' exited with status %d"
%
(
module_name
,
result_code
>>
8
))
finally
:
try
:
os
.
unlink
(
result_file
)
except
:
pass
is_private_field
=
re
.
compile
(
'^_[^_]'
).
match
is_private_field
=
re
.
compile
(
'^_[^_]'
).
match
class
_FakeClass
(
object
):
class
_FakeClass
(
object
):
def
__init__
(
self
,
**
kwargs
):
def
__init__
(
self
,
**
kwargs
):
self
.
shortDescription
=
lambda
x
:
kwargs
.
get
(
'module_name'
)
self
.
_shortDescription
=
kwargs
.
get
(
'module_name'
)
self
.
__dict__
.
update
(
kwargs
)
self
.
__dict__
.
update
(
kwargs
)
def
shortDescription
(
self
):
return
self
.
_shortDescription
try
:
# Py2.7+ and Py3.2+
try
:
# Py2.7+ and Py3.2+
from
unittest.runner
import
_TextTestResult
from
unittest.runner
import
_TextTestResult
...
@@ -809,6 +819,9 @@ if __name__ == '__main__':
...
@@ -809,6 +819,9 @@ if __name__ == '__main__':
if
not
test_bugs
:
if
not
test_bugs
:
exclude_selectors
+=
[
FileListExcluder
(
"tests/bugs.txt"
)
]
exclude_selectors
+=
[
FileListExcluder
(
"tests/bugs.txt"
)
]
if
sys
.
platform
in
[
'win32'
,
'cygwin'
]
and
sys
.
version_info
<
(
2
,
6
):
exclude_selectors
+=
[
lambda
x
:
x
==
"run.specialfloat"
]
languages
=
[]
languages
=
[]
if
options
.
use_c
:
if
options
.
use_c
:
...
...
setup.py
View file @
b820fbba
...
@@ -7,6 +7,11 @@ compiler_dir = os.path.join(get_python_lib(prefix=''), 'Cython/Compiler')
...
@@ -7,6 +7,11 @@ compiler_dir = os.path.join(get_python_lib(prefix=''), 'Cython/Compiler')
if
sys
.
platform
==
"win32"
:
if
sys
.
platform
==
"win32"
:
compiler_dir
=
compiler_dir
[
len
(
sys
.
prefix
)
+
1
:]
compiler_dir
=
compiler_dir
[
len
(
sys
.
prefix
)
+
1
:]
if
sys
.
platform
==
"darwin"
:
# Don't create resource files on OS X tar.
os
.
environ
[
'COPY_EXTENDED_ATTRIBUTES_DISABLE'
]
=
'true'
os
.
environ
[
'COPYFILE_DISABLE'
]
=
'true'
setup_args
=
{}
setup_args
=
{}
if
sys
.
version_info
[
0
]
>=
3
:
if
sys
.
version_info
[
0
]
>=
3
:
...
@@ -40,10 +45,24 @@ else:
...
@@ -40,10 +45,24 @@ else:
'Compiler/*.pxd'
,
'Compiler/*.pxd'
,
'Runtime/*.pyx'
]}
'Runtime/*.pyx'
]}
if
os
.
name
==
"posix"
:
# This dict is used for passing extra arguments that are setuptools
scripts
=
[
"bin/cython"
]
# specific to setup
setuptools_extra_args
=
{}
if
'setuptools'
in
sys
.
modules
:
setuptools_extra_args
[
'zip_safe'
]
=
False
setuptools_extra_args
[
'entry_points'
]
=
{
'console_scripts'
:
[
'cython = Cython.Compiler.Main:setuptools_main'
,
]
}
scripts
=
[]
else
:
else
:
scripts
=
[
"cython.py"
]
if
os
.
name
==
"posix"
:
scripts
=
[
"bin/cython"
]
else
:
scripts
=
[
"cython.py"
]
try
:
try
:
if
sys
.
version_info
[
0
]
>=
3
:
if
sys
.
version_info
[
0
]
>=
3
:
...
@@ -93,6 +112,7 @@ except ValueError:
...
@@ -93,6 +112,7 @@ except ValueError:
print
(
"ERROR: %s"
%
sys
.
exc_info
()[
1
])
print
(
"ERROR: %s"
%
sys
.
exc_info
()[
1
])
print
(
"Extension module compilation failed, using plain Python implementation"
)
print
(
"Extension module compilation failed, using plain Python implementation"
)
setup_args
.
update
(
setuptools_extra_args
)
from
Cython.Compiler.Version
import
version
from
Cython.Compiler.Version
import
version
...
...
setupegg.py
0 → 100644
View file @
b820fbba
#!/usr/bin/env python
"""Wrapper to run setup.py using setuptools."""
import
setuptools
execfile
(
'setup.py'
)
tests/bugs.txt
View file @
b820fbba
# This file contains tests corresponding to
of
unresolved bugs,
# This file contains tests corresponding to unresolved bugs,
# which will be skipped in the normal testing run.
# which will be skipped in the normal testing run.
methodmangling_T5
methodmangling_T5
...
@@ -6,3 +6,4 @@ class_attribute_init_values_T18
...
@@ -6,3 +6,4 @@ class_attribute_init_values_T18
numpy_ValueError_T172
numpy_ValueError_T172
unsignedbehaviour_T184
unsignedbehaviour_T184
missing_baseclass_in_predecl_T262
missing_baseclass_in_predecl_T262
tp_new_T454
tests/run/contains_T455.pyx
0 → 100644
View file @
b820fbba
def
in_sequence
(
x
,
seq
):
"""
>>> in_sequence(1, [])
False
>>> in_sequence(1, ())
False
>>> in_sequence(1, {})
False
>>> in_sequence(1, [1])
True
>>> in_sequence(1, (1,))
True
>>> in_sequence(1, {1:None})
True
>>> in_sequence(1, None)
Traceback (most recent call last):
...
TypeError: argument of type 'NoneType' is not iterable
>>> in_sequence(1, 1)
Traceback (most recent call last):
...
TypeError: argument of type 'int' is not iterable
"""
return
x
in
seq
def
not_in_sequence
(
x
,
seq
):
"""
>>> not_in_sequence(1, [])
True
>>> not_in_sequence(1, ())
True
>>> not_in_sequence(1, {})
True
>>> not_in_sequence(1, [1])
False
>>> not_in_sequence(1, (1,))
False
>>> not_in_sequence(1, {1:None})
False
>>> not_in_sequence(1, None)
Traceback (most recent call last):
...
TypeError: argument of type 'NoneType' is not iterable
>>> not_in_sequence(1, 1)
Traceback (most recent call last):
...
TypeError: argument of type 'int' is not iterable
"""
return
x
not
in
seq
def
in_dict
(
k
,
dict
dct
):
"""
>>> in_dict(1, {})
False
>>> in_dict(1, {1:None})
True
>>> in_dict(1, None)
Traceback (most recent call last):
...
TypeError: 'NoneType' object is not iterable
"""
return
k
in
dct
def
not_in_dict
(
k
,
dict
dct
):
"""
>>> not_in_dict(1, {})
True
>>> not_in_dict(1, {1:None})
False
>>> not_in_dict(1, None)
Traceback (most recent call last):
...
TypeError: 'NoneType' object is not iterable
"""
return
k
not
in
dct
def
cascaded
(
a
,
b
,
c
):
"""
>>> cascaded(1, 2, 3)
Traceback (most recent call last):
...
TypeError: argument of type 'int' is not iterable
>>> cascaded(-1, (1,2), (1,3))
True
>>> cascaded(1, (1,2), (1,3))
False
>>> cascaded(-1, (1,2), (1,0))
False
"""
return
a
not
in
b
<
c
tests/run/float_floor_division_T260.pyx
View file @
b820fbba
...
@@ -6,7 +6,7 @@ def floor_div_float(double a, double b):
...
@@ -6,7 +6,7 @@ def floor_div_float(double a, double b):
-2.0
-2.0
>>> floor_div_float(-2.3, 1.5)
>>> floor_div_float(-2.3, 1.5)
-2.0
-2.0
>>> floor_div_float(1e10, 1e-10)
>>> floor_div_float(1e10, 1e-10)
== 1e20
1e+20
True
"""
"""
return
a
//
b
return
a
//
b
tests/run/tp_new.pyx
View file @
b820fbba
...
@@ -26,7 +26,7 @@ class MyTypeSubClass(MyType):
...
@@ -26,7 +26,7 @@ class MyTypeSubClass(MyType):
def
__init__
(
self
):
def
__init__
(
self
):
print
"INIT"
print
"INIT"
# only th
is
can be safely optimised:
# only th
ese
can be safely optimised:
@
cython
.
test_assert_path_exists
(
'//PythonCapiCallNode'
)
@
cython
.
test_assert_path_exists
(
'//PythonCapiCallNode'
)
@
cython
.
test_fail_if_path_exists
(
'//SimpleCallNode/AttributeNode'
)
@
cython
.
test_fail_if_path_exists
(
'//SimpleCallNode/AttributeNode'
)
...
...
tests/run/tp_new_T454.pyx
0 → 100644
View file @
b820fbba
cimport
cython
cdef
class
TypeWithFactory
:
@
cython
.
test_assert_path_exists
(
'//PythonCapiCallNode'
)
@
cython
.
test_fail_if_path_exists
(
'//SimpleCallNode/AttributeNode'
)
@
classmethod
def
new
(
cls
):
return
cls
.
__new__
(
cls
)
def
make_new_factory
():
"""
>>> isinstance(make_new_factory(), TypeWithFactory)
True
"""
return
TypeWithFactory
.
new
()
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