Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d1fe8fa
added _Py_normpathAndSize
finnagin Jul 3, 2023
726da04
Merge remote-tracking branch 'upstream/main' into 106242
finnagin Jul 3, 2023
8cab42c
PyAPI_FUNC -> extern
finnagin Jul 5, 2023
82a9d36
remove prinfs
finnagin Jul 5, 2023
6c18bf8
fix length calculation
finnagin Jul 5, 2023
c90249d
length -> norm_size, fix begining null char case
finnagin Jul 6, 2023
8e1f1ea
fix norm_size calculation
finnagin Jul 6, 2023
3003891
add test cases
finnagin Jul 6, 2023
2fcae77
Merge remote-tracking branch 'upstream/main' into 106242
finnagin Jul 6, 2023
30fa3a4
move tests to test_genericpath.py
finnagin Jul 6, 2023
f0afe44
handle edge cases
finnagin Jul 6, 2023
6412901
decrement p2 when == minp2 & update minp2 handling with leading ./
finnagin Jul 13, 2023
78192de
change test case to no longer include null character
finnagin Jul 13, 2023
199abac
Merge remote-tracking branch 'upstream/main' into 106242
finnagin Jul 13, 2023
cbe57c4
Merge branch 'python:main' into 106242
finnagin Jul 13, 2023
4b9de2c
Add norm_size variable description, add normpath description
finnagin Jul 13, 2023
f1731f1
update normpathAndSize description
finnagin Jul 13, 2023
d7f7045
norm_size->normsize
finnagin Jul 16, 2023
184fde9
Merge remote-tracking branch 'upstream/main' into 106242
finnagin Jul 16, 2023
9e0d52a
remove trailing whitespace
finnagin Jul 16, 2023
3815967
Merge remote-tracking branch 'upstream/main' into 106242
finnagin Jul 16, 2023
d9d78cc
Merge branch 'python:main' into 106242
finnagin Jul 16, 2023
3ef9e3b
_Py_normpathAndSize -> _Py_normpath_and_size
finnagin Jul 17, 2023
c885d13
revert test_addpackage_import_bad_pth_file change
finnagin Jul 17, 2023
d896d45
merge upstream/main, fix merge conflicts
finnagin Aug 14, 2023
0959e2b
📜🤖 Added by blurb_it.
blurb-it[bot] Aug 14, 2023
aecae84
Update Misc/NEWS.d/next/Library/2023-08-14-23-11-11.gh-issue-106242.7…
finnagin Aug 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
added _Py_normpathAndSize
  • Loading branch information
finnagin committed Jul 3, 2023
commit d1fe8fade29a3bf60a2b57af83f18e94f1fd5b48
1 change: 1 addition & 0 deletions Include/internal/pycore_fileutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ extern int _Py_add_relfile(wchar_t *dirname,
size_t bufsize);
extern size_t _Py_find_basename(const wchar_t *filename);
PyAPI_FUNC(wchar_t *) _Py_normpath(wchar_t *path, Py_ssize_t size);
PyAPI_FUNC(wchar_t *) _Py_normpathAndSize(wchar_t *path, Py_ssize_t size, Py_ssize_t *length);

// The Windows Games API family does not provide these functions
// so provide our own implementations. Remove them in case they get added
Expand Down
6 changes: 5 additions & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5275,7 +5275,11 @@ os__path_normpath_impl(PyObject *module, PyObject *path)
if (!buffer) {
return NULL;
}
PyObject *result = PyUnicode_FromWideChar(_Py_normpath(buffer, len), -1);
Py_ssize_t end_len;
wchar_t *norm_path = _Py_normpathAndSize(buffer, len, &end_len);
printf("len: %d\n", len);
printf("end_len: %d\n", end_len);
PyObject *result = PyUnicode_FromWideChar(norm_path, -1);
PyMem_Free(buffer);
return result;
}
Expand Down
12 changes: 11 additions & 1 deletion Python/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2379,7 +2379,7 @@ _Py_find_basename(const wchar_t *filename)
the path, if known. If -1, the first null character will be assumed
to be the end of the path. */
wchar_t *
_Py_normpath(wchar_t *path, Py_ssize_t size)
_Py_normpathAndSize(wchar_t *path, Py_ssize_t size, Py_ssize_t *length)
{
assert(path != NULL);
if (!path[0] || size == 0) {
Expand Down Expand Up @@ -2447,8 +2447,11 @@ _Py_normpath(wchar_t *path, Py_ssize_t size)
}
#endif /* MS_WINDOWS */

*length = size;

/* if pEnd is specified, check that. Else, check for null terminator */
for (; !IS_END(p1); ++p1) {
*length++;
wchar_t c = *p1;
#ifdef ALTSEP
if (c == ALTSEP) {
Expand Down Expand Up @@ -2502,6 +2505,13 @@ _Py_normpath(wchar_t *path, Py_ssize_t size)
return path;
}

wchar_t *
_Py_normpath(wchar_t *path, Py_ssize_t size)
{
Py_ssize_t length;
return _Py_normpathAndSize(path, size, &length);
}


/* Get the current directory. buflen is the buffer size in wide characters
including the null character. Decode the path from the locale encoding.
Expand Down