◐ Shell
clean mode source ↗

gh-60115: Support frozen modules for linecache.getline() by gaogaotiantian · Pull Request #131638 · python/cpython

When we try to get source lines for frozen modules with linecache.getlines(), it will be rejected because frozen modules have file names starting with <. However, we can deal with that case, if we have module_globals - we can read __file__ in module_globals to get the real file and read it.

pdb suffers from it when debugging frozen modules - list deals with it but stack entry and ll does not. I could fix it in pdb, but I think linecache could benefit from this change so it helps all users. This is also a pretty straighforward change, just convert the filename passed in to the actual file name and the rest is the same.