Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug in InteractiveConsole /pickle #53189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fabioz mannequin opened this issue Jun 8, 2010 · 8 comments
Closed

Bug in InteractiveConsole /pickle #53189

fabioz mannequin opened this issue Jun 8, 2010 · 8 comments
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes docs Documentation in the Doc dir

Comments

@fabioz
Copy link
Mannequin

fabioz mannequin commented Jun 8, 2010

BPO 8943
Nosy @ncoghlan, @orsenthil, @fabioz, @avassalotti
Files
  • fast_test.py: Code showing the error.
  • interative.py: Another code showing the error
  • backtrace-py3k-8943.txt: preliminary gdb backtrace py3k pickle:save_global
  • issue8943.diff: hg diff Doc/library/code.rst > issue8943.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2010-06-08.16:24:21.604>
    labels = ['3.8', 'type-bug', 'library', '3.9', '3.10']
    title = 'Bug in InteractiveConsole /pickle'
    updated_at = <Date 2020-10-28.14:13:37.445>
    user = 'https://github.com/fabioz'

    bugs.python.org fields:

    activity = <Date 2020-10-28.14:13:37.445>
    actor = 'holdenweb'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2010-06-08.16:24:21.604>
    creator = 'fabioz'
    dependencies = []
    files = ['17589', '19734', '19735', '26917']
    hgrepos = []
    issue_num = 8943
    keywords = ['patch']
    message_count = 7.0
    messages = ['107328', '107905', '108871', '121898', '121899', '121905', '168631']
    nosy_count = 6.0
    nosy_names = ['ncoghlan', 'orsenthil', 'fabioz', 'alexandre.vassalotti', 'iuridiniz', 'mjdorma']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue8943'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    Linked PRs

    @fabioz
    Copy link
    Mannequin Author

    fabioz mannequin commented Jun 8, 2010

    Unable to pickle classes used in the InteractiveConsole. The code attached works in python 2.5 and fails on python 3.1.2.

    @fabioz fabioz mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 8, 2010
    @orsenthil
    Copy link
    Member

    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

    @avassalotti
    Copy link
    Member

    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.

    @iuridiniz
    Copy link
    Mannequin

    iuridiniz mannequin commented Nov 21, 2010

    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

    @iuridiniz
    Copy link
    Mannequin

    iuridiniz mannequin commented Nov 21, 2010

    preliminary gdb backtrace

    @iuridiniz
    Copy link
    Mannequin

    iuridiniz mannequin commented Nov 21, 2010

    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.

    @mjdorma
    Copy link
    Mannequin

    mjdorma mannequin commented Aug 20, 2012

    I'd suggest this is an issue in the doc for the InteractiveInterpreter class.

    Try locals=global() and your problem goes away. (namespace == __main__)...

    @iritkatriel iritkatriel added 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes labels Oct 27, 2020
    @iritkatriel iritkatriel changed the title Bug in InteractiveConsole Bug in InteractiveConsole /pickle Oct 27, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added 3.11 only security fixes 3.12 only security fixes and removed 3.9 only security fixes 3.8 (EOL) end of life labels Mar 1, 2023
    @serhiy-storchaka serhiy-storchaka added docs Documentation in the Doc dir 3.13 bugs and security fixes 3.14 bugs and security fixes and removed type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir 3.11 only security fixes 3.10 only security fixes labels Aug 16, 2024
    serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Aug 16, 2024
    @serhiy-storchaka
    Copy link
    Member

    The current behavior is reasonable. This is rather a documentation issue than a bug in InteractiveInterpreter or pickle.

    We can clarify this explicitly since it is not obvious.

    encukou pushed a commit that referenced this issue May 20, 2025
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 20, 2025
    …ion to pickle (pythonGH-123069)
    
    (cherry picked from commit a31bbc9)
    
    Co-authored-by: Serhiy Storchaka <[email protected]>
    Co-authored-by: Terry Jan Reedy <[email protected]>
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 20, 2025
    …ion to pickle (pythonGH-123069)
    
    (cherry picked from commit a31bbc9)
    
    Co-authored-by: Serhiy Storchaka <[email protected]>
    Co-authored-by: Terry Jan Reedy <[email protected]>
    encukou pushed a commit that referenced this issue May 20, 2025
    …tion to pickle (GH-123069) (GH-134328)
    
    gh-53189: Document peculiarities of InteractiveConsole in relation to pickle (GH-123069)
    
    (cherry picked from commit a31bbc9)
    
    Co-authored-by: Serhiy Storchaka <[email protected]>
    Co-authored-by: Terry Jan Reedy <[email protected]>
    encukou pushed a commit that referenced this issue May 20, 2025
    …tion to pickle (GH-123069) (GH-134329)
    
    gh-53189: Document peculiarities of InteractiveConsole in relation to pickle (GH-123069)
    
    (cherry picked from commit a31bbc9)
    
    Co-authored-by: Serhiy Storchaka <[email protected]>
    Co-authored-by: Terry Jan Reedy <[email protected]>
    @picnixz picnixz closed this as completed May 20, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes docs Documentation in the Doc dir
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants