Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
43605e6b
Commit
43605e6b
authored
Nov 15, 2017
by
Yury Selivanov
Committed by
GitHub
Nov 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32034: Make IncompleteReadError & LimitOverrunError pickleable #4409
parent
4bd41c9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
Lib/asyncio/streams.py
Lib/asyncio/streams.py
+6
-0
Lib/test/test_asyncio/test_streams.py
Lib/test/test_asyncio/test_streams.py
+18
-0
Misc/NEWS.d/next/Library/2017-11-15-13-44-28.bpo-32034.uHAOmu.rst
...S.d/next/Library/2017-11-15-13-44-28.bpo-32034.uHAOmu.rst
+1
-0
No files found.
Lib/asyncio/streams.py
View file @
43605e6b
...
...
@@ -35,6 +35,9 @@ class IncompleteReadError(EOFError):
self
.
partial
=
partial
self
.
expected
=
expected
def
__reduce__
(
self
):
return
type
(
self
),
(
self
.
partial
,
self
.
expected
)
class
LimitOverrunError
(
Exception
):
"""Reached the buffer limit while looking for a separator.
...
...
@@ -46,6 +49,9 @@ class LimitOverrunError(Exception):
super
().
__init__
(
message
)
self
.
consumed
=
consumed
def
__reduce__
(
self
):
return
type
(
self
),
(
self
.
args
[
0
],
self
.
consumed
)
@
coroutine
def
open_connection
(
host
=
None
,
port
=
None
,
*
,
...
...
Lib/test/test_asyncio/test_streams.py
View file @
43605e6b
...
...
@@ -3,6 +3,7 @@
import
gc
import
os
import
queue
import
pickle
import
socket
import
sys
import
threading
...
...
@@ -845,6 +846,23 @@ os.close(fd)
stream._transport.__repr__.return_value = "
<
Transport
>
"
self.assertEqual("
<
StreamReader
t
=<
Transport
>>
", repr(stream))
def test_IncompleteReadError_pickleable(self):
e = asyncio.IncompleteReadError(b'abc', 10)
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
with self.subTest(pickle_protocol=proto):
e2 = pickle.loads(pickle.dumps(e, protocol=proto))
self.assertEqual(str(e), str(e2))
self.assertEqual(e.partial, e2.partial)
self.assertEqual(e.expected, e2.expected)
def test_LimitOverrunError_pickleable(self):
e = asyncio.LimitOverrunError('message', 10)
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
with self.subTest(pickle_protocol=proto):
e2 = pickle.loads(pickle.dumps(e, protocol=proto))
self.assertEqual(str(e), str(e2))
self.assertEqual(e.consumed, e2.consumed)
if __name__ == '__main__':
unittest.main()
Misc/NEWS.d/next/Library/2017-11-15-13-44-28.bpo-32034.uHAOmu.rst
0 → 100644
View file @
43605e6b
Make asyncio.IncompleteReadError and LimitOverrunError pickleable.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment