__lazy_import__ errors in test_xpickle #144878
Copy link
Copy link
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
ERROR: test_builtin_functions (test.test_xpickle.CPicklePython314Compat.test_builtin_functions) (name='__lazy_import__', proto=1)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/skip/src/python/cpython/Lib/test/pickletester.py", line 3238, in test_builtin_functions
s = self.dumps(t, proto)
File "/Users/skip/src/python/cpython/Lib/test/test_xpickle.py", line 190, in dumps
return self.send_to_worker(python, data)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "/Users/skip/src/python/cpython/Lib/test/test_xpickle.py", line 172, in send_to_worker
raise exception
AttributeError: module 'builtins' has no attribute '__lazy_import__'test_xpickle seems to be failing with the above traceback for every version it's tested with and for all protocols. I have a bunch of versions available, 2.7 and 3.7-3.14 in addition to main. The above traceback is from my Mac, but I get the same failure on my Linux laptop.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux, macOS
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Activity
hugovk commentedon Feb 16, 2026
First thought: it might be worth
make cleanand rebuilding the CPython source?The lazy imports PEP was merged to
mainlast week, so that needs to be rebuilt: #142351smontanaro commentedon Feb 16, 2026
I've already done that. When seeing anything which might mess up
make(dependencies aren't perfect) I typically start withgit clean -fdx. I'll try again later (not at home right now) just to make sure I'm not misremembering.smontanaro commentedon Feb 16, 2026
Just to confirm, on both Linux and Mac (Git checkout up-to-date) I executed:
(just
./pythonon Linux)and got the same slew of tracebacks when run as part of
make testor standalone.Is it possible the failure stems from lazy imports not being suitably skipped when running
xpickletests on older versions of Python?hugovk commentedon Feb 16, 2026
You should only run the tests in
mainon CPython built frommain.Older Python versions should not run against the tests in
mainbecause they don't support the new things that are only inmain, such asbuiltins.__lazy_import__.smontanaro commentedon Feb 16, 2026
That's how I run it. But it pokes around my machines to find older versions for which to check compatibility. Look at the first line of the traceback. It's failing in something like
...CPicklePython314Compat.... All the other tracebacks are either different protocol numbers 0 thru 5) or different Python combinations. It finds ten different Python versions on my Mac, so that same traceback is spewed sizes of times. The result is the same on Linux, though I have many fewer Python versions, so I get fewer tracebacks.hugovk commentedon Feb 16, 2026
Aha, right, I can reproduce (on macOS) it when running either
./python.exe Lib/test/test_xpickle.pyor:By default we don't test with the
xpickleresource:But it appears we don't have it enabled for either GitHub Actions or buildbots, which seems like a shortcoming.
Anyway, thanks for the report, and ping @DinoV and @pablogsal about this bug.
pythongh-144878: Gate PEP 810 builtins in xpickle compat tests
pablogsal commentedon Feb 16, 2026
#144889 should do the trick
pablogsal commentedon Feb 16, 2026
Thanks @smontanaro for the report!
gh-144878: Gate PEP 810 builtins in xpickle compat tests (#144889)
pythongh-144878: Gate PEP 810 builtins in xpickle compat tests (pytho…
pythongh-144878: Gate PEP 810 builtins in xpickle compat tests (pytho…