| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
reduce redundancy. (GH-5350)
|
|
|
|
|
| |
cannot handle long names (GH-5293)
Closes https://github.com/cython/cython/issues/5290
|
|
|
|
|
|
| |
Not all `py_constants` are actually `py_constants` so they need to be checked before generating clean-up code.
Since this fact is a source of bugs (like this one), it should be cleaned up. `py_constants` should be limited to Python constants (or get a more accurate name, but it seems reasonable to have such a list of things that need cleanup).
Issue found in https://github.com/cython/cython/pull/5261
|
|
|
|
| |
generation.
|
| |
|
|
|
|
|
| |
Makes insertion points behave as they do elsewhere,
adds the ability to track indentation (which I don't use
here, but which I think will clear things up)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
First part of https://github.com/cython/cython/issues/3689
First part of https://github.com/cython/cython/issues/4495
This tries to put all the global static variables into the
module state struct. When CYTHON_USE_MODULE_STATE is false,
they're looked up from a single static instance of the struct.
This allows a lot of semi-duplicated code to be dropped.
It doesn't get rid of the awkward `#defines` to access the
struct (that's probably the next step of the cleanup).
It moves the stringtab from a global into a function local.
It moves the statically defined coroutine types into the
module state struct in the same way that CyFunction/FusedFunction
already were.
It's mostly an exercise in deleting things - it doesn't
attempt to do any significant cleanup of the generation code.
|
|\ |
|
| |
| |
| |
| |
| |
| | |
* Fix clang -Wcomma
* Fix clang -Wextra-semi-stmt
* Fix clang -Wconditional-uninitialized
* Fix clang -Wunreachable-code-return
|
| |
| |
| |
| |
| |
| | |
(GH-4749)"
This reverts commit 74073417c4f7e616af0a139a55f790f1ec7fe728.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Closes https://github.com/cython/cython/issues/4637
See See https://github.com/cython/cython/issues/3556
* Acquire the GIL in nogil functions only when strictly needed on function exit, e.g. for cleaning up temp variables from with-gil blocks or adding tracebacks.
See https://github.com/cython/cython/issues/3554
* Make the GIL-avoidance in 7d99b0f0 actually work in nogil functions and not just nogil sections.
See https://github.com/cython/cython/issues/3558
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This means that reverse operators (e.g. `__radd__`) won't be
hidden by the automatic wrapper that `PyType_Ready()` produces if
the forward method exists. Although they won't work as
in Python, they will be possible to look up and call explicitly.
This should make it easier to write code that's compatible with
Cython 0.29.x and Cython 3 (where reverse operators will be full supported).
Closes https://github.com/cython/cython/issues/4750
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
(GH-4703)" (GH-4742)
PR 4703 was an incomplete backport of the changes needed for #3554 and generates incorrect C code.
See https://github.com/cython/cython/issues/3554
Reverts https://github.com/cython/cython/pull/4703
This reverts commit d395a56f8e68ee563f866d0dec5a31a37f77df9e.
|
| |
| |
| |
| |
| |
| | |
Acquire the GIL in nogil functions only when strictly needed on function exit, e.g. for cleaning up temp variables from with-gil blocks or adding tracebacks.
Closes GH-3554
Closes GH-4637
|
| |
| |
| |
| | |
file instead of "None".
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* Validate and fix temp releasing (GH-3708)
Backports 92147baf11071352ffbfa475d0d21e091753e628.
* Fix a temp leak in the type init code.
* Fix temp leaks in fused types initialisation code.
* Correctly release the buffer index temps allocated for index calculations.
* Make tests fails hard if a temp variable is not released at the end of a generated function.
* Fix temp leak in switch statement code.
* Make end-to-end tests fail on refnanny output.
* Fix result temp leak in PyTypeTestNode.
* Fix result temp leak in external type/function import code and enable the refnanny check for them.
* Fix temp leak when try-return-finally is used in generators.
* Make it explicit when an allocated temp is not meant to be reused.
* Fix temp leak when assigning to the real/imag attributes of complex numbers.
* Fix temp leak when assigning to a memoryview slice.
* Clean up "num_threads" result temp in parallel section, not only in prange loop.
* Fix temp leak in Pythran buffer setitem code.
* Simplify NumPyMethodCallNode since it does not need the Python function anymore. Previously, it generated code that needlessly looked up the Python function without actually using it.
* Fix temp leak when deleting C++ objects.
* Add a test that actually reusing temps when deleting C++ objects works correctly.
|
| |
| |
| |
| | |
It was written before `with` was universally available. Update
the interface to make it harder to get wrong.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
I was getting a whole lot on errors along the lines of
```
cfunc_convert_with_memoryview.cpp:11097:8: note: in expansion of macro ‘CYTHON_UNUSED’
11097 | static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
| ^~~~~~~~~~~~~
cfunc_convert_with_memoryview.cpp:407:31: note: an attribute that appertains to a type-specifier is ignored
407 | #define CYTHON_UNUSED [[maybe_unused]]
```
This swaps the order of static and CYTHON_UNUSED.
I think whether the error appears is probably dependent on the exact
compiler version.
|
| |
| |
| |
| |
| | |
As a result of f946fe22fff32077dc58beeb64ec1ebc85d37632
And fix at least one pre-existing reference counting leak for memoryview references in things like
`any(i > 0 for i in memview)`
|
| |
| |
| |
| | |
their call overhead.
|
| |
| |
| |
| |
| |
| | |
0b4370678e5b00a020cd990f922964d3aba59884.
Closes https://github.com/cython/cython/issues/4945
|
| |
| |
| |
| | |
newlines.
|
| |
| |
| | |
Fixes https://github.com/cython/cython/issues/3447
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This means that reverse operators (e.g. `__radd__`) won't be
hidden by the automatic wrapper that PyType_Ready() produces if
the forward method exists. Although they won't work as
in Python, they will be possible to look up and call explicitly.
This should make it easier to write code that's compatible with
Cython 0.29.x and Cython 3 (where reverse operators will be
full supported).
Adjusted to work on Cython 3.0.
Based on https://github.com/cython/cython/pull/4753
Closes https://github.com/cython/cython/issues/4750
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
practice since the regex is only applied to Cython's only C code.
Found by GitHub CodeQL.
|
| |
| |
| |
| | |
is probably what users expect since silently keeping outdated files is error prone.
|
| |
| |
| |
| | |
file instead of "None".
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
Also adds a check whether we have the GIL before doing so. This
is important because Py_UNBLOCK_THREADS is documented as unsafe
if we don't hold the GIL.
Closes https://github.com/cython/cython/issues/4137
|
| |
| |
| |
| |
| |
| |
| | |
This can happen (rarely) with exceptions that occur very early in the module init process.
Fixes https://github.com/cython/cython/issues/4377
Uses a fake Numpy module for testing to make a version of "import_array" that always fails.
|
| |
| |
| | |
Adds utility code sections to toggle C compiler warnings for the duration of the utility code.
|
| |
| |
| |
| |
| |
| |
| | |
* Fix class attributes access where cpp_locals=False.
* Add "no-cpp-locals" tag to mark a test as not suitable for running with "cpp_locals=True".
* Add a list of "extra_directives" to runtests as additional test mode.
Resolves some issues in https://github.com/cython/cython/issues/4266
|
| |
| |
| |
| |
| |
| |
| | |
1) Entry utility_code wasn't being imported unless the entry was visibly used. The utility code is needed for the definition even if unused. I think this is what utility_code_definition is for, but I'm not completely sure. I also had to add some calls to ensure it's used.
2) CppOptionalTempCoercions weren't being moved correctly. Tested by printing from the destructor.
3) cdef-class attributes weren't being created or destroyed correctly. Tested by printing from the destructor
|
| |
| |
| |
| |
| | |
This avoids the need for default constructors of stack allocated variables and temps by allowing late initialisation.
Closes https://github.com/cython/cython/issues/4160
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* Split the current "CYTHON_COMPILING_IN_LIMITED_API" macro guard into separate feature guards:
1) using a global module state struct ("CYTHON_USE_MODULE_STATE")
2) using PyType_FromSpec() for extension types ("CYTHON_USE_TYPE_SPECS")
3) actual limited-API special casing ("CYTHON_COMPILING_IN_LIMITED_API")
* Start using PyType_FromModuleAndSpec() for creating extension types since that adds the module reference with PEP-573.
* Do not pass the module reference into *shared* extension types since we do not want to keep the module alive just because other modules still refer to the type.
* Mark the Limited-API and module state struct features as experimental.
* Add CI setups for using PyType_FromSpec() for creating extension types.
* Avoid overly complicated code in __Pyx_FetchCommonTypeFromSpec() when we are not compiling against the Limited-API.
* Correctly set up the bases tuple for PyType_FromSpecWithBases() and stop relying on the PyTypeObject struct being available in several places by using the type pointer instead (and setting it early enough).
* Set the "tp_dealloc" slot from the type spec, also for the limited API case.
* Generally re-enable the "heaptype bases hack" when creating extension types.
* Implement "tp_dictoffset" slot when using type specs in Py3.9+.
* Fix and simplify the vtable setup in the limited API config.
* Make CyFunction inheritable to "correctly" allow FusedFunction subclassing it.
* Enable buffer interface support when using type specs by assigning the "tp_as_buffer" slot explicitly after creating the type.
* Set "vectorcalloffset" when using type specs.
* Make "__bool__" slot prefer Py3+ name instead of Py2 name to make the correct name ("Py_nb_bool") appear in the type spec.
* Validate and fix up all extension types when constructing them from type specs (not only the internal ones).
* Only call PyType_Modified() once after changing a type, not once per change.
* Turn the "no buffer protocol in the limited API" error into a warning since the user code might still work without it.
* Enable the same flags for CyFunction in the static type and type spec case since it's shared across modules and thus, we might otherwise end up with differently configured types in the same runtime.
* The names of Cython's internal types (functions, generator, coroutine, etc.) are now prefixed with the shared module name, instead of making them look like homeless builtins.
See https://bugs.python.org/issue20204
See https://github.com/python/cpython/commit/490055a1673b524da2ebe2312f072aba2a826036
* Work around a CPython bug that makes it overwrite exttype member definitions for the "__module__" attribute.
See https://bugs.python.org/issue40703
* Inherit buffer slots manually since type slots don't support them and thus PyType_Ready() does not see them.
* Add METH_METHOD call support (currently unused).
* Fix the vectorcall offset used in CyFunction type struct in Py3.9, if it inherits from PyCMethodObject instead of PyCFunctionObject.
* Work around the duplicate creation of the "OverrideCheckNode" for fused cpdef functions.
See https://github.com/cython/cython/issues/3628
* Decref the type when deallocating instances of heap types in Py3.8+.
See https://bugs.python.org/issue35810
* Look up the fused dispatch function in the override check, not the specialisation (which shouldn't be overridden all by itself).
Closes https://github.com/cython/cython/issues/3628
* Avoid running the override check for CyFunction, just because it's not a PyCFunction itself.
|
| |
| |
| |
| | |
where appropriate.
|
| | |
|
| |
| |
| | |
clang warns about dead code when an if-statement always evaluates to false. This warning can be silenced using an extra '()'.
|
| |
| |
| | |
Specifically this allows public packed structs but may also allow other public declarations that require small amounts of utility code.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* Cython debugger documentation: Added link to an installation script.
* Got a new libpython.py from the cpython source distribution.
* Default language level in tests is now 3 instead of 2
* Migrated codefile from python 2 to python 3.
* Added testcase for the cy list command in cygdb.
* Temporarily removing test case that freezes gdb.
* Fixed a bug that broke several Cygdb tests.
The cython_debug/cython_debug_info_* files map the names of the C-functions generated by the Cython compiler to the names of the functions in the *.pyx source. If the function was defined using "def" (and not "cpdef" or "cdef") in the *.pyx source file, the C-function named in cython_debug/cython_debug_info_* used to be __pyx_pw_*, which is the name of the wrapper function and now it is __pyx_f_*, which is the name of the actual function. This makes some Cygdb tests pass that did not pass before.
* Better error messages: If a cygdb command raises, a traceback will be printed.
* Fixed a bug in cygdb.
The following now works:
1. Start cygdb
2. Type "cy exec" and hit enter
3. Type some other lines
4. Type "end" and hit enter.
-> These "other lines" will get executed
* Fixed a bug in cygdb: cy list now works outside of functions.
* Added print_hr_allmarkers function for easier debugging.
* Fixed a bug that broke cygdb:
cy break did not work if you put the breakpoint outside of a function if there was e.g. the following somewhere in your *.pyx file:
cdef class SomeClass():
pass
* Added a Cygdb test for printing global variables.
* Fixing cygdb: Replaced cy print with a simple, working solution.
* If an exception in Cygdb occurs, a stacktrace will be printed.
* Fixed a bug that broke cy break -p
* Bugfix: The compiler now writes out correctly which cython linenumber and path corresponds to which c linenumber.
* Set language_level=2 in runtests.py
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* Fix a temp leak in the type init code.
* Fix temp leaks in fused types initialisation code.
* Correctly release the buffer index temps allocated for index calculations.
* Make tests fails hard if a temp variable is not released at the end of a generated function.
* Fix temp leak in switch statement code.
* Make end-to-end tests fail on refnanny output.
* Fix result temp leak in PyTypeTestNode.
* Fix result temp leak in external type/function import code and enable the refnanny check for them.
* Fix temp leak when try-return-finally is used in generators.
* Make it explicit when an allocated temp is not meant to be reused.
* Fix temp leak when assigning to the real/imag attributes of complex numbers.
* Fix temp leak when assigning to a memoryview slice.
* Clean up "num_threads" result temp in parallel section, not only in prange loop.
* Fix temp leak in Pythran buffer setitem code.
* Simplify NumPyMethodCallNode since it does not need the Python function anymore. Previously, it generated code that needlessly looked up the Python function without actually using it.
* Fix temp leak when deleting C++ objects.
* Add a test that actually reusing temps when deleting C++ objects works correctly.
|
| | |
|
| |
| |
| | |
… and enforce them with pycodestyle.
|
|\ \
| |/ |
|
| |
| |
| |
| | |
method replacements at all, it's not reusable.
|
| | |
|
| |
| |
| |
| |
| |
| | |
used.
This was previously broken by the introduction of the "__PYX_ERR()" macro.
|