- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
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 2018-09-23 07:02 by Roger Aiudi, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 9509 | merged | Roger Aiudi, 2018-09-23 07:02 | |
| PR 15172 | merged | miss-islington, 2019-08-08 05:44 | |
| PR 12361 | kmaork, 2020-01-16 12:08 |
| Messages (6) | ||
|---|---|---|
| msg326140 - (view) | Author: Roger Aiudi (Roger Aiudi) * | Date: 2018-09-23 07:02 |
PurePath.__truediv__ and __rtruediv__ raise a TypeError when passed something which is not an instance of string or PurePath. This prevents creating any sort of compatible class that doesn't inherit from the previously mentioned types. |
||
| msg326146 - (view) | Author: Berker Peksag (berker.peksag) * ![]() |
Date: 2018-09-23 07:58 |
Thanks for the report and for the PR. Could you give us a little bit more information about your use case? Couldn't you make the class you want to use implement the __fspath__ protocol?
import pathlib as p
class Spam:
def __fspath__(self):
return 'pathlib.py'
And we can use it like:
>>> p.Path('Lib') / Spam()
PosixPath('Lib/pathlib.py')
>>> (p.Path('Lib') / Spam()).exists()
True
(3.4 and 3.5 are in security-fix-only mode, so I removed them from the versions field.)
|
||
| msg326156 - (view) | Author: Roger Aiudi (Roger Aiudi) * | Date: 2018-09-23 14:41 |
Using your above example, my use case is returning an instance of Spam instead of PurePath from the division operation. The Spam class would have extra properties and methods for dealing with a substructure of our file system that can exist in different places, so being able to use a normal Path to locate it later with the division operation would be useful. (I know I could have a method that would do that, but I personally think reading the division left to right is clearer.) The current implementation makes this impossible and I found raising a TypeError to be inconsistent with how Python handles operator overloading in the standard library. |
||
| msg349217 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2019-08-08 05:41 |
New changeset 4c69be22df3852f17873a74d015528d9a8ae92d6 by Serhiy Storchaka (aiudirog) in branch 'master': bpo-34775: Return NotImplemented in PurePath division. (GH-9509) https://github.com/python/cpython/commit/4c69be22df3852f17873a74d015528d9a8ae92d6 |
||
| msg350712 - (view) | Author: Ned Deily (ned.deily) * ![]() |
Date: 2019-08-29 05:06 |
New changeset 4adcaf81513e57a2a4e278073a89efb1375af8df by Ned Deily (Miss Islington (bot)) in branch '3.8': bpo-34775: Return NotImplemented in PurePath division. (GH-9509) (GH-15172) https://github.com/python/cpython/commit/4adcaf81513e57a2a4e278073a89efb1375af8df |
||
| msg350714 - (view) | Author: Ned Deily (ned.deily) * ![]() |
Date: 2019-08-29 05:12 |
The change was pushed for release in 3.8.0b4. I don't think we should backport it to 3.7 at this stage in its lifecycle as the old behavior has been around for a long time. Thanks, everyone! |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:06 | admin | set | github: 78956 |
| 2020-01-16 12:08:52 | kmaork | set | pull_requests: + pull_request17426 |
| 2019-08-29 05:12:34 | ned.deily | set | status: open -> closed versions: + Python 3.9, - Python 3.6, Python 3.7 messages: + msg350714 resolution: fixed stage: patch review -> resolved |
| 2019-08-29 05:06:03 | ned.deily | set | nosy:
+ ned.deily messages: + msg350712 |
| 2019-08-08 05:44:33 | miss-islington | set | keywords:
+ patch stage: test needed -> patch review pull_requests: + pull_request14904 |
| 2019-08-08 05:41:18 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg349217 |
| 2018-09-23 14:41:44 | Roger Aiudi | set | messages: + msg326156 |
| 2018-09-23 08:20:43 | xtreak | set | nosy:
+ xtreak |
| 2018-09-23 07:58:01 | berker.peksag | set | versions:
- Python 3.4, Python 3.5 nosy: + berker.peksag messages: + msg326146 stage: test needed |
| 2018-09-23 07:02:08 | Roger Aiudi | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements

