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
6d58d649
Commit
6d58d649
authored
Mar 20, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #11127: Raise a TypeError when trying to pickle a socket object.
parent
b938bcd2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
0 deletions
+12
-0
Lib/socket.py
Lib/socket.py
+3
-0
Lib/test/test_socket.py
Lib/test/test_socket.py
+7
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/socket.py
View file @
6d58d649
...
...
@@ -112,6 +112,9 @@ class socket(_socket.socket):
s
[
7
:])
return
s
def
__getstate__
(
self
):
raise
TypeError
(
"Cannot serialize socket object"
)
def
dup
(
self
):
"""dup() -> socket object
...
...
Lib/test/test_socket.py
View file @
6d58d649
...
...
@@ -18,6 +18,7 @@ import contextlib
from
weakref
import
proxy
import
signal
import
math
import
pickle
try
:
import
fcntl
except
ImportError
:
...
...
@@ -764,6 +765,12 @@ class GeneralModuleTests(unittest.TestCase):
fp
.
close
()
self
.
assertEqual
(
repr
(
fp
),
"<_io.BufferedReader name=-1>"
)
def
test_pickle
(
self
):
sock
=
socket
.
socket
()
with
sock
:
for
protocol
in
range
(
pickle
.
HIGHEST_PROTOCOL
+
1
):
self
.
assertRaises
(
TypeError
,
pickle
.
dumps
,
sock
,
protocol
)
@
unittest
.
skipUnless
(
thread
,
'Threading required for this test.'
)
class
BasicTCPTest
(
SocketConnectedTest
):
...
...
Misc/NEWS
View file @
6d58d649
...
...
@@ -83,6 +83,8 @@ Library
-
Issue
#
4391
:
Use
proper
gettext
plural
forms
in
optparse
.
-
Issue
#
11127
:
Raise
a
TypeError
when
trying
to
pickle
a
socket
object
.
-
Issue
#
11563
:
Connection
:
close
header
is
sent
by
requests
using
URLOpener
class
which
helps
in
closing
of
sockets
after
connection
is
over
.
Patch
contributions
by
Jeff
McNeil
and
Nadeem
Vawda
.
...
...
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