{{ message }}
gh-106242: Fix path truncation in normpath - #106816
Merged
Merged
Conversation
zooba
reviewed
Jul 17, 2023
zooba
left a comment
Member
There was a problem hiding this comment.
LGTM with the minor name convention update
eryksun
reviewed
Jul 17, 2023
Member
zooba
reviewed
Aug 14, 2023
…1HMym.rst Co-authored-by: Steve Dower <steve.dower@microsoft.com>
zooba
approved these changes
Aug 14, 2023
Contributor
Contributor
Contributor
|
Sorry, @finnagin and @zooba, I could not cleanly backport this to |
Contributor
|
Sorry, @finnagin and @zooba, I could not cleanly backport this to |
|
GH-107981 is a backport of this pull request to the 3.12 branch. |
zooba
pushed a commit
to zooba/cpython
that referenced
this pull request
Aug 15, 2023
zooba
pushed a commit
to zooba/cpython
that referenced
this pull request
Aug 15, 2023
ambv
pushed a commit
that referenced
this pull request
Aug 15, 2023
iritkatriel
pushed a commit
to iritkatriel/cpython
that referenced
this pull request
Aug 16, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Following the suggestion from this comment in the original issue this PR adds a new function
_Py_normpathAndSizewhich behaves like_Py_normpathbut also takes a pointer which it will use to store the length of the final normalized path. This new function is then used inos__path_normpath_implto pass the above mentioned length intoPyUnicode_FromWideCharinstead of -1.Additionally, this adds a test to check that normpath is not truncating paths containing a null character as well as changes
test_addpackage_import_bad_pth_fileintest_site.pywhich was using a null character to make a bad path, specifically it was using the string'abc\x00def'. The problem is that before this change this was being truncated for parts of the test so the string it was actually using in those parts was'abc'. Upon making the normpath changes it started throwing the errorValueError: embedded null characterso I changed the test to use'abc<>$$**:://def'instead.