summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Custom int128 conversion as a slow fallback (GH-5419)scoder2023-05-151-3/+24
| | | | * Use a custom (although slow) PyLong->cint128 conversion if "_PyLong_AsByteArray()" is missing (in PyPy/Limited API). * Avoid large integer conversion for enum types (where shift etc. don't work well).
* Prevent calling the dealloc slot of a non-GC base class with GC tracking ↵scoder2023-05-151-0/+38
| | | | | enabled. (GH-5432) This shows warnings in CPython (3.12) debug builds and can lead to crashes when GC triggers on an object while deallocating it.
* Keep 'extern' visibility in context of struct/union to properly infer ↵Matus Valo2023-05-032-3/+41
| | | | 'noexcept' for function pointer fields (GH-5386)
* Catch ValueError when calling memoryview() to avoid leaking implementation ↵Matus Valo2023-04-301-0/+26
| | | | details (GH-5406)
* Fix parsing of bracketed then called context managers (GH-5404)da-woods2023-04-281-0/+20
| | | | | | | Require the bracketed multiple context managers to be followed by a colon, so that the bracketed called context manager is identified as regular parentheses in old-style syntax. Fixes https://github.com/cython/cython/issues/5403
* Move C-only test out of Python test file.Stefan Behnel2023-04-242-59/+53
|
* Warn about useless directives that do not change the previous setting.Stefan Behnel2023-04-242-0/+62
| | | | Also, make sure that we correctly allow resetting directives, even if the new value is the same as the value from outside (since we might already have set it differently in the same directives block).
* Disallow @cfunc being applied to a @ufunc.Stefan Behnel2023-04-241-0/+7
| | | | Closes https://github.com/cython/cython/issues/5399
* Disallow @cfunc together with @ccall on the same function.Stefan Behnel2023-04-241-0/+20
|
* Allow assigning ctuples from arbitrary sequences, not just tuples. The code ↵Stefan Behnel2023-04-241-3/+26
| | | | was there anyway, just needed moving around a bit.
* Improve error message when assigning tuples of incorrect size to a ctuple. ↵Stefan Behnel2023-04-241-3/+3
| | | | Previously, it said "Expected tuple of size 4, got tuple", which is unhelpful and confusing.
* Ignore (and warn about) simple type-tuples in annotations (like "(int, ↵Stefan Behnel2023-04-242-6/+29
| | | | | | int)") and require "tuple[int, int]" instead. Closes https://github.com/cython/cython/issues/5397
* Avoid Python int object creation when multiplying sequences with C integers ↵scoder2023-04-212-0/+176
| | | | | | | | | (GH-5213) * Avoid redundant subtree analysis in MulNode when multiplying sequences with unknown types. * Avoid Python int creation when multiplying sequences with integers. * Also allow a cint mult_factor for sequences, avoiding Python coercion if possible. * Also optimise (int * ctuple), which will eventually end up as a Python tuple as well. * Make sure we only apply a "mult_factor" to a Python sequence (not ctuples), and make the re-analysis of TupleNode a little safer.
* Fix regression in code generation order for cdef classes (GH-5395)Lisandro Dalcin2023-04-211-1/+23
|
* Make memoryviews with aliased item types comformable (GH-5375)Yue Yang2023-04-201-0/+15
|
* Work around the new Py3.12 error message suggestions in doctests by not ↵Stefan Behnel2023-04-143-43/+43
| | | | | | printing the exceptions. In Py3.12, printing the AttributeError calls __getattr__(obj, '__dict__') to suggest typos, which changes the call counts to "__getattr__" in some of the tests.
* Add a "CYTHON_EXTERN_C" macro to allow redefining "__PYX_EXTERN_C" on user ↵scoder2023-04-131-42/+45
| | | | | | | | side (GH-5371) See https://github.com/cython/cython/pull/5366 Add a warning for users who already defined "__PYX_EXTERN_C" before that there is a new macro for this. Also try to reverse-engineer expressive names for the different test cases.
* Fix issues with partially optimized cascaded comparisons (GH-5357)da-woods2023-04-131-0/+66
| | | | | | | | | | | If a cascaded comparison is partially optimized (i.e. only some of the comparisons are optimized) then the result types must end up consistent all the way through. At the moment we select PyObject which probably isn't the most efficient option, but is the easiest to implement We do not require the whole cascaded optimization to succeed. Instead, we can just get Python comparisons as bool, and just ensure that the entire cascade has the same type
* Remove unintended duplicate of `IS_UNSIGNED_IMPL` and make the macro ↵0dminnimda2023-04-062-0/+20
| | | | | | generally available (GH-5358) Closes https://github.com/cython/cython/issues/5356 Fixes https://github.com/cython/cython/pull/5302
* Fix AnnotationWriter for IndexNode with empty TupleNode (GH-5355)Lisandro Dalcin2023-04-051-0/+5
|
* Merge branch '0.29.x'Stefan Behnel2023-04-011-0/+27
|\
| * Fix a reference leak when a for-loop's "else:" branch contains a "break" for ↵Stefan Behnel2023-04-011-1/+28
| | | | | | | | | | | | an outer loop. Closes https://github.com/cython/cython/issues/5347
* | Add an explicit (although unnecessary) "noexcept" marker to the ↵Stefan Behnel2023-03-311-0/+33
| | | | | | | | | | | | "PyCapsule_Destructor" function type to document explicitly that it must not emit exceptions. See https://github.com/scipy/scipy/issues/17234
* | Improve error message for 'cimport cython.floating' (GH-5295)da-woods2023-03-271-0/+4
| | | | | | | | Tries to provide some helpful hints for https://github.com/cython/cython/issues/5288 where people may be trying to cimport directives/types as if they were a module.
* | Allow InterpretCompilerDirectives.visit_AnnotationNode() to process nodes ↵Chia-Hsiang Cheng2023-03-261-0/+13
| | | | | | | | | | that have no children (GH-5336) Closes https://github.com/cython/cython/issues/5235
* | Allow soft-complex->double coercion to run without gil (#5287)da-woods2023-03-251-0/+48
| | | | | | | | | | | | It'll only need the GIL on failure (which it can get) and "power of" type maths is the soft of thing that people are likely already doing in nogil blocks
* | Add declarations for C++20 mathematical constants (GH-5309)Jonathan Helgert2023-03-241-0/+21
| |
* | Add a test for relative cimport within a submodule (GH-5320)Ralf Gommers2023-03-231-0/+17
| | | | | | | | | | This test mirrors the structure of SciPy's `linalg.cython_blas`, `linalg.cython_lapack` and `special.cython_special` modules. Original bug was resolved in master by https://github.com/cython/cython/pull/4552 (https://github.com/cython/cython/commit/0c8dea13946833606ab7e290d51cd12aee077c04)
* | Restore 0.29.x handling of None fused memoryviews (GH-5298)da-woods2023-03-231-0/+10
| | | | | | | | | | | | | | Partial fix for https://github.com/cython/cython/issues/5297 Ideally I think we should do something cleverer, but this'd complicated memoryview dispatch significantly. This PR just restores the 0.29.x behaviour where None matches the first type.
* | Fix ufunc GIL handling (#5332)da-woods2023-03-221-6/+47
| | | | | | | | | | | | | | | | It looks like Numpy releases the GIL for us (unless it's PyObject arguments), so we should assume that we don't have the GIL, and write code to regain it if needed, rather than assuming we need to release the GIL. Fixes #5328
* | Fix the relative-first import scheme for language_level=2 in Python 3. (GH-5329)scoder2023-03-221-0/+83
| | | | | | | | | | | | | | | | Since https://github.com/cython/cython/commit/4993ba6a0194c2fbcf438ae2833f43c33781148d, we returned the top-level package module instead of the module that was actually imported with its dotted name ("collections" instead of "collections.abc"). Closes https://github.com/cython/cython/issues/5308 See https://github.com/cython/cython/issues/2854
* | Fix exception handling in memoryview utilitycode (GH-5325)da-woods2023-03-203-9/+20
| | | | | | | | | | | | | | | | | | | | | | | | The new exception-handling semantics meant that the utility code always had to check for exceptions on some void nogil functions (requiring us to re-acquire the GIL). This made performance noticeably worse under some circumstances. Fix this by making the exception specifications noexcept for quite a few cdef functions in the memoryview utility code. Fixes https://github.com/cython/cython/issues/5324
* | Fix missing exported C function declarations with cimport_from_pyx enabled ↵Chia-Hsiang Cheng2023-03-171-0/+15
| | | | | | | | (#5318)
* | Limit the cname length for generated number constants since some C compilers ↵0dminnimda2023-03-171-0/+19
| | | | | | | | | | cannot handle long names (GH-5293) Closes https://github.com/cython/cython/issues/5290
* | Add support for C++ std::any (#5314)Maximilien Colange2023-03-161-0/+78
| |
* | Add a test for relative cimports from `__init__.pxd` files.Stefan Behnel2023-03-161-0/+15
| |
* | Add libcpp.cmath (#5262)Jonathan Helgert2023-03-113-0/+49
| | | | | | | | This PR adds the C++ STL cmath header. It's mainly motivated by the new C++17 mathematical special functions (like assoc_laguerre, assoc_legendre, beta, ...) and the C++20 linear interpolation function lerp. However, all other functions are already in libc.math, so I'm not really sure if we should have them in both libc.math and libcpp.cmath.
* | Merge branch '0.29.x'Stefan Behnel2023-03-072-29/+26
|\ \ | |/
| * Allow Py3.12 AttributeError suggestions in doctest output.Stefan Behnel2023-03-072-29/+26
| |
| * Avoid exponential recursion when coercing nested conditional expressions.Stefan Behnel2023-01-051-0/+46
| | | | | | | | | | | | This used to coerce the nesting tree twice at each condition, once for `coerce_to()` and once for `analyse_result_type()`, both calling each other for the entire subtree. Closes https://github.com/cython/cython/issues/5197
* | Allow nested C++ names after a module name (#5229)Chia-Hsiang Cheng2023-03-053-0/+64
| | | | | | | | | | | | | | | | | | | | Allow code like the following to compile: cimport m def my_func(): cdef m.CppClass.NestedClass c where m is a module, CppClass is a C++ class and NestedClass is a nested class inside CppClass.
* | Fix annotation typing of Optional[tuple] (#5272)da-woods2023-03-011-0/+9
| | | | | | Allow it to use a Py-tuple instead of a ctuple
* | Order merged_in utility code (#5282)da-woods2023-03-011-0/+13
| | | | | | | | | | | | Force utility code to come before pxd code which comes before module code. This specifically fixes #5269, (where the "ToPy" functions for cpdef enums weren't availbale when cyfunctions were created). But I think it's a good idea anyway.
* | Add a test for libc.stdlib, specifically for exception declarations on the ↵Stefan Behnel2023-03-011-0/+32
| | | | | | | | callback used by qsort.
* | Fix some issues when optimising the builtin memoryview (GH-5271)da-woods2023-03-011-0/+26
| | | | | | | | | | | | | | Error in capitalization. Closes https://github.com/cython/cython/issues/5270 Context managers were being optimized into a non-working state when involving a CloneNode. Closes https://github.com/cython/cython/issues/5268
* | Support auto-generation of Numpy ufuncs (GH-4803)da-woods2023-02-251-0/+158
| | | | | | | | | | Provides a decorator to automatically transform a cdef function into a Numpy ufunc (with the loop embedded in the function so hopefully pretty efficient). Closes https://github.com/cython/cython/issues/4758
* | Show warning when annotation type is unknown (GH-5079)Matus Valo2023-02-252-4/+67
| | | | | | Closes https://github.com/cython/cython/issues/5070
* | Shorten line to make style checker happy.Stefan Behnel2023-02-251-1/+1
| |
* | Make test pass after adding float inference in GH-5234. We should really be ↵Stefan Behnel2023-02-251-2/+2
| | | | | | | | inferring either Python float or C double from the Python type annotation of 'x' instead, but as it stands, we infer the types from the ctuple assignment.
* | Make unused **keyword argument show up in locals() (GH-4899)da-woods2023-02-241-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you had a function ``` def f(**kwds): return locals() ``` then 'kwds' would not appear in locals. Found while investigating one of the coverage gaps listed in https://github.com/cython/cython/issues/4163. ``` allow_null = all(ref.node.allow_null for ref in self.starstar_arg.entry.cf_references) # 3772 ↛ exit if allow_null: # 3773 ↛ 3774 code.putln("%s = NULL;" % (self.starstar_arg.entry.cname,)) ``` This uncovered code was wrong and has been removed. The only way I can see to have an `allow_null` reference to the ** argument would be to use `locals()`, and in this case an empty dict should be generated.