Skip to content

__lazy_import__ errors in test_xpickle #144878

Description

@smontanaro

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

Activity

  1. hugovk commented on Feb 16, 2026

    @hugovk
    Member

    First thought: it might be worth make clean and rebuilding the CPython source?

    The lazy imports PEP was merged to main last week, so that needs to be rebuilt: #142351

  2. smontanaro commented on Feb 16, 2026

    @smontanaro
    ContributorAuthor

    I've already done that. When seeing anything which might mess up make (dependencies aren't perfect) I typically start with git clean -fdx. I'll try again later (not at home right now) just to make sure I'm not misremembering.

  3. added
    testsTests in the Lib/test dir
    pendingThe issue will be closed if no feedback is provided
    on Feb 16, 2026
  4. smontanaro commented on Feb 16, 2026

    @smontanaro
    ContributorAuthor

    Just to confirm, on both Linux and Mac (Git checkout up-to-date) I executed:

    git clean -fdx && ./configure && nice make test TESTOPTS=-ucpu,largefile,extralargefile,xpickle
    ./python.exe -m test -v -uxpickle test_xpickle
    

    (just ./python on Linux)

    and got the same slew of tracebacks when run as part of make test or standalone.

    Is it possible the failure stems from lazy imports not being suitably skipped when running xpickle tests on older versions of Python?

  5. hugovk commented on Feb 16, 2026

    @hugovk
    Member

    You should only run the tests in main on CPython built from main.

    Older Python versions should not run against the tests in main because they don't support the new things that are only in main, such as builtins.__lazy_import__.

  6. smontanaro commented on Feb 16, 2026

    @smontanaro
    ContributorAuthor

    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.

  7. hugovk commented on Feb 16, 2026

    @hugovk
    Member

    Aha, right, I can reproduce (on macOS) it when running either ./python.exe Lib/test/test_xpickle.py or:

    ❯ ./python.exe -m test test_xpickle -u xpickle
    Raised RLIMIT_NOFILE: 256 -> 1024
    Using random seed: 1869269231
    0:00:00 load avg: 5.00 Run 1 test sequentially in a single process
    0:00:00 load avg: 5.00 [1/1] test_xpickle
    test test_xpickle failed -- multiple errors occurred; run in verbose mode for details
    0:00:16 load avg: 4.41 [1/1/1] test_xpickle failed (126 errors)
    
    == Tests result: FAILURE ==
    
    1 test failed:
        test_xpickle
    
    Total duration: 16.7 sec
    Total tests: run=1,456 skipped=98
    Total test files: run=1/1 failed=1
    Result: FAILURE

    By default we don't test with the xpickle resource:

        xpickle -   Test pickle and _pickle against Python 3.6, 3.7, 3.8
                    and 3.9 to test backwards compatibility. These tests
                    may take very long to complete.
    

    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.

  8. removed
    pendingThe issue will be closed if no feedback is provided
    on Feb 16, 2026
  9. added a commit that references this issue on Feb 16, 2026
  10. pablogsal commented on Feb 16, 2026

    @pablogsal
    Member

    #144889 should do the trick

  11. pablogsal commented on Feb 16, 2026

    @pablogsal
    Member

    Thanks @smontanaro for the report!

  12. added a commit that references this issue on Feb 16, 2026
  13. added a commit that references this issue on Feb 28, 2026
  14. added a commit that references this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions