summaryrefslogtreecommitdiffstats
path: root/Lib/test/_testcppext.cpp
Commit message (Collapse)AuthorAgeFilesLines
* gh-94731: Revert to C-style casts for _Py_CAST (GH-94782) (#94849)Miss Islington (bot)2022-07-151-3/+73
| | | | | Co-authored-by: da-woods <dw-git@d-woods.co.uk> (cherry picked from commit 6cbb57f62d345d7a5d6aeb1b3b5d37a845344d5e)
* gh-94751: Install, import and run the test C++ extension (MVP) (GH-94754) ↵Miss Islington (bot)2022-07-131-0/+14
| | | | | | | | | | | | | (#94780) This is a quick-and-dirty way to run the C++ tests. It can definitely be improved in the future, but it should fail when things go wrong. - Run test functions on import (yes, this can definitely be improved) - Fudge setuptools metadata (name & version) to make the extension installable - Install and import the extension in test_cppext (cherry picked from commit ec5db539b9df99c8b96149768dc2e8598dce2afa) Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-91321: Fix compatibility with C++ older than C++11 (#93784) (#93802)Victor Stinner2022-06-141-16/+30
| | | | | | | | | | | * Fix the compatibility of the Python C API with C++ older than C++11. * _Py_NULL is only defined as nullptr on C++11 and newer. (cherry picked from commit 4caf5c2753f1aa28d6f4bc1aa377975fd2a62331) * test_cppext now builds the C++ extension with setuptools. * Add @test.support.requires_venv_with_pip. (cherry picked from commit ca0cc9c433830e14714a5cc93fb4e7254da3dd76)
* gh-93442: Add test for _Py_CAST(nullptr). (gh-93505) (gh-93509)Miss Islington (bot)2022-06-051-0/+3
| | | | | | | (cherry picked from commit 713eb184b50f2b8b138fb01187ee32fa29a815c9) Co-authored-by: Neil Schemenauer <nas-github@arctrix.com> Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
* gh-93442: Make C++ version of _Py_CAST work with 0/NULL. (GH-93500) (gh-93507)Miss Islington (bot)2022-06-051-0/+4
| | | | | | | | | | | | | | | | | Add C++ overloads for _Py_CAST_impl() to handle 0/NULL. This will allow C++ extensions that pass 0 or NULL to macros using _Py_CAST() to continue to compile. Without this, you get an error like: invalid ‘static_cast’ from type ‘int’ to type ‘_object*’ The modern way to use a NULL value in C++ is to use nullptr. However, we want to not break extensions that do things the old way. Co-authored-by: serge-sans-paille (cherry picked from commit 8bcc3fa3453e28511d04eaa0aa7d8e1a3495d518) Co-authored-by: Neil Schemenauer <nas-github@arctrix.com> Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
* gh-92898: Enhance _testcppext test on cast to PyObject* (GH-93111)Miss Islington (bot)2022-05-261-11/+31
| | | | | | | * Add StrongRef class. * Rename and reformat functions of the _Py_CAST() implementation. (cherry picked from commit 20d30ba2ccf9182e4f08db112f428c909148a40b) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.11] GH-92898: Make _Py_Cast C++ version compatible with cast operator ↵Dong-hee Na2022-05-211-0/+9
| | | | (gh-92951) (gh-93049)
* gh-89653: PEP 670: Fix PyUnicode_READ() cast (GH-92872)Miss Islington (bot)2022-05-171-0/+31
| | | | | | | _Py_CAST() cannot be used with a constant type: use _Py_STATIC_CAST() instead. (cherry picked from commit e6fd7992a92879103215b3e9f218fe07212af9b1) Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-91321: Add _Py_NULL macro (#92253)Victor Stinner2022-05-031-4/+4
| | | | | | | | Fix C++ compiler warnings: "zero as null pointer constant" (clang -Wzero-as-null-pointer-constant). * Add the _Py_NULL macro used by static inline functions to use nullptr in C++. * Replace NULL with nullptr in _testcppext.cpp.
* gh-92135: Fix _Py_reinterpret_cast() for const (#92138)Victor Stinner2022-05-021-0/+31
| | | | | | | | | | Fix C++ compiler warnings on cast macros, like _PyObject_CAST(), when casting a constant expression to a non constant type: use const_cast<> in C++. * In C++, Py_SAFE_DOWNCAST() now uses static_cast<> rather than reinterpret_cast<>. * Add tests to the _testcppext C++ extension. * test_cppext no longer captures stdout in verbose mode.
* gh-91321: Add _testcppext C++ extension (#32175)Victor Stinner2022-05-021-0/+62
Build a basic C++ test extension to check that the Python C API is compatible with C++ and does not emit C++ compiler warnings. * Add Modules/_testcppext.cpp: C++ extension * Add Lib/test/test_cppext.py: test building the C++ extension.