Skip to content

gh-74696: Pass root_dir to custom archivers which support it #94251

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

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
e5ebb8d
gh-74696: Pass root_dir to custom archivers which support it
serhiy-storchaka Jun 22, 2022
563b0f5
Update Doc/library/shutil.rst
serhiy-storchaka Jun 25, 2022
2190304
Merge branch 'main' into shutil-register_archive_format-supports_root…
merwok Sep 29, 2022
7dc8fb3
closes gh-97650: correct sphinx executable (gh-97651)
NoSuck Sep 29, 2022
679cf96
gh-96397: Document that attributes need not be identifiers (#96454)
jeff5 Sep 29, 2022
3c84af2
gh-96348: Deprecate the 3-arg signature of coroutine.throw and genera…
ofey404 Sep 30, 2022
8a0ad46
Use SyntaxError invalid range in tutorial introduction example (GH-93…
ehebert Sep 30, 2022
182755f
gh-97649: The Tools directory is no longer installed on Windows (GH-9…
zooba Sep 30, 2022
b1a9de0
gh-90989: Install Windows launcher per-user, and clarify some install…
zooba Sep 30, 2022
cc1e8e0
gh-94526: getpath_dirname() no longer encodes the path (#97645)
vstinner Sep 30, 2022
8fd0e86
bpo-35675: IDLE - separate config_key window and frame (#11427)
csabella Sep 30, 2022
d1d6b31
gh-87597: Document TimeoutExpired.stdout & .stderr types (#97685)
gpshead Sep 30, 2022
c6203f8
GH-96827: Don't touch closed loops from executor threads (#96837)
gvanrossum Sep 30, 2022
67851dc
GH-97592: Fix crash in C remove_done_callback due to evil code (#97660)
gvanrossum Sep 30, 2022
4c95e50
gh-90110: Update the c-analyzer Tool (gh-97695)
ericsnowcurrently Oct 1, 2022
fb39e7f
gh-90908: Document asyncio.Task.cancelling() and asyncio.Task.uncance…
ambv Oct 1, 2022
0bb7e71
Fix capitalization of Unix in documentation (#96913)
hawkinsw Oct 1, 2022
5ffc011
gh-95588: Drop the safety claim from `ast.literal_eval` docs. (#95919)
gpshead Oct 2, 2022
e401b65
gh-97591: In `Exception.__setstate__()` acquire strong references bef…
ofey404 Oct 2, 2022
879e866
gh-95975: Move except/*/finally ref labels to more precise locations …
CAM-Gerlach Oct 2, 2022
299dd41
gh-97607: Fix content parsing in the impl-detail reST directive (#97652)
CAM-Gerlach Oct 2, 2022
551b707
[docs] Update logging cookbook with recipe for using a logger like an…
vsajip Oct 2, 2022
b37f2cd
Refactor tests.
serhiy-storchaka Oct 2, 2022
bf58b11
Merge branch 'main' into shutil-register_archive_format-supports_root…
serhiy-storchaka Oct 2, 2022
9980c8c
Apply suggestions from code review
serhiy-storchaka Oct 4, 2022
5160cb7
fix markup
merwok Oct 4, 2022
701f896
Update Doc/whatsnew/3.12.rst
serhiy-storchaka Oct 5, 2022
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
Prev Previous commit
Next Next commit
gh-94526: getpath_dirname() no longer encodes the path (#97645)
Fix the Python path configuration used to initialized sys.path at
Python startup. Paths are no longer encoded to UTF-8/strict to avoid
encoding errors if it contains surrogate characters (bytes paths are
decoded with the surrogateescape error handler).

getpath_basename() and getpath_dirname() functions no longer encode
the path to UTF-8/strict, but work directly on Unicode strings. These
functions now use PyUnicode_FindChar() and PyUnicode_Substring() on
the Unicode path, rather than strrchr() on the encoded bytes string.
  • Loading branch information
vstinner authored and serhiy-storchaka committed Oct 2, 2022
commit cc1e8e0367c90a67d8b24a0cb8c0b75d85ce1094
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix the Python path configuration used to initialized :data:`sys.path` at
Python startup. Paths are no longer encoded to UTF-8/strict to avoid encoding
errors if it contains surrogate characters (bytes paths are decoded with the
surrogateescape error handler). Patch by Victor Stinner.
23 changes: 14 additions & 9 deletions Modules/getpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,32 @@ getpath_abspath(PyObject *Py_UNUSED(self), PyObject *args)
static PyObject *
getpath_basename(PyObject *Py_UNUSED(self), PyObject *args)
{
const char *path;
if (!PyArg_ParseTuple(args, "s", &path)) {
PyObject *path;
if (!PyArg_ParseTuple(args, "U", &path)) {
return NULL;
}
const char *name = strrchr(path, SEP);
return PyUnicode_FromString(name ? name + 1 : path);
Py_ssize_t end = PyUnicode_GET_LENGTH(path);
Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1);
if (pos < 0) {
return Py_NewRef(path);
}
return PyUnicode_Substring(path, pos + 1, end);
}


static PyObject *
getpath_dirname(PyObject *Py_UNUSED(self), PyObject *args)
{
const char *path;
if (!PyArg_ParseTuple(args, "s", &path)) {
PyObject *path;
if (!PyArg_ParseTuple(args, "U", &path)) {
return NULL;
}
const char *name = strrchr(path, SEP);
if (!name) {
Py_ssize_t end = PyUnicode_GET_LENGTH(path);
Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1);
if (pos < 0) {
return PyUnicode_FromStringAndSize(NULL, 0);
}
return PyUnicode_FromStringAndSize(path, (name - path));
return PyUnicode_Substring(path, 0, pos);
}


Expand Down