Message410640
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. |
|
Date |
User |
Action |
Args |
2022-01-15 10:57:45 | Spencer Brown | set | recipients:
+ Spencer Brown, posita |
2022-01-15 10:57:45 | Spencer Brown | set | messageid: <1642244265.0.0.280361391634.issue46133@roundup.psfhosted.org> |
2022-01-15 10:57:44 | Spencer Brown | link | issue46133 messages |
2022-01-15 10:57:44 | Spencer Brown | create | |
|