[issue34775] pathlib.PurePath division raises TypeError instead of returning NotImplemented

2018-09-23 Thread Roger Aiudi


New submission from Roger Aiudi :

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.

--
components: Library (Lib)
messages: 326140
nosy: Roger Aiudi
priority: normal
pull_requests: 8915
severity: normal
status: open
title: pathlib.PurePath division raises TypeError instead of returning 
NotImplemented
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue34775>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34775] pathlib.PurePath division raises TypeError instead of returning NotImplemented

2018-09-23 Thread Roger Aiudi


Roger Aiudi  added the comment:

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.

--

___
Python tracker 
<https://bugs.python.org/issue34775>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com