Issue 20111: pathlib.PurePath.with_suffix() allows creation of otherwise impossible paths (original) (raw)
Issue20111
Created on 2014-01-02 20:29 by july, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (4) | ||
---|---|---|
msg207185 - (view) | Author: July Tikhonov (july) * | Date: 2014-01-02 20:29 |
This is not a real-world example, but it brokes some invariant (part of path must not contain separator): >>> pathlib.PurePath('/a/b.c.d').with_suffix('///') PurePosixPath('/a/b.c///') >>> pathlib.PurePath('/a/b.c.d').with_suffix('/not/split/into/parts').parts ('/', 'a', 'b.c/not/split/into/parts') I think these cases should raise an error. I would also like to consider the following to be an error, since the argument of with_suffix() is not exactly a suffix: >>> PurePath('/a/b.c.d').with_suffix('e') PurePosixPath('/a/b.ce') but I'm far less sure in this case. | ||
msg207196 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2014-01-02 22:52 |
Thank you for reporting this! You're right, this is a bug. | ||
msg207197 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2014-01-02 23:07 |
New changeset ef2b2ddd27c8 by Antoine Pitrou in branch 'default': Issue #20111: pathlib.Path.with_suffix() now sanity checks the given suffix. http://hg.python.org/cpython/rev/ef2b2ddd27c8 | ||
msg207198 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2014-01-02 23:08 |
I've committed a fix: ValueError is now raised for invalid suffixes. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:56 | admin | set | github: 64310 |
2014-01-02 23:08:25 | pitrou | set | status: open -> closedversions: - Python 3.5messages: + resolution: fixedstage: resolved |
2014-01-02 23:07:36 | python-dev | set | nosy: + python-devmessages: + |
2014-01-02 22:52:39 | pitrou | set | messages: + |
2014-01-02 20:54:13 | r.david.murray | set | nosy: + r.david.murray |
2014-01-02 20:33:27 | july | set | type: behavior |
2014-01-02 20:29:00 | july | create |