Skip to content

Commit

Permalink
Do not use cffi on Windows with Python 3.12+
Browse files Browse the repository at this point in the history
  • Loading branch information
Legrandin committed Sep 13, 2023
1 parent fe24003 commit 2d3c273
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Crypto/Util/_raw_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ def address_of(self):
if '__pypy__' not in sys.builtin_module_names and sys.flags.optimize == 2:
raise ImportError("CFFI with optimize=2 fails due to pycparser bug.")

# cffi still uses PyUnicode_GetSize, which was removed in Python 3.12
# thus leading to a crash on cffi.dlopen()
# See https://groups.google.com/u/1/g/python-cffi/c/oZkOIZ_zi5k
if sys.version_info >= (3, 12) and os.name == "nt":
raise ImportError("CFFI is not compatible with Python 3.12 on Windows")

from cffi import FFI

ffi = FFI()
Expand Down

0 comments on commit 2d3c273

Please sign in to comment.