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

Mention Ellipsis pickling in the docs#103660

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

Merged

Conversation

sterliakov
Copy link
Contributor

I literally came to docs to check ifEllipsis can be pickled and unpickled, but had to try it in REPL instead. This micro PR updates the documentation page to mention thatEllipsis is picklable. (no issue code, since this is a minor doc-only change)

Needs backport to all maintained versions, because this behaviour did not change (at least it's picklable in versions 3.7 to 3.12, I haven't checked earlier versions).

arhadthedev reacted with thumbs up emoji
@AA-Turner
Copy link
Member

Is this covered by ‘classes accessible from the top level of a module’? For example,NotImplemented isn’t contained in this list. Perhaps the ‘special’ thing aboutEllipsis is the relation to...?

A

@sterliakov
Copy link
ContributorAuthor

Oh, I'd rather addNotImplemented too, thanks for the reminder! Just checked, and it's picklable as well.

NeitherEllipsis norNotImplemented are covered by "classes accessible from..." at least because they are not classes... These five builtin singletons (with None, True, and False) are special due to their nature. In fact... andNotImplemented are covered by "instances of such classes whose the result of calling__getstate__() is picklable", but this finding requires treating them in slightly unusual way (Ellipsis is not "instance of typetypes.EllipsisType" from the developer point of view, but a builtin truthy literal singleton, and the same logic applies toNotImplemented - instance oftypes.NotImplementedType).

@AA-Turner
Copy link
Member

Oh, I'd rather addNotImplemented too, thanks for the reminder!

Just added a review suggestion on that point.

Good points about classes vs singleton instances of the types!

A

Copy link
Contributor

@hauntsaninjahauntsaninja left a comment

Choose a reason for hiding this comment

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

If we're documenting this behaviour, ideally we should make sure it's tested as well.

JelleZijlstra reacted with thumbs up emoji
@sterliakov
Copy link
ContributorAuthor

Sorry for having abandoned this PR for a while. All these cases (bothNotImplemented andEllipsis) are already covered by tests introduced inBPO6477 9 years ago together withNone pickling test.

deftest_singleton_types(self):
# Issue #6477: Test that types of built-in singletons can be pickled.
singletons= [None, ...,NotImplemented]
forsingletoninsingletons:
forprotoinprotocols:
s=self.dumps(type(singleton),proto)
u=self.loads(s)
self.assertIs(type(singleton),u)

@hauntsaninjahauntsaninja added the needs backport to 3.12only security fixes labelAug 30, 2023
@AA-Turner
Copy link
Member

@hauntsaninja I've merged HEAD as the branch was out-of-date, so the checks would never succeed (& hence auto-merge would never happen)

A

@hauntsaninjahauntsaninja merged commit14ec0bb intopython:mainAug 30, 2023
@miss-islington
Copy link
Contributor

Thanks@sterliakov for the PR, and@hauntsaninja for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-bot
Copy link

GH-108661 is a backport of this pull request to the3.12 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.12only security fixes labelAug 30, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestAug 30, 2023
(cherry picked from commit14ec0bb)Co-authored-by: sterliakov <50529348+sterliakov@users.noreply.github.com>
@bedevere-bot
Copy link

GH-108662 is a backport of this pull request to the3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11only security fixes labelAug 30, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestAug 30, 2023
(cherry picked from commit14ec0bb)Co-authored-by: sterliakov <50529348+sterliakov@users.noreply.github.com>
hauntsaninja pushed a commit that referenced this pull requestAug 30, 2023
Mention Ellipsis pickling in the docs (GH-103660)(cherry picked from commit14ec0bb)Co-authored-by: sterliakov <50529348+sterliakov@users.noreply.github.com>
Yhg1s pushed a commit that referenced this pull requestAug 30, 2023
Mention Ellipsis pickling in the docs (GH-103660)(cherry picked from commit14ec0bb)Co-authored-by: sterliakov <50529348+sterliakov@users.noreply.github.com>
carljm added a commit to carljm/cpython that referenced this pull requestAug 30, 2023
* main:pythongh-108520: Fix bad fork detection in nested multiprocessing use case (python#108568)pythongh-108590: Revertpythongh-108657 (commit400a1ce) (python#108686)pythongh-108494: Argument Clinic: Document how to generate code that uses the limited C API (python#108584)  Document Python build requirements (python#108646)pythongh-101100: Fix Sphinx warnings in the Logging Cookbook (python#108678)  Fix typo in multiprocessing docs (python#108666)pythongh-108669: unittest: Fix documentation for TestResult.collectedDurations (python#108670)pythongh-108590: Fix sqlite3.iterdump for invalid Unicode in TEXT columns (python#108657)  Revert "pythongh-103224: Use the realpath of the Python executable in `test_venv` (pythonGH-103243)" (pythonGH-108667)pythongh-106320: Remove private _Py_ForgetReference() (python#108664)  Mention Ellipsis pickling in the docs (python#103660)  Revert "Use non alternate name for Kyiv (pythonGH-108533)" (pythonGH-108649)pythongh-108278: Deprecate passing the first param of sqlite3.Connection callback APIs by keyword (python#108632)pythongh-108455: peg_generator: install two stubs packages before running mypy (python#108637)pythongh-107801: Improve the accuracy of io.IOBase.seek docs (python#108268)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@AA-TurnerAA-TurnerAA-Turner left review comments

@hauntsaninjahauntsaninjahauntsaninja approved these changes

Assignees
No one assigned
Labels
docsDocumentation in the Doc dirskip issueskip news
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@sterliakov@AA-Turner@miss-islington@bedevere-bot@hauntsaninja@arhadthedev

[8]ページ先頭

©2009-2025 Movatter.jp