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.

Author makronized
Recipients docs@python, makronized
Date 2013-10-04.11:18:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1380885490.13.0.480584034262.issue19164@psf.upfronthosting.co.za>
In-reply-to
Content
When you try to use uuid.UUID() without arguments you get a TypeError exception saying that you can actually use an integer (while you cannot). 

Python 2.6.8 (default, Apr 26 2013, 16:24:53) 
[GCC 4.6.3] on linux2
>>> uuid.UUID()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/uuid.py", line 129, in __init__
    raise TypeError('need one of hex, bytes, bytes_le, fields, or int')
TypeError: need one of hex, bytes, bytes_le, fields, or int

>>> uuid.UUID(uuid.uuid4().int)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/uuid.py", line 131, in __init__
    hex = hex.replace('urn:', '').replace('uuid:', '')
AttributeError: 'long' object has no attribute 'replace'

So, let's check with an integer - maybe an int has 'replace'.
>>> uuid.UUID(1231231)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/uuid.py", line 131, in __init__
    hex = hex.replace('urn:', '').replace('uuid:', '')
AttributeError: 'int' object has no attribute 'replace'

No, it doesn't. Anyway, with a propery hex value, it works (of course!).

>>> uuid.UUID(uuid.uuid4().hex)
UUID('89b1283d-c32e-4b8a-a9e3-a699445fdd4d')
History
Date User Action Args
2013-10-04 11:18:10makronizedsetrecipients: + makronized, docs@python
2013-10-04 11:18:10makronizedsetmessageid: <1380885490.13.0.480584034262.issue19164@psf.upfronthosting.co.za>
2013-10-04 11:18:10makronizedlinkissue19164 messages
2013-10-04 11:18:09makronizedcreate