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
12c5182c
Commit
12c5182c
authored
Feb 25, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
cf1d7075
143f91e2
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
74 additions
and
47 deletions
+74
-47
Cython/Compiler/Annotate.py
Cython/Compiler/Annotate.py
+1
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+8
-5
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+10
-2
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+26
-30
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-0
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+1
-1
Cython/Includes/libc/locale.pxd
Cython/Includes/libc/locale.pxd
+1
-1
Cython/Includes/libc/math.pxd
Cython/Includes/libc/math.pxd
+1
-1
Makefile
Makefile
+4
-1
README.txt
README.txt
+3
-3
tests/bugs.txt
tests/bugs.txt
+0
-1
tests/run/ipow_crash_T562.pyx
tests/run/ipow_crash_T562.pyx
+17
-2
No files found.
Cython/Compiler/Annotate.py
View file @
12c5182c
...
@@ -86,6 +86,7 @@ class AnnotationCCodeWriter(CCodeWriter):
...
@@ -86,6 +86,7 @@ class AnnotationCCodeWriter(CCodeWriter):
html_filename
=
os
.
path
.
splitext
(
target_filename
)[
0
]
+
".html"
html_filename
=
os
.
path
.
splitext
(
target_filename
)[
0
]
+
".html"
f
=
codecs
.
open
(
html_filename
,
"w"
,
encoding
=
"UTF-8"
)
f
=
codecs
.
open
(
html_filename
,
"w"
,
encoding
=
"UTF-8"
)
f
.
write
(
u'<!-- Generated by Cython %s on %s -->
\
n
'
%
(
Version
.
version
,
time
.
asctime
()))
f
.
write
(
u'<html>
\
n
'
)
f
.
write
(
u'<html>
\
n
'
)
f
.
write
(
u"""
f
.
write
(
u"""
<head>
<head>
...
...
Cython/Compiler/ExprNodes.py
View file @
12c5182c
...
@@ -368,7 +368,7 @@ class ExprNode(Node):
...
@@ -368,7 +368,7 @@ class ExprNode(Node):
def
nonlocally_immutable
(
self
):
def
nonlocally_immutable
(
self
):
# Returns whether this variable is a safe reference, i.e.
# Returns whether this variable is a safe reference, i.e.
# can't be modified as part of globals or closures.
# can't be modified as part of globals or closures.
return
self
.
is_temp
return
self
.
is_temp
or
self
.
type
.
is_array
or
self
.
type
.
is_cfunction
# --------------- Type Analysis ------------------
# --------------- Type Analysis ------------------
...
@@ -1477,6 +1477,8 @@ class NameNode(AtomicExprNode):
...
@@ -1477,6 +1477,8 @@ class NameNode(AtomicExprNode):
return
1
return
1
def
nonlocally_immutable
(
self
):
def
nonlocally_immutable
(
self
):
if
ExprNode
.
nonlocally_immutable
(
self
):
return
True
entry
=
self
.
entry
entry
=
self
.
entry
return
entry
and
(
entry
.
is_local
or
entry
.
is_arg
)
and
not
entry
.
in_closure
return
entry
and
(
entry
.
is_local
or
entry
.
is_arg
)
and
not
entry
.
in_closure
...
@@ -3038,10 +3040,11 @@ class SimpleCallNode(CallNode):
...
@@ -3038,10 +3040,11 @@ class SimpleCallNode(CallNode):
if
i
==
0
and
self
.
self
is
not
None
:
if
i
==
0
and
self
.
self
is
not
None
:
continue
# self is ok
continue
# self is ok
arg
=
self
.
args
[
i
]
arg
=
self
.
args
[
i
]
if
arg
.
is_name
and
arg
.
entry
and
(
if
arg
.
nonlocally_immutable
():
(
arg
.
entry
.
is_local
and
not
arg
.
entry
.
in_closure
)
# locals, C functions, unassignable types are safe.
or
arg
.
entry
.
type
.
is_cfunction
):
pass
# local variables and C functions are safe
elif
arg
.
type
.
is_cpp_class
:
# Assignment has side effects, avoid.
pass
pass
elif
env
.
nogil
and
arg
.
type
.
is_pyobject
:
elif
env
.
nogil
and
arg
.
type
.
is_pyobject
:
# can't copy a Python reference into a temp in nogil
# can't copy a Python reference into a temp in nogil
...
...
Cython/Compiler/Main.py
View file @
12c5182c
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# Cython Top Level
# Cython Top Level
#
#
import
os
,
sys
,
re
import
os
,
sys
,
re
,
codecs
if
sys
.
version_info
[:
2
]
<
(
2
,
3
):
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
)
...
@@ -607,6 +607,14 @@ def run_pipeline(source, options, full_module_name = None):
...
@@ -607,6 +607,14 @@ def run_pipeline(source, options, full_module_name = None):
# Set up result object
# Set up result object
result
=
create_default_resultobj
(
source
,
options
)
result
=
create_default_resultobj
(
source
,
options
)
if
options
.
annotate
is
None
:
# By default, decide based on whether an html file already exists.
html_filename
=
os
.
path
.
splitext
(
result
.
c_file
)[
0
]
+
".html"
if
os
.
path
.
exists
(
html_filename
):
line
=
codecs
.
open
(
html_filename
,
"r"
,
encoding
=
"UTF-8"
).
readline
()
if
line
.
startswith
(
u'<!-- Generated by Cython'
):
options
.
annotate
=
True
# Get pipeline
# Get pipeline
if
source_ext
.
lower
()
==
'.py'
:
if
source_ext
.
lower
()
==
'.py'
:
pipeline
=
context
.
create_py_pipeline
(
options
,
result
)
pipeline
=
context
.
create_py_pipeline
(
options
,
result
)
...
@@ -826,7 +834,7 @@ default_options = dict(
...
@@ -826,7 +834,7 @@ default_options = dict(
errors_to_stderr
=
1
,
errors_to_stderr
=
1
,
cplus
=
0
,
cplus
=
0
,
output_file
=
None
,
output_file
=
None
,
annotate
=
Fals
e
,
annotate
=
Non
e
,
generate_pxi
=
0
,
generate_pxi
=
0
,
working_path
=
""
,
working_path
=
""
,
recursive
=
0
,
recursive
=
0
,
...
...
Cython/Compiler/ModuleNode.py
View file @
12c5182c
...
@@ -2664,8 +2664,6 @@ int %(wmain_method)s(int argc, wchar_t **argv) {
...
@@ -2664,8 +2664,6 @@ int %(wmain_method)s(int argc, wchar_t **argv) {
#else
#else
static int __Pyx_main(int argc, wchar_t **argv) {
static int __Pyx_main(int argc, wchar_t **argv) {
#endif
#endif
int r = 0;
PyObject* m = NULL;
/* 754 requires that FP exceptions run in "no stop" mode by default,
/* 754 requires that FP exceptions run in "no stop" mode by default,
* and until C vendors implement C99's ways to control FP exceptions,
* and until C vendors implement C99's ways to control FP exceptions,
* Python requires non-stop mode. Alas, some platforms enable FP
* Python requires non-stop mode. Alas, some platforms enable FP
...
@@ -2677,29 +2675,30 @@ static int __Pyx_main(int argc, wchar_t **argv) {
...
@@ -2677,29 +2675,30 @@ static int __Pyx_main(int argc, wchar_t **argv) {
m = fpgetmask();
m = fpgetmask();
fpsetmask(m & ~FP_X_OFL);
fpsetmask(m & ~FP_X_OFL);
#endif
#endif
if (argc
) {
if (argc
&& argv)
Py_SetProgramName(argv[0]);
Py_SetProgramName(argv[0]);
}
Py_Initialize();
Py_Initialize();
if (argc
) {
if (argc
&& argv)
PySys_SetArgv(argc, argv);
PySys_SetArgv(argc, argv);
}
{ /* init module '%(module_name)s' as '__main__' */
PyObject* m = NULL;
%(module_is_main)s = 1;
%(module_is_main)s = 1;
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
init%(module_name)s();
init%(module_name)s();
#else
#else
m = PyInit_%(module_name)s();
m = PyInit_%(module_name)s();
#endif
#endif
if (PyErr_Occurred() != NULL) {
if (PyErr_Occurred()) {
r = 1;
PyErr_Print(); /* This exits with the right code if SystemExit. */
PyErr_Print(); /* This exits with the right code if SystemExit. */
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
if (Py_FlushLine()) PyErr_Clear();
if (Py_FlushLine()) PyErr_Clear();
#endif
#endif
return 1;
}
}
Py_XDECREF(m);
Py_XDECREF(m);
}
Py_Finalize();
Py_Finalize();
return
r
;
return
0
;
}
}
...
@@ -2858,18 +2857,15 @@ check_binary_version_utility_code = UtilityCode(proto="""
...
@@ -2858,18 +2857,15 @@ check_binary_version_utility_code = UtilityCode(proto="""
static int __Pyx_check_binary_version(void);
static int __Pyx_check_binary_version(void);
"""
,
impl
=
"""
"""
,
impl
=
"""
static int __Pyx_check_binary_version(void) {
static int __Pyx_check_binary_version(void) {
long version_hex, major_version, minor_version;
char ctversion[4], rtversion[4];
PyObject *sys_hexversion = PySys_GetObject((char*)"hexversion");
PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
if (sys_hexversion == NULL) return -1;
PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
version_hex = PyInt_AsLong(sys_hexversion);
if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
if (version_hex == -1 && PyErr_Occurred()) return -1;
major_version = ((unsigned long)version_hex >> 24);
minor_version = ((unsigned long)version_hex >> 16) & 0x00FF;
if (!(major_version == PY_MAJOR_VERSION && minor_version == PY_MINOR_VERSION)) {
char message[200];
char message[200];
PyOS_snprintf(message, sizeof(message),
PyOS_snprintf(message, sizeof(message),
"compiletime version (%d, %d) of module '%.100s' does not match runtime version (%d, %d).",
"compiletime version %s of module '%.100s' "
PY_MAJOR_VERSION, PY_MINOR_VERSION, __Pyx_MODULE_NAME, (int)major_version, (int)minor_version);
"does not match runtime version %s",
ctversion, __Pyx_MODULE_NAME, rtversion);
#if PY_VERSION_HEX < 0x02050000
#if PY_VERSION_HEX < 0x02050000
return PyErr_Warn(NULL, message);
return PyErr_Warn(NULL, message);
#else
#else
...
...
Cython/Compiler/Nodes.py
View file @
12c5182c
...
@@ -2278,6 +2278,8 @@ class DefNode(FuncDefNode):
...
@@ -2278,6 +2278,8 @@ class DefNode(FuncDefNode):
arg
.
hdr_type
.
declaration_code
(
arg
.
hdr_cname
))
arg
.
hdr_type
.
declaration_code
(
arg
.
hdr_cname
))
if
not
self
.
entry
.
is_special
and
sig
.
method_flags
()
==
[
TypeSlots
.
method_noargs
]:
if
not
self
.
entry
.
is_special
and
sig
.
method_flags
()
==
[
TypeSlots
.
method_noargs
]:
arg_code_list
.
append
(
"CYTHON_UNUSED PyObject *unused"
)
arg_code_list
.
append
(
"CYTHON_UNUSED PyObject *unused"
)
if
(
self
.
entry
.
scope
.
is_c_class_scope
and
self
.
entry
.
name
==
"__ipow__"
):
arg_code_list
.
append
(
"CYTHON_UNUSED PyObject *unused"
)
if
sig
.
has_generic_args
:
if
sig
.
has_generic_args
:
arg_code_list
.
append
(
arg_code_list
.
append
(
"PyObject *%s, PyObject *%s"
"PyObject *%s, PyObject *%s"
...
...
Cython/Compiler/TypeSlots.py
View file @
12c5182c
...
@@ -603,7 +603,7 @@ PyNumberMethods = (
...
@@ -603,7 +603,7 @@ PyNumberMethods = (
MethodSlot
(
ibinaryfunc
,
"nb_inplace_multiply"
,
"__imul__"
),
MethodSlot
(
ibinaryfunc
,
"nb_inplace_multiply"
,
"__imul__"
),
MethodSlot
(
ibinaryfunc
,
"nb_inplace_divide"
,
"__idiv__"
,
py3
=
False
),
MethodSlot
(
ibinaryfunc
,
"nb_inplace_divide"
,
"__idiv__"
,
py3
=
False
),
MethodSlot
(
ibinaryfunc
,
"nb_inplace_remainder"
,
"__imod__"
),
MethodSlot
(
ibinaryfunc
,
"nb_inplace_remainder"
,
"__imod__"
),
MethodSlot
(
ternaryfunc
,
"nb_inplace_power"
,
"__ipow__"
),
# NOT i
ternaryfunc!!!
MethodSlot
(
ibinaryfunc
,
"nb_inplace_power"
,
"__ipow__"
),
# actually
ternaryfunc!!!
MethodSlot
(
ibinaryfunc
,
"nb_inplace_lshift"
,
"__ilshift__"
),
MethodSlot
(
ibinaryfunc
,
"nb_inplace_lshift"
,
"__ilshift__"
),
MethodSlot
(
ibinaryfunc
,
"nb_inplace_rshift"
,
"__irshift__"
),
MethodSlot
(
ibinaryfunc
,
"nb_inplace_rshift"
,
"__irshift__"
),
MethodSlot
(
ibinaryfunc
,
"nb_inplace_and"
,
"__iand__"
),
MethodSlot
(
ibinaryfunc
,
"nb_inplace_and"
,
"__iand__"
),
...
...
Cython/Includes/libc/locale.pxd
View file @
12c5182c
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
cdef
extern
from
*
:
cdef
extern
from
*
:
ctypedef
char
const_char
"const char"
ctypedef
char
const_char
"const char"
cdef
extern
from
"locale.h"
:
cdef
extern
from
"locale.h"
nogil
:
struct
lconv
:
struct
lconv
:
char
*
decimal_point
char
*
decimal_point
...
...
Cython/Includes/libc/math.pxd
View file @
12c5182c
cdef
extern
from
"math.h"
:
cdef
extern
from
"math.h"
nogil
:
enum
:
M_E
enum
:
M_E
enum
:
M_LOG2E
enum
:
M_LOG2E
...
...
Makefile
View file @
12c5182c
...
@@ -9,9 +9,12 @@ local:
...
@@ -9,9 +9,12 @@ local:
.git
:
REV := $(shell cat .gitrev)
.git
:
REV := $(shell cat .gitrev)
.git
:
TMPDIR := $(shell mktemp -d tmprepo.XXXXXX)
.git
:
TMPDIR := $(shell mktemp -d tmprepo.XXXXXX)
.git
:
.git
:
rm
-rf
$(TMPDIR)
git clone
$(REPO)
$(TMPDIR)
git clone
$(REPO)
$(TMPDIR)
cd
$(TMPDIR)
;
git checkout
-b
working
$(REV)
cd
$(TMPDIR)
;
git checkout
-b
working
$(REV)
mv
$(TMPDIR)
/
{
.git,.hgtags,.hgignore
}
.
mv
$(TMPDIR)
/.hgtags .
mv
$(TMPDIR)
/.hgignore .
mv
$(TMPDIR)
/.git .
mv
$(TMPDIR)
/Doc/s5 Doc/s5
mv
$(TMPDIR)
/Doc/s5 Doc/s5
rm
-rf
$(TMPDIR)
rm
-rf
$(TMPDIR)
...
...
README.txt
View file @
12c5182c
...
@@ -26,16 +26,16 @@ See LICENSE.txt.
...
@@ -26,16 +26,16 @@ See LICENSE.txt.
--------------------------
--------------------------
Note that Cython used to ship the
Mercurial (hg)
repository in its source
Note that Cython used to ship the
full version control
repository in its source
distribution, but no longer does so due to space constraints. To get the
distribution, but no longer does so due to space constraints. To get the
full source history, make sure you have
hg
installed, then step into the
full source history, make sure you have
git
installed, then step into the
base directory of the Cython source distribution and type
base directory of the Cython source distribution and type
make repo
make repo
Alternatively, check out the latest developer repository from
Alternatively, check out the latest developer repository from
http
://hg.cython.org/cython-devel
http
s://github.com/cython/cython
...
...
tests/bugs.txt
View file @
12c5182c
...
@@ -14,7 +14,6 @@ genexpr_T491
...
@@ -14,7 +14,6 @@ genexpr_T491
with_statement_module_level_T536
with_statement_module_level_T536
function_as_method_T494
function_as_method_T494
closure_inside_cdef_T554
closure_inside_cdef_T554
ipow_crash_T562
pure_mode_cmethod_inheritance_T583
pure_mode_cmethod_inheritance_T583
genexpr_iterable_lookup_T600
genexpr_iterable_lookup_T600
for_from_pyvar_loop_T601
for_from_pyvar_loop_T601
...
...
tests/run/ipow_crash_T562.pyx
View file @
12c5182c
class
IPOW
:
"""
>>> IPOW().__ipow__('a')
a
>>> x = IPOW()
>>> x **= 'z'
z
"""
def
__ipow__
(
self
,
other
):
print
(
"%s"
%
other
)
cdef
class
CrashIPOW
:
cdef
class
CrashIPOW
:
"""
"""
>>> CrashIPOW().__ipow__('a')
>>> CrashIPOW().__ipow__('a')
a
>>> x = CrashIPOW()
>>> x **= 'z'
z
"""
"""
def
__ipow__
(
self
,
other
,
mod
):
def
__ipow__
(
self
,
other
):
print
"%s, %s"
%
(
other
,
mod
)
print
(
"%s"
%
other
)
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