Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Doc/library/uuid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ which relays any information about the UUID's safety, using this enumeration:
UUID(int=0x12345678123456781234567812345678)

Exactly one of *hex*, *bytes*, *bytes_le*, *fields*, or *int* must be given.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also explicitly specify that this raises a TypeError, but I feel like this is generally known that invalid arguments raise TypeErrors?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually:

  • Invalid signature/usage/object types -> TypeError
  • Valid type but invalid data -> ValueError

The only exception I'm aware of is ipaddress which raises TypeErrors a bit everywhere...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum then not documenting ValueError would maybe make sense? I had the correct assumption for TypeError, and wasn't sure for value errors but indeed it makes sense and once you know about this you can just write your try..except blocks from muscle memory

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually fine with documenting this. Sometimes we do document this, sometimes not.

If any of these arguments are malformed, a :exc:`ValueError` is raised.
The *version* argument is optional; if given, the resulting UUID will have its
variant and version number set according to :rfc:`9562`, overriding bits in the
given *hex*, *bytes*, *bytes_le*, *fields*, or *int*.
Expand Down
Loading