-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Open
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The reproducer I found comes from #84376 and it was entirely by chance that I stumbled upon the REPL issue itself. I don't know if it's because we're using multiprocessing
or if it's because the exception is in another thread or process, or if it's again something else.
Python 3.14.0a6+ (heads/main:3b3720f1a26, Apr 1 2025, 10:14:27) [GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing
... q = multiprocessing.Queue()
... try:
... q.put(lambda: None)
... print("Success!")
... except Exception:
... print("Failure")
...
Success!
>>> AttributeError: module '__main__' has no attribute '<lambda>'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/$HOME/lib/python/cpython/Lib/multiprocessing/queues.py", line 262, in _feed
obj = _ForkingPickler.dumps(obj)
File "/$HOME/lib/python/cpython/Lib/multiprocessing/reduction.py", line 51, in dumps
cls(buf, protocol).dump(obj)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^
_pickle.PicklingError: Can't pickle <function <lambda> at 0x7f1410a13a10>: it's not found as __main__.<lambda>
KeyboardInterrupt
>>>
In the old REPL, the traceback is properly shown.
Python 3.14.0a6+ (heads/main:3b3720f1a26, Apr 1 2025, 10:14:27) [GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing
>>> q = multiprocessing.Queue()
>>> try:
... q.put(lambda: None)
... print("Success!")
... except Exception:
... print("Failure")
...
Success!
>>> AttributeError: module '__main__' has no attribute '<lambda>'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/$HOME/lib/python/cpython/Lib/multiprocessing/queues.py", line 262, in _feed
obj = _ForkingPickler.dumps(obj)
File "/$HOME/lib/python/cpython/Lib/multiprocessing/reduction.py", line 51, in dumps
cls(buf, protocol).dump(obj)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^
_pickle.PicklingError: Can't pickle <function <lambda> at 0x7f2119283350>: it's not found as __main__.<lambda>
>>>
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error