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

merge

parents cf1d7075 143f91e2
......@@ -86,6 +86,7 @@ class AnnotationCCodeWriter(CCodeWriter):
html_filename = os.path.splitext(target_filename)[0] + ".html"
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"""
<head>
......
......@@ -368,7 +368,7 @@ class ExprNode(Node):
def nonlocally_immutable(self):
# Returns whether this variable is a safe reference, i.e.
# 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 ------------------
......@@ -1477,6 +1477,8 @@ class NameNode(AtomicExprNode):
return 1
def nonlocally_immutable(self):
if ExprNode.nonlocally_immutable(self):
return True
entry = self.entry
return entry and (entry.is_local or entry.is_arg) and not entry.in_closure
......@@ -3038,10 +3040,11 @@ class SimpleCallNode(CallNode):
if i == 0 and self.self is not None:
continue # self is ok
arg = self.args[i]
if arg.is_name and arg.entry and (
(arg.entry.is_local and not arg.entry.in_closure)
or arg.entry.type.is_cfunction):
# local variables and C functions are safe
if arg.nonlocally_immutable():
# locals, C functions, unassignable types are safe.
pass
elif arg.type.is_cpp_class:
# Assignment has side effects, avoid.
pass
elif env.nogil and arg.type.is_pyobject:
# can't copy a Python reference into a temp in nogil
......
......@@ -2,7 +2,7 @@
# Cython Top Level
#
import os, sys, re
import os, sys, re, codecs
if sys.version_info[:2] < (2, 3):
sys.stderr.write("Sorry, Cython requires Python 2.3 or later\n")
sys.exit(1)
......@@ -607,6 +607,14 @@ def run_pipeline(source, options, full_module_name = None):
# Set up result object
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
if source_ext.lower() == '.py':
pipeline = context.create_py_pipeline(options, result)
......@@ -826,7 +834,7 @@ default_options = dict(
errors_to_stderr = 1,
cplus = 0,
output_file = None,
annotate = False,
annotate = None,
generate_pxi = 0,
working_path = "",
recursive = 0,
......
......@@ -2664,8 +2664,6 @@ int %(wmain_method)s(int argc, wchar_t **argv) {
#else
static int __Pyx_main(int argc, wchar_t **argv) {
#endif
int r = 0;
PyObject* m = NULL;
/* 754 requires that FP exceptions run in "no stop" mode by default,
* and until C vendors implement C99's ways to control FP exceptions,
* Python requires non-stop mode. Alas, some platforms enable FP
......@@ -2677,29 +2675,30 @@ static int __Pyx_main(int argc, wchar_t **argv) {
m = fpgetmask();
fpsetmask(m & ~FP_X_OFL);
#endif
if (argc) {
if (argc && argv)
Py_SetProgramName(argv[0]);
}
Py_Initialize();
if (argc) {
if (argc && argv)
PySys_SetArgv(argc, argv);
{ /* init module '%(module_name)s' as '__main__' */
PyObject* m = NULL;
%(module_is_main)s = 1;
#if PY_MAJOR_VERSION < 3
init%(module_name)s();
#else
m = PyInit_%(module_name)s();
#endif
if (PyErr_Occurred()) {
PyErr_Print(); /* This exits with the right code if SystemExit. */
#if PY_MAJOR_VERSION < 3
if (Py_FlushLine()) PyErr_Clear();
#endif
return 1;
}
Py_XDECREF(m);
}
%(module_is_main)s = 1;
#if PY_MAJOR_VERSION < 3
init%(module_name)s();
#else
m = PyInit_%(module_name)s();
#endif
if (PyErr_Occurred() != NULL) {
r = 1;
PyErr_Print(); /* This exits with the right code if SystemExit. */
#if PY_MAJOR_VERSION < 3
if (Py_FlushLine()) PyErr_Clear();
#endif
}
Py_XDECREF(m);
Py_Finalize();
return r;
return 0;
}
......@@ -2858,18 +2857,15 @@ check_binary_version_utility_code = UtilityCode(proto="""
static int __Pyx_check_binary_version(void);
""", impl="""
static int __Pyx_check_binary_version(void) {
long version_hex, major_version, minor_version;
PyObject *sys_hexversion = PySys_GetObject((char*)"hexversion");
if (sys_hexversion == NULL) return -1;
version_hex = PyInt_AsLong(sys_hexversion);
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 ctversion[4], rtversion[4];
PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
char message[200];
PyOS_snprintf(message, sizeof(message),
"compiletime version (%d, %d) of module '%.100s' does not match runtime version (%d, %d).",
PY_MAJOR_VERSION, PY_MINOR_VERSION, __Pyx_MODULE_NAME, (int)major_version, (int)minor_version);
"compiletime version %s of module '%.100s' "
"does not match runtime version %s",
ctversion, __Pyx_MODULE_NAME, rtversion);
#if PY_VERSION_HEX < 0x02050000
return PyErr_Warn(NULL, message);
#else
......
......@@ -2278,6 +2278,8 @@ class DefNode(FuncDefNode):
arg.hdr_type.declaration_code(arg.hdr_cname))
if not self.entry.is_special and sig.method_flags() == [TypeSlots.method_noargs]:
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:
arg_code_list.append(
"PyObject *%s, PyObject *%s"
......
......@@ -603,7 +603,7 @@ PyNumberMethods = (
MethodSlot(ibinaryfunc, "nb_inplace_multiply", "__imul__"),
MethodSlot(ibinaryfunc, "nb_inplace_divide", "__idiv__", py3 = False),
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_rshift", "__irshift__"),
MethodSlot(ibinaryfunc, "nb_inplace_and", "__iand__"),
......
......@@ -3,7 +3,7 @@
cdef extern from *:
ctypedef char const_char "const char"
cdef extern from "locale.h":
cdef extern from "locale.h" nogil:
struct lconv:
char *decimal_point
......
cdef extern from "math.h":
cdef extern from "math.h" nogil:
enum: M_E
enum: M_LOG2E
......
......@@ -9,9 +9,12 @@ local:
.git: REV := $(shell cat .gitrev)
.git: TMPDIR := $(shell mktemp -d tmprepo.XXXXXX)
.git:
rm -rf $(TMPDIR)
git clone $(REPO) $(TMPDIR)
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
rm -rf $(TMPDIR)
......
......@@ -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
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
make repo
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
with_statement_module_level_T536
function_as_method_T494
closure_inside_cdef_T554
ipow_crash_T562
pure_mode_cmethod_inheritance_T583
genexpr_iterable_lookup_T600
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:
"""
>>> CrashIPOW().__ipow__('a')
a
>>> x = CrashIPOW()
>>> x **= 'z'
z
"""
def __ipow__(self, other, mod):
print "%s, %s" % (other, mod)
def __ipow__(self, other):
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