Skip to content

Commit bed8cb6

Browse files
committed
Fix types.CodeType serialization for PyPy3.11
Enable the new `inspect.signature(types.CodeType)` code path for PyPy3.11 and newer. Add a workaround to skip the `magic` parameter that does not seem to be exposed (or needed). With these changes, the serialization tests pass on PyPy3.11 7.3.19, as well as most of the test suite. Fixes #933 Signed-off-by: Michał Górny <[email protected]>
1 parent 0d5488f commit bed8cb6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ipyparallel/serialize/codeutil.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ def code_ctor(*args):
2626
"codestring": "code",
2727
"constants": "consts",
2828
}
29+
# inspect.signature(types.CodeType) was broken in older PyPy3.10 releases
30+
_use_inspect_signature_ver = (3, 11) if hasattr(sys, "pypy_version_info") else (3, 10)
2931
# pass every supported arg to the code constructor
3032
# this should be more forward-compatible
3133
# (broken on pypy: https://github.com/ipython/ipyparallel/issues/845)
32-
if sys.version_info >= (3, 10) and not hasattr(sys, "pypy_version_info"):
34+
if sys.version_info >= _use_inspect_signature_ver:
3335
_code_attr_names = tuple(
3436
_code_attr_map.get(name, name)
3537
for name, param in inspect.signature(types.CodeType).parameters.items()
36-
if param.POSITIONAL_ONLY or param.POSITIONAL_OR_KEYWORD
38+
if (param.POSITIONAL_ONLY or param.POSITIONAL_OR_KEYWORD)
39+
and not (hasattr(sys, "pypy_version_info") and name == "magic")
3740
)
3841
else:
3942
# can't inspect types.CodeType on Python < 3.10

0 commit comments

Comments
 (0)