Skip to content

gh-135041: Expand and update pickletools module docstrings #135042

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Legoclones
Copy link
Contributor

@Legoclones Legoclones commented Jun 2, 2025

A few updates to the pickletools description code strings (functioning as documentation for the Pickle Virtual Machine).

@AA-Turner AA-Turner changed the title gh-135041: Pickle documentation update gh-135041: Expand and update pickletools module docstrings Jun 2, 2025
Comment on lines -1976 to -1981
If not isinstance(callable, type), REDUCE complains unless the
callable has been registered with the copyreg module's
safe_constructors dict, or the callable has a magic
'__safe_for_unpickling__' attribute with a true value. I'm not sure
why it does this, but I've sure seen this complaint often enough when
I didn't want to <wink>.
Copy link
Member

Choose a reason for hiding this comment

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

Is this no longer accurate?

@AA-Turner AA-Turner added docs Documentation in the Doc dir skip news labels Jun 2, 2025
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs Jun 2, 2025
@python-cla-bot
Copy link

python-cla-bot bot commented Jun 3, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

Add Oxford comma

Co-authored-by: Adam Turner <[email protected]>
@Legoclones
Copy link
Contributor Author

I believe that should be all the changes you requested, let me know if I've missed anything else.

@@ -1668,7 +1679,9 @@ def __init__(self, name, code, arg,
Stack before: ... pydict key value
Stack after: ... pydict

where pydict has been modified via pydict[key] = value.
where pydict has been modified via pydict[key] = value. Note that any
Copy link
Member

Choose a reason for hiding this comment

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

Should not we change "dict" to "mapping" in the description? And "list" to "sequence" in the description of APPEND?

Comment on lines +1819 to +1821
The index of the memo object to push is given by the positive
newline-terminated decimal string following. BINGET and LONG_BINGET
are space-optimized versions.
Copy link
Member

Choose a reason for hiding this comment

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

String can be positive.

Comment on lines 1918 to 1922
EXT1 has a 1-byte integer argument. This is used to index into
the inverted extension registry, which contains integer to tuple
mappings. The tuples have a length of two in the format of
'("module", "name")'. This tuple is then passed through find_class,
and the result is pushed onto the stack.
Copy link
Member

Choose a reason for hiding this comment

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

It mentions too much implementation details (the inverted extension registry and its format). It should only refer to copyreg.add_extension() (which unfortunately is not documented) and find_class() (like in GLOBAL, or just refer to it).

@serhiy-storchaka serhiy-storchaka requested a review from pitrou June 17, 2025 10:33
Legoclones and others added 2 commits June 17, 2025 09:41
Clarify the `APPENDS` docstring

Co-authored-by: Serhiy Storchaka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants