FlorianRhiem / pyGLFW

Python bindings for GLFW
MIT License
232 stars 36 forks source link

Prevent error when running in debug mode in vscode #76

Closed almarklein closed 8 months ago

almarklein commented 8 months ago

When running code with "run and debug" in VSCode, it fails in a particularly strange way when the code imports glfw. It somehow fails on the raw_input not existing.

This is on Mac, have not tested on other platforms yet.

The error is most likely caused by some weird interaction between debugpy (the vscode python debugger) and subprocessing. I strongly suspect this can be regarded as a bug in debugpy, but tracing down that bug is much harder than fixing this particular case 😄

This simply assumes Python3 and falls back to the Python2 variant if it fails, instead of the other way around.

FlorianRhiem commented 8 months ago

Hey @almarklein, thank you for the pull request!

You're right that it's easier to fix the issue here than to track down the bug, however I don't think the fix you propose is ideal. input exists in Python 2 as an equivalent of calling eval(raw_input(prompt)), which is why raw_input is used in Python 2.

Instead of using try/except to check for a NameError, I have implemented a sys.version_info-Check in 1e96d7de5bf99a91d5025fe5d71c0b657da109ab. Can you verify that the VSCode issue does not occur with that branch? If so I'll release a version with that fix.

almarklein commented 8 months ago

Ooh, nice catch, I was not aware of input existing but being something else in py2. I can confirm that your patch using sys.version_info works 👍

FlorianRhiem commented 8 months ago

I've merged that branch into master and released version 2.6.5. Thanks again for reporting this!

almarklein commented 7 months ago

Thanks for the quick response!