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.

Title: UUID constructor should accept another UUID instance
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
Status: closed Resolution: duplicate
Dependencies: Superseder: Should uuid.UUID() accept another UUID() instance?
View: 32112
Assigned To: Nosy List: serhiy.storchaka, tzach
Priority: normal Keywords:

Created on 2021-07-22 06:06 by tzach, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg397976 - (view) Author: Tzach Yarimi (tzach) Date: 2021-07-22 06:08
Primitives usually accept an instance of their own type in the constructor, for example:


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@3.8/3.8.11/Frameworks/Python.framework/Versions/3.8/lib/python3.8/", line 168, in __init__
    hex = hex.replace('urn:', '').replace('uuid:', '')
AttributeError: 'UUID' object has no attribute 'replace'
msg397977 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-07-22 07:07
It is a duplicate of issue32112.
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88872
2021-07-22 07:07:02serhiy.storchakasetstatus: open -> closed

superseder: Should uuid.UUID() accept another UUID() instance?

nosy: + serhiy.storchaka
messages: + msg397977
resolution: duplicate
stage: resolved
2021-07-22 06:09:01tzachsetversions: + Python 3.6, Python 3.7, Python 3.8, Python 3.9, Python 3.10
2021-07-22 06:08:23tzachsetmessages: + msg397976
2021-07-22 06:06:33tzachcreate