Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for python3.12 #323

Closed
tacaswell opened this issue Oct 29, 2022 · 3 comments
Closed

support for python3.12 #323

tacaswell opened this issue Oct 29, 2022 · 3 comments

Comments

@tacaswell
Copy link
Contributor

python/cpython#96510 de-coupled the Python and C level recursion limits which renamed some internal names. The following patch fixes the compilation errors with greenlet on the CPython main branch:

diff --git a/src/greenlet/greenlet_greenlet.hpp b/src/greenlet/greenlet_greenlet.hpp
index 1b8a83f..a036a08 100644
--- a/src/greenlet/greenlet_greenlet.hpp
+++ b/src/greenlet/greenlet_greenlet.hpp
@@ -826,7 +826,7 @@ void PythonState::operator<<(const PyThreadState *const tstate) G_NOEXCEPT
     this->use_tracing = tstate->cframe->use_tracing;
 #endif
 #if GREENLET_PY311
-    this->recursion_depth = tstate->recursion_limit - tstate->recursion_remaining;
+    this->recursion_depth = tstate->py_recursion_limit - tstate->py_recursion_remaining;
     this->current_frame = tstate->cframe->current_frame;
     this->datastack_chunk = tstate->datastack_chunk;
     this->datastack_top = tstate->datastack_top;
@@ -862,7 +862,7 @@ void PythonState::operator>>(PyThreadState *const tstate) G_NOEXCEPT
     tstate->cframe->use_tracing = this->use_tracing;
 #endif
 #if GREENLET_PY311
-    tstate->recursion_remaining = tstate->recursion_limit - this->recursion_depth;
+    tstate->py_recursion_remaining = tstate->py_recursion_limit - this->recursion_depth;
     tstate->cframe->current_frame = this->current_frame;
     tstate->datastack_chunk = this->datastack_chunk;
     tstate->datastack_top = this->datastack_top;
@@ -891,7 +891,7 @@ void PythonState::set_initial_state(const PyThreadState* const tstate) G_NOEXCEP
 {
     this->_top_frame = nullptr;
 #if GREENLET_PY311
-    this->recursion_depth = tstate->recursion_limit - tstate->recursion_remaining;
+    this->recursion_depth = tstate->py_recursion_limit - tstate->py_recursion_remaining;
 #else
     this->recursion_depth = tstate->recursion_depth;
 #endif

however does not do any of the version gating needed to work on a released version of CPython.

@mdboom
Copy link
Contributor

mdboom commented Nov 4, 2022

@tacaswell: I assume you don't mind if I take your patch and add the version guards to make it into a full pull request? (This is also breaking pyperformance atm).

@tacaswell
Copy link
Contributor Author

@mdboom nope, not at all!

@amotl
Copy link
Contributor

amotl commented Nov 15, 2022

Also seeing this at https://github.com/isarengineering/SecPi/actions/runs/3466304638/jobs/5789990791#step:9:442. Thank you already for submitting #327, @mdboom!

mdboom pushed a commit to mdboom/greenlet that referenced this issue Apr 27, 2023
jamadden added a commit that referenced this issue Jun 20, 2023
netbsd-srcmastr referenced this issue in NetBSD/pkgsrc Oct 29, 2023
Switch to wheel.mk.

3.0.1 (2023-10-25)
==================

- Fix a potential crash on Python 3.8 at interpreter shutdown time.
  This was a regression from earlier 3.0.x releases. Reported by Matt
  Wozniski in `issue 376 <https://github.com/python-greenlet/greenlet/issues/376>`_.



3.0.0 (2023-10-02)
==================

- No changes from 3.0rc3 aside from the version number.


3.0.0rc3 (2023-09-12)
=====================

- Fix an intermittent error during process termination on some
  platforms (GCC/Linux/libstdc++).


3.0.0rc2 (2023-09-09)
=====================

- Fix some potential bugs (assertion failures and memory leaks) in
  previously-untested error handling code. In some cases, this means
  that the process will execute a controlled ``abort()`` after severe
  trouble when previously the process might have continued for some
  time with a corrupt state. It is unlikely those errors occurred in
  practice.
- Fix some assertion errors and potential bugs with re-entrant
  switches.
- Fix a potential crash when certain compilers compile greenlet with
  high levels of optimization. The symptom would be that switching to
  a greenlet for the first time immediately crashes.
- Fix a potential crash when the callable object passed to the
  greenlet constructor (or set as the ``greenlet.run`` attribute) has
  a destructor attached to it that switches. Typically, triggering
  this issue would require an unlikely subclass of
  ``greenlet.greenlet``.
- Python 3.11+: Fix rare switching errors that could occur when a
  garbage collection was triggered during the middle of a switch, and
  Python-level code in ``__del__`` or weakref callbacks switched to a
  different greenlet and ultimately switched back to the original
  greenlet. This often manifested as a ``SystemError``: "switch
  returned NULL without an exception set."

For context on the fixes, see `gevent issue #1985
<https://github.com/gevent/gevent/issues/1985>`_.

3.0.0rc1 (2023-09-01)
=====================

- Windows wheels are linked statically to the C runtime in an effort
  to prevent import errors on systems without the correct C runtime
  installed. It's not clear if this will make the situation better or
  worse, so please share your experiences in `issue 346
  <https://github.com/python-greenlet/greenlet/issues/346>`_.

  Note that this only applies to the binary wheels found on PyPI.
  Building greenlet from source defaults to the shared library. Set
  the environment variable ``GREENLET_STATIC_RUNTIME=1`` at build time
  to change that.
- Build binary wheels for Python 3.12 on macOS.
- Fix compiling greenlet on a debug build of CPython 3.12. There is
  `one known issue
  <https://github.com/python-greenlet/greenlet/issues/368>`_ that
  leads to an interpreter crash on debug builds.
- Python 3.12: Fix walking the frame stack of suspended greenlets.
  Previously accessing ``glet.gr_frame.f_back`` would crash due to
  `changes in CPython's undocumented internal frame handling <https://github.com/python/cpython/commit/1e197e63e21f77b102ff2601a549dda4b6439455>`_.

Platforms
---------
- Now, greenlet *may* compile and work on Windows ARM64 using
  llvm-mingw, but this is untested and unsupported. See `PR
  <https://github.com/python-greenlet/greenlet/pull/224>`_ by Adrian
  Vladu.
- Now, greenlet *may* compile and work on LoongArch64 Linux systems,
  but this is untested and unsupported. See `PR 257
  <https://github.com/python-greenlet/greenlet/pull/257/files>`_ by merore.

Known Issues
------------

- There may be (very) subtle issues with tracing on Python 3.12, which
  has redesigned the entire tracing infrastructure.

3.0.0a1 (2023-06-21)
====================

- Build binary wheels for S390x Linux. See `PR 358
  <https://github.com/python-greenlet/greenlet/pull/358>`_ from Steven
  Silvester.
- Fix a rare crash on shutdown seen in uWSGI deployments. See `issue
  330 <https://github.com/python-greenlet/greenlet/issues/330>`_ and `PR 356
  <https://github.com/python-greenlet/greenlet/pull/356>`_ from Andrew
  Wason.
- Make the platform-specific low-level C/assembly snippets stop using
  the ``register`` storage class. Newer versions of standards remove
  this storage class, and it has been generally ignored by many
  compilers for some time. See `PR 347
  <https://github.com/python-greenlet/greenlet/pull/347>`_ from Khem
  Raj.
- Add initial support for Python 3.12. See `issue
  <https://github.com/python-greenlet/greenlet/issues/323>`_ and `PR
  <https://github.com/python-greenlet/greenlet/pull/327>`_; thanks go
  to (at least) Michael Droettboom, Andreas Motl, Thomas A Caswell,
  raphaelauv, Hugo van Kemenade, Mark Shannon, and Petr Viktorin.
- Remove support for end-of-life Python versions, including Python
  2.7, Python 3.5 and Python 3.6.
- Require a compiler that supports ``noinline`` directives. See
  `issue 271
  <https://github.com/python-greenlet/greenlet/issues/266>`_.
- Require a compiler that supports C++11.
Silvanoc added a commit to linkml/prefixmaps that referenced this issue Nov 6, 2023
Upgrading greenlet version to have support for Python v3.12.
See here for more information: python-greenlet/greenlet#323

Closes #45

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Silvanoc added a commit to linkml/prefixmaps that referenced this issue Nov 9, 2023
Upgrading greenlet version to have support for Python v3.12.
See here for more information: python-greenlet/greenlet#323

Closes #45

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Silvanoc added a commit to linkml/prefixmaps that referenced this issue Nov 9, 2023
Upgrading greenlet version to have support for Python v3.12.
See here for more information: python-greenlet/greenlet#323

Closes #45

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Silvanoc added a commit to linkml/prefixmaps that referenced this issue Nov 9, 2023
Upgrading greenlet version to have support for Python v3.12.
See here for more information: python-greenlet/greenlet#323

Closes #45

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Silvanoc added a commit to linkml/prefixmaps that referenced this issue Nov 9, 2023
Upgrading greenlet and pyYAML versions to have support for Python v3.12.
See here for more information: python-greenlet/greenlet#323

Closes #45

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Silvanoc added a commit to linkml/prefixmaps that referenced this issue Nov 9, 2023
Upgrading greenlet, pyYAML and typing_extensions versions to have support for
Python v3.12.
See here for more information: python-greenlet/greenlet#323

Closes #45

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Silvanoc added a commit to linkml/prefixmaps that referenced this issue Nov 9, 2023
Upgrading greenlet, pyYAML and typing_extensions versions to have support for
Python v3.12.
See here for more information: python-greenlet/greenlet#323

Closes #45

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants