Skip to content

gh-76785: Minor Improvements to "interpreters" Module #116328

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Make interpreters.Queue instances pickleable.
  • Loading branch information
ericsnowcurrently committed Mar 4, 2024
commit acd472a0b6c1be443062a94e7048f4c5177fbd05
8 changes: 8 additions & 0 deletions Lib/test/support/interpreters/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ def __repr__(self):
def __hash__(self):
return hash(self._id)

# for pickling:
def __getnewargs__(self):
return (self._id,)

# for pickling:
def __getstate__(self):
return None

@property
def id(self):
return self._id
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_interpreters/test_queues.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib
import pickle
import threading
from textwrap import dedent
import unittest
Expand Down Expand Up @@ -127,6 +128,12 @@ def test_equality(self):
self.assertEqual(queue1, queue1)
self.assertNotEqual(queue1, queue2)

def test_pickle(self):
queue = queues.create()
data = pickle.dumps(queue)
unpickled = pickle.loads(data)
self.assertEqual(unpickled, queue)


class TestQueueOps(TestBase):

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy