Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a key from a dictionary while iterating over it raises an exception in Python 3 #1998

Closed
tacchinotacchi opened this issue Dec 16, 2019 · 2 comments · May be fixed by arsdragonfly/node-gyp#1

Comments

@tacchinotacchi
Copy link

tacchinotacchi commented Dec 16, 2019

The problem is at line

# Now drop all the abstract ones.

In Python 3, it's not allowed to delete a key from a dictionary while iterating over it.
Example while trying to npm install --save gl:

> gl@4.4.0 install /home/alex/Documents/code/editor-renderer/node_modules/gl
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=13.3.0 runtime=node arch=x64 libc= platform=linux)
Traceback (most recent call last):
  File "/usr/lib/node_modules/node-gyp/gyp/gyp_main.py", line 50, in <module>
    sys.exit(gyp.script_main())
  File "/usr/lib/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 554, in script_main
    return main(sys.argv[1:])
  File "/usr/lib/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 547, in main
    return gyp_main(args)
  File "/usr/lib/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 520, in gyp_main
    [generator, flat_list, targets, data] = Load(
  File "/usr/lib/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 136, in Load
    result = gyp.input.Load(build_files, default_variables, includes[:],
  File "/usr/lib/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2868, in Load
    SetUpConfigurations(target, target_dict)
  File "/usr/lib/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2289, in SetUpConfigurations
    for configuration in target_dict['configurations'].keys():
RuntimeError: dictionary changed size during iteration
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:219:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
gyp ERR! System Linux 4.19.88-1-MANJARO
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/alex/Documents/code/editor-renderer/node_modules/gl
gyp ERR! node -v v13.3.0
gyp ERR! node-gyp -v v6.0.1
gyp ERR! not ok 
npm WARN editor-renderer@0.0.1 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gl@4.4.0 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the gl@4.4.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/alex/.npm/_logs/2019-12-16T14_48_26_168Z-debug.log
@cclauss
Copy link
Contributor

cclauss commented Dec 16, 2019

Wrap the dict inside a list().

@arsdragonfly
Copy link

running into the same issue when npm install screeps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants