Content-Length: 264246 | pFad | https://github.com/python/cpython/issues/132737

44 cProfile cannot run code that pickles objects defined in __main__ · Issue #132737 · python/cpython · GitHub
Skip to content

cProfile cannot run code that pickles objects defined in __main__ #132737

@aneeshdurg

Description

@aneeshdurg

Bug report

Bug description:

import pickle
import sys
from dataclasses import dataclass, field


@dataclass
class State:
    x: list[int] = field(default_factory=list)

print(pickle.dumps(State([0])))

The following code will run successfully on it's own, but will fail if run with cProfile, with the message that __main__.State could not be found by.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/132737

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy