Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DocumentValueError being raised byUUID constructor#144425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Viicos wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromViicos:document-uuid-valueerror
Open
Changes fromall 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 deletionsDoc/library/uuid.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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
ContributorAuthor

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 aTypeError, but I feel like this is generally known that invalid arguments raiseTypeErrors?

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 isipaddress which raises TypeErrors a bit everywhere...

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

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

StanFromIreland reacted with thumbs up emoji
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.

Viicos reacted with thumbs up emoji
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

[8]ページ先頭

©2009-2026 Movatter.jp