Closed dshivashankar1994 closed 7 months ago
I cannot reproduce, did you by any chance update something else, or use it in different environment where some things might have been cached ?
I added a test in https://github.com/deshaw/pyflyby/pull/282, let see if it fails only on some platforms.
I also dug into CPython history, the really strange things is that 'get_filename'
has been removed from FrozenImporter in Python 2.5, so quite a while ago,
Has not been touched in quite a while:
And when stepping through the code, seem to access SourceLoader
instead of FrozenImporter
, and it is likely you have a custom hook or environement.
I'm guessing #283 will prevent the crash, but I'd still like to understand the cause to have a proper fix.
I cannot reproduce, did you by any chance update something else, or use it in different environment where some things might have been cached ?
Right. Missed to mention that the issue happens in py3.11. Probably https://github.com/deshaw/pyflyby/issues/280 could have helped us
Also, I tried quickly verifying the commit. The issue still persists
Ok, yes, I can reproduce on 3.11.
5ec2d569a920b74db658bc84f1990ce1743be103 seem to be the first failing commit. I'll do a different fix.
@Carreau The issue still persists in the latest version as well
In [2]: code = """
...:
...: from os import *
...: getcwd()
...: """
In [3]: replace_star_imports(code)
[PYFLYBY] None: couldn't import 'os' to enumerate exports, leaving unchanged: 'from os import *'. WrappedAttributeError: type object 'FrozenImporter' has no attribute 'get_filename'
Out[3]: PythonBlock('\n\nfrom os import *\ngetcwd()\n')
Can you please check ? Its in python 3.11
replace_star_imports is broken in latest version 1.8.8
Can this be fixed on priority ? (cc: @quarl )