This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2014年02月16日 13:28 by july, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| pathlib-with_suffix-test.diff | july, 2014年02月16日 13:28 | proposed tests | review | |
| pathlib-with_suffix.diff | july, 2014年02月16日 13:30 | proposed fix | review | |
| Messages (5) | |||
|---|---|---|---|
| msg211316 - (view) | Author: July Tikhonov (july) * | Date: 2014年02月16日 13:28 | |
The changeset ef2b2ddd27c8 restricted the argument of Path.with_suffix() too much, and caused some strange behavior. Case 1: removing suffix completely is disallowed now. The following code worked before the fix: >>> pathlib.PurePath('a', 'b.c').with_suffix('') PurePosixPath('a/b') but now fails with ValueError: >>> pathlib.PurePath('a', 'b.c').with_suffix('') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/july/source/python/Lib/pathlib.py", line 760, in with_suffix raise ValueError("Invalid suffix %r" % (suffix)) ValueError: Invalid suffix '' It was the only one obvious way of removing the suffix, and I think it should remain so. (BTW: There is a XXX note in the code questioning if Path.with_suffix(None) should remove the suffix.) Case 2: while the output is now always a correct Path, the suffix can still contain separator. The following code produced incorrect path before the fix: >>> pathlib.PurePath('a', 'b.c').with_suffix('./.s/.') PurePosixPath('a/b./.s/.') >>> _.parts ('a', 'b./.s/.') Now, the produced path is correct, but the code itself is still allowed: >>> pathlib.PurePath('a', 'b.c').with_suffix('./.s/.') PurePosixPath('a/b.s') while I would expect it to fail with ValueError. Attached: proposed test patch. |
|||
| msg211317 - (view) | Author: July Tikhonov (july) * | Date: 2014年02月16日 13:30 | |
Proposed patch attached. |
|||
| msg211766 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2014年02月20日 23:39 | |
Thank you! Unfortunately, it is too late for 3.4, but I will make sure the fix is included in 3.4.1 (and 3.5). |
|||
| msg222428 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年07月07日 01:38 | |
New changeset 0d84855861ff by Antoine Pitrou in branch '3.4': Issue #20639: calling Path.with_suffix('') allows removing the suffix again. http://hg.python.org/cpython/rev/0d84855861ff |
|||
| msg222430 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2014年07月07日 01:39 | |
Sorry for the delay! The patch is now applied. Thank you for contributing! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:58 | admin | set | github: 64838 |
| 2014年07月07日 01:39:34 | pitrou | set | status: open -> closed resolution: fixed messages: + msg222430 stage: patch review -> resolved |
| 2014年07月07日 01:38:47 | python-dev | set | nosy:
+ python-dev messages: + msg222428 |
| 2014年02月20日 23:39:58 | pitrou | set | nosy:
+ serhiy.storchaka messages: + msg211766 stage: patch review |
| 2014年02月16日 13:30:25 | july | set | files:
+ pathlib-with_suffix.diff messages: + msg211317 |
| 2014年02月16日 13:28:50 | july | create | |