[issue44706] UUID constructor should accept another UUID instance

Tzach Yarimi report at bugs.python.org
Thu Jul 22 02:08:23 EDT 2021


New submission from Tzach Yarimi <tzachyrm at gmail.com>:

Primitives usually accept an instance of their own type in the constructor, for example:

int(5)
str("a")
tuple((1,2,3))

This is not the case for UUID:
>>> from uuid import uuid4, UUID
>>> x = uuid4()
>>> UUID(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python at 3.8/3.8.11/Frameworks/Python.framework/Versions/3.8/lib/python3.8/uuid.py", line 168, in __init__
    hex = hex.replace('urn:', '').replace('uuid:', '')
AttributeError: 'UUID' object has no attribute 'replace'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44706>
_______________________________________


More information about the Python-bugs-list mailing list