Skip to content
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

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

Open
Estrangeling opened this issue Feb 23, 2025 · 0 comments
Open

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

Estrangeling opened this issue Feb 23, 2025 · 0 comments

Comments

@Estrangeling
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant