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

Normalize debugger temp file paths on Windows #838

Merged
merged 3 commits into from
Jan 10, 2022

Conversation

kycutler
Copy link
Contributor

@kycutler kycutler commented Jan 7, 2022

Fixes #784

@blink1073 blink1073 added the bug label Jan 10, 2022
Copy link
Contributor

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than adding a dependency, we could use a ctypes version of this function call: https://mail.python.org/pipermail/python-win32/2008-January/006642.html

@kycutler
Copy link
Contributor Author

@blink1073 thanks for the review! Updated to use ctypes and remove the direct dependency on pywin32. The ctypes code is loosely based on the similar handling in debugpy here.

return filename

# test that it works
_convert_to_long_pathname(__file__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add this as a test in test_debugger.py instead of inline here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add it there to test as well. The intent with adding it here is to catch any errors with e.g. DLL references early so we can fail just once up front and fallback to not normalizing, rather than failing every time we get the path below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test, and clarified the inline comment. Note that debugpy (or rather pydevd) does a similar runtime check here.

Copy link
Contributor

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

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

Successfully merging this pull request may close these issues.

Temp file paths can be inconsistent with debugpy
2 participants