[issue32665] pathlib.Path._from_parsed_parts should call cls.__new__(cls)
Pablo Galindo Salgado
report at bugs.python.org
Sat Jan 27 16:34:12 EST 2018
Pablo Galindo Salgado <pablogsal at gmail.com> added the comment:
This behaviour is because "parent" descriptor ends calling:
@classmethod
def _from_parsed_parts(cls, drv, root, parts, init=True):
self = object.__new__(cls)
self._drv = drv
self._root = root
self._parts = parts
if init:
self._init()
return self
and this calls object.__new__ and this call raises AttributeError: new_attr. Notice that object.__new__(cls) will not raise as this snippet shows:
>>>: class A:
...: def __new__(*args):
...: raise ZeroDivisionError()
...:
>>> A()
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
<python> in <module>()
----> 1 A()
<python> in __new__(*args)
1 class A:
2 def __new__(*args):
----> 3 raise ZeroDivisionError()
4
ZeroDivisionError:
>>> object.__new__(A)
>>> <__main__.A at 0x7f6239c17860>
----------
nosy: +pablogsal
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32665>
_______________________________________
More information about the Python-bugs-list
mailing list