-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
json.dump(..., default=something) takes a unary function but is documented binary #107544
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The documentation you cite is for the The |
Shall we backport the docs PR or are we ready to close this issue? |
Let's close this. I think backporting is going to be too much of a pain due to how old the PR is. |
Uh oh!
There was an error while loading. Please reload this page.
Documentation
TLDR
The following documentation at https://docs.python.org/3.13/library/json.html suggests that
default
should be a member method but light testing shows that it should be unary.Documentation in Question
default(o)
Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).
For example, to support arbitrary iterators, you could implement default() like this:
Light testing
The current documentation suggests the following pattern that never gets to
TypeError("binary")
:A unary function behaves like I expect, namely entering
unary(...)
:Linked PRs
json.dumps(..., default=)
#108259The text was updated successfully, but these errors were encountered: