| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
| |
The module struct was being initialized with `= {}` which isn't valid C until C23 so MSVC was rejecting it
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
ModuleNode.sort_types_by_inheritance() (GH-5139)
|
|
|
|
|
|
|
|
|
|
| |
With clang 14+ and `-Werror,-Wbitwise-instead-of-logical` build failed with:
```
$(BUILD_ROOT)/library/python/cyson/cyson/_cyson.pyx.cpp:29973:39: error: use of bitwise '&' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5cyson_6_cyson_InputStream < 16) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5cyson_6_cyson_InputStream)) & ((Py_TYPE(o)->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0))) {
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&&
$(BUILD_ROOT)/library/python/cyson/cyson/_cyson.pyx.cpp:29973:39: note: cast one or both operands to int to silence this warning
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a subset of PR #2951, containing the code concerning nested class definition support.
For the records, you'll find below the original #2951 description of theses changes:
4 - Nested classes
------------------------
This is not about wrapping nested C++ classes, because it is already present and functional (and there's a test which can prove it).
This is about being able to generate C++ classes definitions with nested classes. So it is exactly like the batch about method overloading: being able to define and not just declare.
If I have understood it properly, this addresses issue #1218
a) Make cppclass generate code for nested definitions (for example nested cppclass)
b) Fix Symtab for the inherited nested types: this is basically the same thing than for other attributes, have a separate "inherited types" array, to be able to have them in scope but ignore them during code generation.
c) Amend the nested classes test
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes #1839
cdef public functions should be declared with the appropriate linkage:
* in C mode, either extern or extern "C", depending on whether the header file is included in (resp. object code is linked against) a C or a C++ compilation unit. Choice is made at compile-time through #ifdef __cplusplus macros. NB: This is the current behavior.
* in C++ mode, extern "C++" is the only option, as C code cannot call C++ code. Note that extern "C++" should be preferred over extern to allow users to #include the C++ header inside a extern "C" block (which is legal, although barely used).
Note that the current behavior is OK for C mode, but is incorrect for the C++ mode. As described in #1839, this incorrect behavior is diagnosed by compilers emitting warnings when cdef public functions return a C++ type (e.g. std::vector).
The test introduced in this PR checks that the current behavior for C mode (with both C and C++ compatibility) is preserved, and that the behavior for C++ mode is fixed.
|
|\ |
|
| |
| |
| |
| |
| |
| | |
* Fix clang -Wcomma
* Fix clang -Wextra-semi-stmt
* Fix clang -Wconditional-uninitialized
* Fix clang -Wunreachable-code-return
|
| |
| |
| |
| |
| |
| | |
including final types that inherit __del__ from elsewhere (either
known or unknown).
Fixes #4995
|
| |
| |
| |
| | |
itemsize for the "size changed" check (GH-4894)
|
|\ \
| |/ |
|
| |
| |
| |
| |
| |
| | |
different sources.
See https://github.com/cython/cython/pull/4764
|
| |
| |
| |
| |
| | |
time package path (GH-4764)
Closes https://github.com/cython/cython/issues/4763
|
| | |
|
| |
| |
| |
| | |
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
|
| |
| |
| |
| | |
`xml.etree.ElementTree.Element.getiterator()` was deprecated in Python
2.7 & 3.2 and removed in Python 3.9.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 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.
|
| | |
|
| |
| |
| |
| |
| |
| | |
reverting https://github.com/cython/cython/pull/3633 and force it to "False".
Closes #3688.
|
| |
| |
| |
| | |
This reverts commit e6a812402b0368cf930a55ed465a38820f606054.
|
| |
| |
| |
| | |
This reverts commit d849fb2379f4f892c8374b52385991c399c31a49.
|
| |
| |
| |
| | |
This reverts commit bcb938776c5a502a4a451c7a24c4b80d110a5c86.
|
| |
| |
| |
| | |
This reverts commit 02bb311d96359c7d2a359415612a9ffa24eda0a0.
|
| |
| |
| |
| |
| | |
time package path (GH-4764)
Closes https://github.com/cython/cython/issues/4763
|
| |
| |
| |
| |
| |
| | |
It appears to have been be used for Python < 2.6 (which didn't have the new buffer protocol).
Most of the mechanism had already been removed, but the capsule attributes that it relied on were still generated.
Also removed some utility code that was only used for this feature.
|
| |
| |
| |
| | |
for type-specs / Limited-API (GH-4506)
|
| |
| |
| | |
Closes https://github.com/cython/cython/issues/3612
|
| |
| |
| |
| |
| | |
Follow up to https://github.com/cython/cython/pull/4453 (01d323abea91f8b75caffa452f57320b06a57e9e).
That PR creates a temp that's only used in the limited API
(and therefore causes warnings on all other paths)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The type for the self argument for binops depends on the compile
directives. Therefore it needs a set of type slots that depends
on the compiler directives.
I've therefore got rid of the big static list of typeslots in
TypeSlots.py in favour of a class that defines them all (and
can be initialized with suitable compiler directives as needed).
This involves moving a static dictionary and list out of the
global scope too, so that they too can be part of the class.
The passing of the dictionary and list to all the constructors
is a bit awkward
Fixes https://github.com/cython/cython/issues/4434
|
| |
| |
| |
| |
| |
| |
| |
| | |
Before this the _Py_TPFLAGS_HAVE_VECTORCALL was set all the time
when using the limited api, but a CyFunction never sets up a
vectorcall function. This caused basically all function calls to
crash when binding=True with the limited API.
Also removes the premature refnanny usage when setting up the module.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| | |
files (GH-4309)
Fixes https://github.com/cython/cython/issues/4308
|
| |
| |
| |
| | |
See https://github.com/cython/cython/pull/3626
|
| | |
|
| |
| |
| | |
Closes https://github.com/cython/cython/issues/4172
|
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| | |
Implements https://github.com/cython/cython/issues/2090
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 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.
|
| |
| |
| |
| |
| | |
See https://github.com/cython/cython/issues/4177
See https://github.com/cython/cython/pull/4178
|
| |
| |
| |
| |
| |
| |
| | |
Cython (GH-4178)
This is a common gotcha for new users who name their .pyx file after the C file that they want to wrap.
Closes https://github.com/cython/cython/issues/4177
|
| |
| |
| |
| |
| |
| |
| | |
(GH-4125)
A bug in distutils means that it tries to export a slightly incorrectly named PyInitU function. The fix in https://bugs.python.org/issue39432 wasn't quite right (`"_name".encode("punycode") != "name".encode("punycode")`) and thus the "unicode_imports" test is failing on Windows 3.8+ when distutils explicitly tries to export a non-existing symbol.
We now create a dummy function with that alternative name so that the export doesn't fail.
|
| |
| |
| |
| | |
and clean up the call chains a little.
|
| |
| |
| |
| | |
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
|
| |
| |
| |
| | |
* Fixed crash on memoryview self-assignment
* Rename memoryview decref function to match what it does
|
| |
| |
| |
| | |
`xml.etree.ElementTree.Element.getiterator()` was deprecated in Python
2.7 & 3.2 and removed in the freshly released Python 3.9.
|
| |
| |
| |
| | |
support both, to be on the safe side.
|
| |
| |
| | |
Specifically this allows public packed structs but may also allow other public declarations that require small amounts of utility code.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In C++ mode, structs can contain C++ classes. Therefore structs
should have their destructors called to ensure any class
contained is also destructed.
Also, a bit more thorough about ensuring constructor is generated where necessary.
Closes GH-3226.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 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
|