Commit 12c5182c authored by Stefan Behnel's avatar Stefan Behnel

merge

parents cf1d7075 143f91e2
...@@ -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>
......
...@@ -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
......
...@@ -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 = False, annotate = None,
generate_pxi = 0, generate_pxi = 0,
working_path = "", working_path = "",
recursive = 0, recursive = 0,
......
...@@ -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
......
...@@ -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"
......
...@@ -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 iternaryfunc!!! 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__"),
......
...@@ -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
......
cdef extern from "math.h": cdef extern from "math.h" nogil:
enum: M_E enum: M_E
enum: M_LOG2E enum: M_LOG2E
......
...@@ -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)
......
...@@ -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 https://github.com/cython/cython
......
...@@ -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
......
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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment