GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Mention Ellipsis pickling in the docs by sterliakov · Pull Request #103660 · python/cpython

Conversation

@sterliakov

@sterliakov sterliakov commented Apr 21, 2023

Copy link
Copy Markdown
Contributor

I literally came to docs to check if Ellipsis can be pickled and unpickled, but had to try it in REPL instead. This micro PR updates the documentation page to mention that Ellipsis 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).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

arhadthedev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@sterliakov
Note that Ellipsis is serializable explicitly
927a6f8
@bedevere-bot bedevere-bot added docs Documentation in the Doc dir skip news awaiting review labels Apr 21, 2023
@arhadthedev arhadthedev added skip issue needs backport to 3.11 only security fixes labels Apr 21, 2023
@AA-Turner

AA-Turner commented Apr 21, 2023

Copy link
Copy Markdown
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 about Ellipsis is the relation to ...?

A

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sterliakov

sterliakov commented Apr 21, 2023

Copy link
Copy Markdown
Contributor Author

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

Neither Ellipsis nor NotImplemented 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 ... and NotImplemented 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 type types.EllipsisType" from the developer point of view, but a builtin truthy literal singleton, and the same logic applies to NotImplemented - instance of types.NotImplementedType).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AA-Turner
AA-Turner reviewed Apr 21, 2023
View reviewed changes
Comment thread Doc/library/pickle.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner

AA-Turner commented Apr 21, 2023

Copy link
Copy Markdown
Member

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

Just added a review suggestion on that point.

Good points about classes vs singleton instances of the types!

A

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sterliakov
Add NotImplemented mention, adjust for review comment
0312d9c
AA-Turner
AA-Turner reviewed Apr 21, 2023
View reviewed changes
Comment thread Doc/library/pickle.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner
Wrap over-long line
7e9c2fe
hauntsaninja
hauntsaninja reviewed Apr 24, 2023
View reviewed changes

@hauntsaninja hauntsaninja left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@sterliakov

sterliakov commented Aug 29, 2023

Copy link
Copy Markdown
Contributor Author

Sorry for having abandoned this PR for a while. All these cases (both NotImplemented and Ellipsis) are already covered by tests introduced in BPO6477 9 years ago together with None pickling test.

cpython/Lib/test/pickletester.py

Lines 1976 to 1983 in d08d49d

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hauntsaninja hauntsaninja added the needs backport to 3.12 only security fixes label Aug 30, 2023
hauntsaninja
hauntsaninja approved these changes Aug 30, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Aug 30, 2023
@hauntsaninja
hauntsaninja enabled auto-merge (squash) August 30, 2023 00:44
@AA-Turner
Merge branch 'main' into docs/st-ellipsis-serializable
5944c1b
@AA-Turner

AA-Turner commented Aug 30, 2023

Copy link
Copy Markdown
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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hauntsaninja
hauntsaninja merged commit 14ec0bb into python:main Aug 30, 2023
@miss-islington

miss-islington commented Aug 30, 2023

Copy link
Copy Markdown
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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting merge label Aug 30, 2023
@bedevere-bot

bedevere-bot commented Aug 30, 2023

Copy link
Copy Markdown

GH-108661 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Aug 30, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 30, 2023
@sterliakov @miss-islington
Mention Ellipsis pickling in the docs (pythonGH-103660)
d21ca65
(cherry picked from commit 14ec0bb)

Co-authored-by: sterliakov <[email protected]>
@bedevere-bot

bedevere-bot commented Aug 30, 2023

Copy link
Copy Markdown

GH-108662 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Aug 30, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 30, 2023
@sterliakov @miss-islington
Mention Ellipsis pickling in the docs (pythonGH-103660)
a9366f9
(cherry picked from commit 14ec0bb)

Co-authored-by: sterliakov <[email protected]>
hauntsaninja pushed a commit that referenced this pull request Aug 30, 2023
@miss-islington @sterliakov
[3.11] Mention Ellipsis pickling in the docs (GH-103660) (#108662)
a2c05a4
Mention Ellipsis pickling in the docs (GH-103660)
(cherry picked from commit 14ec0bb)

Co-authored-by: sterliakov <[email protected]>
Yhg1s pushed a commit that referenced this pull request Aug 30, 2023
@miss-islington @sterliakov
[3.12] Mention Ellipsis pickling in the docs (GH-103660) (#108661)
1d6d05a
Mention Ellipsis pickling in the docs (GH-103660)
(cherry picked from commit 14ec0bb)

Co-authored-by: sterliakov <[email protected]>
carljm added a commit to carljm/cpython that referenced this pull request Aug 30, 2023
@carljm
Merge branch 'main' into icompexc
37377e6
* main:
  pythongh-108520: Fix bad fork detection in nested multiprocessing use case (python#108568)
  pythongh-108590: Revert pythongh-108657 (commit 400a1ce) (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 free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AA-Turner AA-Turner AA-Turner left review comments
@hauntsaninja hauntsaninja hauntsaninja approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@sterliakov @AA-Turner @miss-islington @bedevere-bot @hauntsaninja @arhadthedev
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.