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 fcurella
Recipients fcurella
Date 2018-10-30.15:12:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1540912336.8.0.788709270274.issue35115@psf.upfronthosting.co.za>
In-reply-to
Content
Casting a UUID to an `int` or to a string works as expected:

```
import uuid

value = uuid.UUID()
str(value)
int(value)
```

but casting to an `hex()` raises an exception:

```
import uuid

value = uuid.UUID()

# uuid instances already have the correct value stored in the `.hex` attribute
value.hex

# this raises `TypeError: 'UUID' object cannot be interpreted as an integer`
hex(value)

# this behaves correctly
hex(value.int)

```

Adding support for `hex()` should be simple enough as adding the following to the UUID class in https://github.com/python/cpython/blob/54752533b2ed1c898ffe5ec2e795c6910ee46a39/Lib/uuid.py#L69:

```
def __index__(self):
    return self.int
```
History
Date User Action Args
2018-10-30 15:12:16fcurellasetrecipients: + fcurella
2018-10-30 15:12:16fcurellasetmessageid: <1540912336.8.0.788709270274.issue35115@psf.upfronthosting.co.za>
2018-10-30 15:12:16fcurellalinkissue35115 messages
2018-10-30 15:12:16fcurellacreate