Skip to content

Fix detection of builtins on PyPy 3.9 #1562

@DanielNoord

Description

@DanielNoord

PyPy 3.9 is broken as we can't detect their builtins module. We use the __spec__ attribute, but that is no longer set on that version. Difference in output is:

import sys

print(sys.modules["builtins"].__spec__)
python --version
Python 3.8.12python test.py
ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>)python --version
Python 3.9.6python test.py
ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>, origin='built-in')python --version
Python 3.8.12 (9ef55f6fc369, Oct 25 2021, 05:10:01)
[PyPy 7.3.7 with GCC Apple LLVM 13.0.0 (clang-1300.0.29.3)]python test.py
ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>, origin='built-in')python --version
Python 3.9.12 (05fbe3aa5b0845e6c37239768aa455451aa5faba, Mar 29 2022, 09:54:47)
[PyPy 7.3.9 with GCC Apple LLVM 13.0.0 (clang-1300.0.29.30)]python test.py
None

I have reported this against them, but their response was basically that we should try and find a way to detect builtins in another way as the fact that it worked on 3.8 was not by design but more by chance.
I haven't looked into a possible solution, but just wanted to track this issue here as well.

See:
https://foss.heptapod.net/pypy/pypy/-/issues/3736#note_184637

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions