Stefan Behnel [Mon, 28 Jan 2013 07:00:11 +0000 (08:00 +0100)]
merge 0.18.x branch into master
scoder [Mon, 28 Jan 2013 06:52:41 +0000 (22:52 -0800)]
Merge pull request #179 from cgohlke/patch-3
Fix overflow_check CompileError with msvc
Christoph Gohlke [Sun, 27 Jan 2013 18:07:01 +0000 (10:07 -0800)]
Fix overflow_check CompileError with msvc
--HG--
extra : transplant_source : %3FH%B6t%1FFL%D8%2BF%7CV%7D%10T9%EA%CB%A0%00
Christoph Gohlke [Sun, 27 Jan 2013 18:07:01 +0000 (10:07 -0800)]
Fix overflow_check CompileError with msvc
Stefan Behnel [Sun, 27 Jan 2013 14:12:02 +0000 (15:12 +0100)]
fix doctest dependency on dict order
Stefan Behnel [Sun, 27 Jan 2013 12:18:05 +0000 (13:18 +0100)]
set version to 0.18rc1
Stefan Behnel [Sun, 27 Jan 2013 10:22:21 +0000 (11:22 +0100)]
enable control flow analysis for stack allocated structured variables (struct, union, array, C++ class)
Stefan Behnel [Sun, 27 Jan 2013 05:47:44 +0000 (06:47 +0100)]
simplify code a bit
Stefan Behnel [Sun, 27 Jan 2013 05:45:58 +0000 (06:45 +0100)]
use interned Python string constant instead of calling through __Pyx_GetAttrString()
Stefan Behnel [Sun, 27 Jan 2013 05:16:47 +0000 (06:16 +0100)]
merge 0.18.x branch into master
Stefan Behnel [Sun, 27 Jan 2013 05:16:30 +0000 (06:16 +0100)]
fix C compiler warnings about missing PyModuleDef field initialisers in Py3.[01]
Stefan Behnel [Sun, 27 Jan 2013 04:56:27 +0000 (05:56 +0100)]
merge 0.18.x branch into master
Stefan Behnel [Sun, 27 Jan 2013 04:56:12 +0000 (05:56 +0100)]
fix new test in Py2.[45]
Stefan Behnel [Sat, 26 Jan 2013 21:24:46 +0000 (22:24 +0100)]
rewrite except-as semantics using try-finally - seems to be the easiest way to get flow control analysis working for all cases
Stefan Behnel [Sat, 26 Jan 2013 18:20:35 +0000 (19:20 +0100)]
merge 0.18.x branch into master
scoder [Sat, 26 Jan 2013 18:19:07 +0000 (10:19 -0800)]
Merge pull request #164 from strohel/master
Add test for memoryview of extension type
Stefan Behnel [Sat, 26 Jan 2013 18:15:39 +0000 (19:15 +0100)]
merge 0.18.x branch into master
scoder [Sat, 26 Jan 2013 18:11:48 +0000 (10:11 -0800)]
Merge pull request #178 from strohel/cpp-catch-in-nogil
Fix calling an "except +" cpp function in a nogil function
Stefan Behnel [Sat, 26 Jan 2013 13:53:30 +0000 (14:53 +0100)]
enable except-as target deletion only when language level is 3
Stefan Behnel [Sat, 26 Jan 2013 13:23:47 +0000 (14:23 +0100)]
disable broken optimisation for except-as special case
Stefan Behnel [Sat, 26 Jan 2013 12:55:16 +0000 (13:55 +0100)]
remove some code redundancy
Stefan Behnel [Sat, 26 Jan 2013 12:15:04 +0000 (13:15 +0100)]
extend except-as test case
Stefan Behnel [Sat, 26 Jan 2013 12:06:57 +0000 (13:06 +0100)]
make except-as delete the target after the except clause
Stefan Behnel [Sat, 26 Jan 2013 10:06:46 +0000 (11:06 +0100)]
merge 0.18.x branch into master
Stefan Behnel [Sat, 26 Jan 2013 10:06:26 +0000 (11:06 +0100)]
fix test when using NumPy 1.7
Stefan Behnel [Sat, 26 Jan 2013 09:57:20 +0000 (10:57 +0100)]
merge 0.18.x branch into master
Stefan Behnel [Sat, 26 Jan 2013 09:54:04 +0000 (10:54 +0100)]
fix new memory view error test in Py2.4
--HG--
extra : transplant_source : %8A%F1%17%5C%A7%CA%1C%B1%17%A1%C5t%06O%5BI%F2%19Vq
Stefan Behnel [Sat, 26 Jan 2013 09:54:04 +0000 (10:54 +0100)]
fix new memory view error test in Py2.4
Matěj Laitl [Fri, 25 Jan 2013 10:27:49 +0000 (11:27 +0100)]
Fix calling an "except +" cpp function in a nogil function
For a source:
|cdef extern from "<foo>":
| cdef void foo_cpp() nogil except +
|
|cdef call_foo() nogil:
| foo_cpp()
We used to generate something like this to actually call foo_cpp() in call_foo():
|try{foo_cpp();}
|catch(...) {
| Py_BLOCK_THREADS; __Pyx_CppExn2PyErr(); Py_UNBLOCK_THREADS
| `code.error_goto(self.pos))`
|}
where Py_BLOCK_THREADS expands to "PyEval_RestoreThread(_save);".
__Pyx_CppExn2PyErr() (and alternatives, see SimpleCallNode) calls CPython A API
methods so it needs to be guarded in a nogil environment.
One problem is that "PyThreadState *_save" is only declared by "with nogil:"
block, so a .cpp file that doesn't compile is generated for the above code.
However, I think the real issue is that Py_(UN)BLOCK_THREADS is inappropriate
here, as it isn't allowed to be called recursively and is valid only directly
in a Py_BEGIN_ALLOW_THREADS ... Py_END_ALLOW_THREADS. IMO PyGILState_Ensure()
and PyGILState_Release() (through `code.put_ensure_gil()` and a friend) is the
correct thing to call here as it is allowed to be called recursively and
actually ensures the current thread can call CPython C API.
This patch does exactly this (and it breaks the generated code to multiple
lines as it would be way too long otherwise), plus it extends the
cpp_exceptions_nogil.pyx test with above example that doesn't compile with this
fix not applied.
Note that we explicitly pass declare_gilstate=True to put_ensure_gil(), as
PyGILState_Ensure() docs state that recursive calls to it must not share the
PyGILState_STATE. C++-style declaring a variable inside a block should be
no-problem here, as try{} .. catch() is obviously valid only in a C++ code.
--HG--
extra : transplant_source : %AA%F3%BDk%FE%F9%01%7F%8C%A4n%5E%DA4%97%A5%D9%AF%D60
Stefan Behnel [Sat, 26 Jan 2013 18:15:09 +0000 (19:15 +0100)]
changelog
Matěj Laitl [Fri, 25 Jan 2013 10:27:49 +0000 (11:27 +0100)]
Fix calling an "except +" cpp function in a nogil function
For a source:
|cdef extern from "<foo>":
| cdef void foo_cpp() nogil except +
|
|cdef call_foo() nogil:
| foo_cpp()
We used to generate something like this to actually call foo_cpp() in call_foo():
|try{foo_cpp();}
|catch(...) {
| Py_BLOCK_THREADS; __Pyx_CppExn2PyErr(); Py_UNBLOCK_THREADS
| `code.error_goto(self.pos))`
|}
where Py_BLOCK_THREADS expands to "PyEval_RestoreThread(_save);".
__Pyx_CppExn2PyErr() (and alternatives, see SimpleCallNode) calls CPython A API
methods so it needs to be guarded in a nogil environment.
One problem is that "PyThreadState *_save" is only declared by "with nogil:"
block, so a .cpp file that doesn't compile is generated for the above code.
However, I think the real issue is that Py_(UN)BLOCK_THREADS is inappropriate
here, as it isn't allowed to be called recursively and is valid only directly
in a Py_BEGIN_ALLOW_THREADS ... Py_END_ALLOW_THREADS. IMO PyGILState_Ensure()
and PyGILState_Release() (through `code.put_ensure_gil()` and a friend) is the
correct thing to call here as it is allowed to be called recursively and
actually ensures the current thread can call CPython C API.
This patch does exactly this (and it breaks the generated code to multiple
lines as it would be way too long otherwise), plus it extends the
cpp_exceptions_nogil.pyx test with above example that doesn't compile with this
fix not applied.
Note that we explicitly pass declare_gilstate=True to put_ensure_gil(), as
PyGILState_Ensure() docs state that recursive calls to it must not share the
PyGILState_STATE. C++-style declaring a variable inside a block should be
no-problem here, as try{} .. catch() is obviously valid only in a C++ code.
Robert Bradshaw [Fri, 25 Jan 2013 07:37:11 +0000 (23:37 -0800)]
Merge pull request #177 from strohel/propagate-error-memoryview
Fix error propagation from memoryview-returning functions
Matěj Laitl [Thu, 24 Jan 2013 10:59:23 +0000 (11:59 +0100)]
Fix error propagation from memoryview-returning functions
A code like
|cdef double[:] foo():
| raise AttributeError('dummy')
generated C code like this:
| __pyx_L1_error:;
| (...)
| __pyx_r.memview = NULL;
| __Pyx_AddTraceback("view_return_errors.foo", __pyx_clineno, __pyx_lineno, __pyx_filename);
| __pyx_L0:;
| if (unlikely(!__pyx_r.memview)) {
| PyErr_SetString(PyExc_TypeError,"Memoryview return value is not initialized");
| }
| __Pyx_RefNannyFinishContext();
| return __pyx_r;
|}
Which is incorrect in error case, because we set __pyx_r.memview to NULL and
then we test it, so that the PyErr_SetString() is always called in the error
case, which swallows previously-set error. (it also swallowed the traceback,
which I don't understand)
A fix is to jump to return_from_error_cleanup label in case return type is
memoryview, as it is currently done for the case when buffers are present.
A testcase that fauils w/out this fix applied is included, too.
v2: fix test under Python 3 by not using StandardError
--HG--
extra : transplant_source : G%B5%99Og%D1%81%25k%8F%1F%7B%02V%3E%B9%A4y%FF%EA
Matěj Laitl [Thu, 24 Jan 2013 10:59:23 +0000 (11:59 +0100)]
Fix error propagation from memoryview-returning functions
A code like
|cdef double[:] foo():
| raise AttributeError('dummy')
generated C code like this:
| __pyx_L1_error:;
| (...)
| __pyx_r.memview = NULL;
| __Pyx_AddTraceback("view_return_errors.foo", __pyx_clineno, __pyx_lineno, __pyx_filename);
| __pyx_L0:;
| if (unlikely(!__pyx_r.memview)) {
| PyErr_SetString(PyExc_TypeError,"Memoryview return value is not initialized");
| }
| __Pyx_RefNannyFinishContext();
| return __pyx_r;
|}
Which is incorrect in error case, because we set __pyx_r.memview to NULL and
then we test it, so that the PyErr_SetString() is always called in the error
case, which swallows previously-set error. (it also swallowed the traceback,
which I don't understand)
A fix is to jump to return_from_error_cleanup label in case return type is
memoryview, as it is currently done for the case when buffers are present.
A testcase that fauils w/out this fix applied is included, too.
v2: fix test under Python 3 by not using StandardError
Matěj Laitl [Thu, 29 Nov 2012 21:50:08 +0000 (22:50 +0100)]
Add test for memoryview of extension type
A test for a bug fixed in commit
478b939a4c99a77c0863cfd.
v2: add commit link above
v3: # tag: instead of # tags:, drop cpp tag as it means something different
that I originally thought
There was a bug that produced C code where gcc emitted warnings:
extension_type_memoryview.c: In function ‘__pyx_pf_25extension_type_memoryview_test_getitem’:
extension_type_memoryview.c:1468:15: warning: assignment from incompatible pointer type
extension_type_memoryview.c: In function ‘__pyx_pf_25extension_type_memoryview_2test_getitem_typed’:
extension_type_memoryview.c:1565:15: warning: assignment from incompatible pointer type
extension_type_memoryview.c:1568:18: warning: assignment from incompatible pointer type
And g++ failed with errors:
extension_type_memoryview.c: In function ‘PyObject* __pyx_pf_25extension_type_memoryview_test_getitem(PyObject*)’:
extension_type_memoryview.c:1468:213: error: cannot convert ‘__pyx_obj_25extension_type_memoryview_ExtensionType*’ to ‘PyObject*’ in assignment
extension_type_memoryview.c: In function ‘PyObject* __pyx_pf_25extension_type_memoryview_2test_getitem_typed(PyObject*)’:
extension_type_memoryview.c:1565:213: error: cannot convert ‘__pyx_obj_25extension_type_memoryview_ExtensionType*’ to ‘PyObject*’ in assignment
extension_type_memoryview.c:1568:20: error: cannot convert ‘PyObject*’ to ‘__pyx_obj_25extension_type_memoryview_ExtensionType*’ in assignment
Robert Bradshaw [Tue, 22 Jan 2013 01:17:10 +0000 (17:17 -0800)]
Merge pull request #176 from larsmans/fix-indent
fix indentation error in userguide
Lars Buitinck [Mon, 21 Jan 2013 08:54:39 +0000 (09:54 +0100)]
fix indentation error in userguide
--HG--
extra : transplant_source : %7B%A4%F1%C4/%E4l%2C_%BFF%5B%B7%9C%9F%E0_%2B%15%3D
Lars Buitinck [Mon, 21 Jan 2013 08:54:39 +0000 (09:54 +0100)]
fix indentation error in userguide
Stefan Behnel [Mon, 21 Jan 2013 07:42:57 +0000 (08:42 +0100)]
merge 0.18.x branch back into master
Stefan Behnel [Mon, 21 Jan 2013 07:42:11 +0000 (08:42 +0100)]
fix compiler crash in error case
Stefan Behnel [Mon, 21 Jan 2013 06:50:23 +0000 (07:50 +0100)]
optimise abs(long long)
Stefan Behnel [Mon, 21 Jan 2013 06:47:37 +0000 (07:47 +0100)]
merge 0.18.x branch back into master
Stefan Behnel [Mon, 21 Jan 2013 06:22:10 +0000 (07:22 +0100)]
avoid unused utility code for abs()
Stefan Behnel [Mon, 21 Jan 2013 06:18:17 +0000 (07:18 +0100)]
simplify abs() optimisation for C integers and fix it for the most negative int/long value
Stefan Behnel [Sun, 20 Jan 2013 20:50:38 +0000 (21:50 +0100)]
fix test
Stefan Behnel [Sun, 20 Jan 2013 16:36:39 +0000 (17:36 +0100)]
suppress C compiler warning on power operation on unsigned C int types
Stefan Behnel [Sun, 20 Jan 2013 16:11:24 +0000 (17:11 +0100)]
improve test output in failure case
Stefan Behnel [Sun, 20 Jan 2013 08:30:30 +0000 (09:30 +0100)]
Added tag 0.18b1 for changeset
c1a18ab6b080
Stefan Behnel [Sun, 20 Jan 2013 08:29:38 +0000 (09:29 +0100)]
merge 0.18.x branch back into master
Stefan Behnel [Sun, 20 Jan 2013 07:08:15 +0000 (08:08 +0100)]
move exception class into shadow function as we may not want to export it under the cython.* namespace at this point
Stefan Behnel [Sat, 19 Jan 2013 19:47:29 +0000 (20:47 +0100)]
remove references to 'minierror' module from Shadow.py
Stefan Behnel [Sat, 19 Jan 2013 13:14:16 +0000 (14:14 +0100)]
undo code removal - not entirely clear what to make of it
Stefan Behnel [Sat, 19 Jan 2013 13:08:35 +0000 (14:08 +0100)]
set version to 0.18b1
Stefan Behnel [Sat, 19 Jan 2013 13:08:01 +0000 (14:08 +0100)]
removed broken minivect related code from branch since minivect will not be released as part of 0.18
Stefan Behnel [Fri, 18 Jan 2013 13:58:28 +0000 (14:58 +0100)]
implement relative import support for .pxd files in cythonize()
Stefan Behnel [Fri, 18 Jan 2013 13:36:58 +0000 (14:36 +0100)]
merge 0.18 branch back into master
Stefan Behnel [Fri, 18 Jan 2013 13:36:40 +0000 (14:36 +0100)]
work around missing relative cimport support in cythonize()
Stefan Behnel [Fri, 18 Jan 2013 13:31:33 +0000 (14:31 +0100)]
merge 0.18 branch back into master
Stefan Behnel [Fri, 18 Jan 2013 13:30:04 +0000 (14:30 +0100)]
changelog
Stefan Behnel [Fri, 18 Jan 2013 13:11:00 +0000 (14:11 +0100)]
fix cimport in libcpp.string
Stefan Behnel [Fri, 18 Jan 2013 13:06:26 +0000 (14:06 +0100)]
update 'const' section in string handling tutorial to reflect the new 'const' language support
Stefan Behnel [Fri, 18 Jan 2013 12:55:38 +0000 (13:55 +0100)]
replace 'const_xyz' work-arounds in standard .pxd files by real 'const' declarations
Stefan Behnel [Fri, 18 Jan 2013 09:31:24 +0000 (10:31 +0100)]
add failing Py3 exception test
Stefan Behnel [Fri, 18 Jan 2013 09:26:44 +0000 (10:26 +0100)]
minor test cleanup
Stefan Behnel [Fri, 18 Jan 2013 09:24:34 +0000 (10:24 +0100)]
move doctests into tested functions
Stefan Behnel [Fri, 18 Jan 2013 09:05:50 +0000 (10:05 +0100)]
extended test case
Robert Bradshaw [Fri, 18 Jan 2013 07:33:14 +0000 (23:33 -0800)]
Merge pull request #175 from steinn/pyximport_fix
fix import of pyx modules when '' is in sys.path
Steinn Steinsen [Wed, 16 Jan 2013 10:38:47 +0000 (10:38 +0000)]
fix import of pyx modules when '' is in sys.path
If '' is in sys.path and a module is found the package_path
is relative and breaks the build process.
Steinn Steinsen [Wed, 16 Jan 2013 10:38:47 +0000 (10:38 +0000)]
fix import of pyx modules when '' is in sys.path
If '' is in sys.path and a module is found the package_path
is relative and breaks the build process.
--HG--
extra : transplant_source : 9%EA%CC%A6%3D%1B9R%EF%0DmM%CFZ%18%F3%EC%06%3B%B7
Robert Bradshaw [Tue, 15 Jan 2013 16:57:40 +0000 (08:57 -0800)]
Merge pull request #174 from stevenwinfield/pyxbld_fix
Use OS-dependent directory separator - a / on windows is interpreted by ...
Steven Winfield [Tue, 15 Jan 2013 14:07:37 +0000 (14:07 +0000)]
Use OS-dependent directory separator - a / on windows is interpreted by LINK as a command line switch
--HG--
extra : transplant_source : %A8%F23%AF%26%BC%82y1%86S%1Ac%D3%40%089o%DCQ
Stefan Behnel [Fri, 18 Jan 2013 13:11:00 +0000 (14:11 +0100)]
fix cimport in libcpp.string
--HG--
extra : transplant_source : %E6%CA%F8%11%E8%81u%B9%95%3D%27%C1%0F%F3O%8A%12%3Cnl
Stefan Behnel [Fri, 18 Jan 2013 13:06:26 +0000 (14:06 +0100)]
update 'const' section in string handling tutorial to reflect the new 'const' language support
--HG--
extra : transplant_source : U%15%0B%8E%81%02%F2kE%AA%07u%EF%82%3D14%F1C%86
Stefan Behnel [Fri, 18 Jan 2013 12:55:38 +0000 (13:55 +0100)]
replace 'const_xyz' work-arounds in standard .pxd files by real 'const' declarations
--HG--
extra : transplant_source : H%91%CF%08t%B1%908%AE%26%81%1B%F9%2C%9A%3Fh%ECWK
Steven Winfield [Tue, 15 Jan 2013 14:07:37 +0000 (14:07 +0000)]
Use OS-dependent directory separator - a / on windows is interpreted by LINK as a command line switch
Robert Bradshaw [Mon, 14 Jan 2013 18:57:06 +0000 (10:57 -0800)]
Merge remote-tracking branch 'remotes/main/0.17'
Robert Bradshaw [Sat, 12 Jan 2013 20:59:27 +0000 (12:59 -0800)]
Make __pyx_import_star_type_names static to remove link errors when freezing.
Stefan Behnel [Thu, 10 Jan 2013 21:14:20 +0000 (22:14 +0100)]
preprocess byte string literal escaping instead of doing repeated replacements at runtime
Stefan Behnel [Thu, 10 Jan 2013 21:09:37 +0000 (22:09 +0100)]
undo Py3.3 surrogates support fixes - breaks too many special cases with strings
Stefan Behnel [Thu, 10 Jan 2013 21:07:01 +0000 (22:07 +0100)]
undo Py3.3 surrogates support fixes - breaks too many special cases with strings
Stefan Behnel [Thu, 10 Jan 2013 21:00:03 +0000 (22:00 +0100)]
extended (failing) test cases
Robert Bradshaw [Tue, 8 Jan 2013 04:47:43 +0000 (20:47 -0800)]
Merge pull request #173 from yarikoptic/upstream-0.17
BF: replace show-ref with rev-parse --verify for determining current treeish location
Stefan Behnel [Mon, 7 Jan 2013 19:08:22 +0000 (20:08 +0100)]
fix Unicode string initialisation in PyPy
Stefan Behnel [Sun, 6 Jan 2013 19:26:39 +0000 (20:26 +0100)]
add error test case for unknown \N{...} Unicode escape name
Stefan Behnel [Sun, 6 Jan 2013 19:19:41 +0000 (20:19 +0100)]
implement \N{...} Unicode escapes for literals
Stefan Behnel [Sun, 6 Jan 2013 13:00:39 +0000 (14:00 +0100)]
add <locals> to __qualname__ for closures as defined by PEP 3155
Stefan Behnel [Sun, 6 Jan 2013 10:37:25 +0000 (11:37 +0100)]
safety fixes and a little branch prediction helping in CyFunction utility code
Stefan Behnel [Sun, 6 Jan 2013 10:10:43 +0000 (11:10 +0100)]
fix surrogates in Unicode literals in Python 3.3 (the UTF-8 codec rejects them explictly)
Stefan Behnel [Sat, 5 Jan 2013 14:02:29 +0000 (15:02 +0100)]
move __Pyx_InitStrings() utility function into StringTools.c
Stefan Behnel [Fri, 4 Jan 2013 16:28:11 +0000 (17:28 +0100)]
fix test
Stefan Behnel [Fri, 4 Jan 2013 15:39:01 +0000 (16:39 +0100)]
implement __qualname__ special attribute on Python functions/classes (PEP 3155)
Stefan Behnel [Fri, 4 Jan 2013 06:36:45 +0000 (07:36 +0100)]
make cleanup safety fix more explicit
Stefan Behnel [Fri, 4 Jan 2013 06:29:34 +0000 (07:29 +0100)]
fix merge conflict
Stefan Behnel [Thu, 3 Jan 2013 20:55:20 +0000 (21:55 +0100)]
fix comparison of single character unicode literals
--HG--
extra : rebase_source :
5e91ffb0a20724dc92084bb68288cb6000814dca
Robert Bradshaw [Thu, 3 Jan 2013 19:39:55 +0000 (11:39 -0800)]
Prep for 0.17.4 release.
Stefan Behnel [Thu, 3 Jan 2013 15:57:07 +0000 (16:57 +0100)]
generate safer cleanup code that also works in the case something goes badly wrong early at module init time
--HG--
extra : rebase_source :
015495e6aee6c59b11ee9169d2ad597ff54bfd0c
Robert Bradshaw [Thu, 3 Jan 2013 20:34:13 +0000 (12:34 -0800)]
More overflowcheck documentation.
Robert Bradshaw [Thu, 3 Jan 2013 20:25:13 +0000 (12:25 -0800)]
Merge branch 'bugs'
Conflicts:
CHANGES.rst
Cython/__init__.py
Stefan Behnel [Thu, 3 Jan 2013 06:30:35 +0000 (07:30 +0100)]
merge
Stefan Behnel [Thu, 3 Jan 2013 06:28:55 +0000 (07:28 +0100)]
add test tags