Skip to content

Bug: can't pickle custom class in PtIPython on Windows 11 #602

@Estrangeling

Description

@Estrangeling

I have never been able to pickle custom classes in PtIPython on Windows.

Minimal reproducible example:

import pickle
from collections import namedtuple

Unicode_Point = namedtuple(
    "Unicode_Point",
    (
        "Code_Point",
        "Name",
        "Script",
        "Category",
        "Combining",
        "Bidi",
        "Decomposition",
        "Numeric",
        "Idib",
        "Upper",
        "Lower",
        "Title",
    ),
)

pickle.dumps(Unicode_Point(Code_Point=926, Name='GREEK CAPITAL LETTER XI', Script='Greek', Category='Lu', Combining='0', Bidi='L', Decomposition='', Numeric=None, Idib='N', Upper=None, Lower=958, Title=None))

On Windows 11, the above code runs fine on both CPython 3.12.6 and IPython 8.27.0 (on CPython 3.12.6) and generates the following:

b'\x80\x04\x95b\x00\x00\x00\x00\x00\x00\x00\x8c\x08__main__\x94\x8c\rUnicode_Point\x94\x93\x94(M\x9e\x03\x8c\x17GREEK CAPITAL LETTER XI\x94\x8c\x05Greek\x94\x8c\x02Lu\x94\x8c\x010\x94\x8c\x01L\x94\x8c\x00\x94N\x8c\x01N\x94NM\xbe\x03Nt\x94\x81\x94.'

But on PtIPython 1.0.1 PtPython 3.0.29 with the same IPython environment, the following error is raised instead:

PicklingError: Can't pickle <class '__main__.Unicode_Point'>: attribute lookup Unicode_Point on __main__ failed

Please fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions