This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Bug in InteractiveConsole /pickle
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: alexandre.vassalotti, fabioz, iuridiniz, mjdorma, ncoghlan, orsenthil
Priority: normal Keywords: patch

Created on 2010-06-08 16:24 by fabioz, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
fast_test.py fabioz, 2010-06-08 16:24 Code showing the error.
interative.py iuridiniz, 2010-11-21 10:47 Another code showing the error
backtrace-py3k-8943.txt iuridiniz, 2010-11-21 10:48 preliminary gdb backtrace py3k pickle:save_global
issue8943.diff mjdorma, 2012-08-20 07:18 hg diff Doc/library/code.rst > issue8943.diff review
Messages (7)
msg107328 - (view) Author: Fabio Zadrozny (fabioz) * Date: 2010-06-08 16:24
Unable to pickle classes used in the InteractiveConsole. The code attached works in python 2.5 and fails on python 3.1.2.
msg107905 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-06-16 03:19
Yes, the problem is observed in py3k. Pickle module when used via Interactive console is trying to import the class as __console__.ClassName and it is failing to see the __console__ module.

_pickle.PicklingError: Can't pickle <class '__console__.Example'>: import of module '__console__' failed
msg108871 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2010-06-28 21:25
One easy fix for this would be to make InteractiveConsole use the string "__main__" instead of "__console__". But other than that, I don't think we can fix this within pickle.
msg121898 - (view) Author: Iuri Diniz (iuridiniz) Date: 2010-11-21 10:47
Bug stills on branch 
http://svn.python.org/projects/python/branches/py3k 
branch http://svn.python.org/projects/python/branches/release27-maint is OK

doing some gdb on 3.2, I have discovered that the problem occurs when trying to dump global Example from module __console__ on py3k/Modules/_pickle.c:save_global:2536

Python 2.7 never calls save_global (why?)

in annex: an update test
msg121899 - (view) Author: Iuri Diniz (iuridiniz) Date: 2010-11-21 10:48
preliminary gdb backtrace
msg121905 - (view) Author: Iuri Diniz (iuridiniz) Date: 2010-11-21 11:39
Well, this is a pickle problem or a Interactive console problem?

on python 2.7 does not save a type "type" (like Example class is)
2: type->tp_name = 0x58a87c "instance"
2: type->tp_name = 0x590391 "dict"
2: type->tp_name = 0x5943b6 "str"
2: type->tp_name = 0x5943b6 "str"

on python 3.2 does and when saving a type, it tries to save a global.
msg168631 - (view) Author: Michael Dorman (mjdorma) * Date: 2012-08-20 07:18
I'd suggest this is an issue in the doc for the InteractiveInterpreter class. 

Try locals=global() and your problem goes away.  (namespace == __main__)...
History
Date User Action Args
2022-04-11 14:57:02adminsetgithub: 53189
2020-10-28 14:13:37holdenwebsetnosy: - holdenweb
2020-10-27 21:48:47iritkatrielsettitle: Bug in InteractiveConsole -> Bug in InteractiveConsole /pickle
versions: + Python 3.8, Python 3.9, Python 3.10, - Python 3.1, Python 3.2
2012-08-20 08:13:41mjdormasetnosy: + ncoghlan
2012-08-20 07:18:32mjdormasetfiles: + issue8943.diff

nosy: + mjdorma
messages: + msg168631

keywords: + patch
2010-11-21 11:39:10iuridinizsetmessages: + msg121905
2010-11-21 10:48:43iuridinizsetfiles: + backtrace-py3k-8943.txt

messages: + msg121899
2010-11-21 10:47:09iuridinizsetfiles: + interative.py
nosy: + iuridiniz
messages: + msg121898

2010-06-28 21:25:02alexandre.vassalottisetmessages: + msg108871
2010-06-26 12:20:22holdenwebsetnosy: + holdenweb
2010-06-16 03:19:41orsenthilsetversions: + Python 3.2
nosy: + alexandre.vassalotti, orsenthil

messages: + msg107905

stage: needs patch
2010-06-08 16:24:21fabiozcreate