-
Notifications
You must be signed in to change notification settings - Fork 105
Closed
Labels
Description
Using the bpython REPL when I import py
I get the following error:
>>> import py
Traceback (most recent call last):
File "<input>", line 1, in <module>
import py
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
File "/home/ceccoemi/Development/git/bpython/bpython/curtsiesfrontend/repl.py", line
243, in load_module
module = self.loader.load_module(name)
File "/home/ceccoemi/Development/pyvenvs/venv3.7/lib/python3.7/site-packages/py/__in
it__.py", line 153, in <module>
'Syslog' : '._log.log:Syslog',
File "/home/ceccoemi/Development/pyvenvs/venv3.7/lib/python3.7/site-packages/py/_ven
dored_packages/apipkg.py", line 63, in initpkg
for module in sys.modules.values():
RuntimeError: dictionary changed size during iteration
In the py/_vendored_packages/apikpg.py
module there is a loop over a dictionary that breaks the import mechanism in bpython using Python 3:
py/py/_vendored_packages/apipkg.py
Lines 61 to 65 in 60f50bd
# eagerload in bypthon to avoid their monkeypatching breaking packages | |
if 'bpython' in sys.modules or eager: | |
for module in sys.modules.values(): | |
if isinstance(module, ApiModule): | |
module.__dict__ |
The fix for this bug is very simple: simply convert the iterable sys.modules.values()
in a list with list(sys.modules.values())
This bug was already fixed in the apipkg package with this pull request.
I didn't understand how you manage the apipkg
module in this package, but I'd like to have this bug fixed because it makes pytest
and py
unusable in bpython
.
I'm available to work on this changes, so please let me know.