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.

Author Spencer Brown
Recipients Spencer Brown, posita
Date 2022-01-15.10:57:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642244265.0.0.280361391634.issue46133@roundup.psfhosted.org>
In-reply-to
Content
There is a solution to this: you can modify the linecache module's cache to add lines under a fake filename, which is the approach attrs takes here:
https://github.com/python-attrs/attrs/blob/9727008fd1e40bc55cdc6aee71e0f61553f33127/src/attr/_make.py#L347
However, there are several downsides. 
- That dict isn't documented or appears in __all__, so it's arguably private.
- The C implementation of traceback printing opens files directly, so this doesn't work there.
- You have to invent a unique filename, and manually remove lines from the cache if the function is later deleted.
This does affect both namedtuple and dataclasses, though it's probably not too important given how straightforward the generated code they produce is.
History
Date User Action Args
2022-01-15 10:57:45Spencer Brownsetrecipients: + Spencer Brown, posita
2022-01-15 10:57:45Spencer Brownsetmessageid: <1642244265.0.0.280361391634.issue46133@roundup.psfhosted.org>
2022-01-15 10:57:44Spencer Brownlinkissue46133 messages
2022-01-15 10:57:44Spencer Browncreate