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
40f12ab0
Commit
40f12ab0
authored
Dec 28, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport Python 3.2 fix for issue #12065, and add another test for SSLSocket.connect_ex().
parent
c4051aa8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
9 deletions
+42
-9
Lib/ssl.py
Lib/ssl.py
+11
-9
Lib/test/test_ssl.py
Lib/test/test_ssl.py
+28
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/ssl.py
View file @
40f12ab0
...
@@ -313,17 +313,19 @@ class SSLSocket(socket):
...
@@ -313,17 +313,19 @@ class SSLSocket(socket):
self
.
cert_reqs
,
self
.
ssl_version
,
self
.
cert_reqs
,
self
.
ssl_version
,
self
.
ca_certs
,
self
.
ciphers
)
self
.
ca_certs
,
self
.
ciphers
)
try
:
try
:
if
return_errno
:
rc
=
socket
.
connect_ex
(
self
,
addr
)
else
:
rc
=
None
socket
.
connect
(
self
,
addr
)
socket
.
connect
(
self
,
addr
)
if
not
rc
:
if
self
.
do_handshake_on_connect
:
if
self
.
do_handshake_on_connect
:
self
.
do_handshake
()
self
.
do_handshake
()
except
socket_error
as
e
:
if
return_errno
:
return
e
.
errno
else
:
self
.
_sslobj
=
None
raise
e
self
.
_connected
=
True
self
.
_connected
=
True
return
0
return
rc
except
socket_error
:
self
.
_sslobj
=
None
raise
def
connect
(
self
,
addr
):
def
connect
(
self
,
addr
):
"""Connects to remote ADDR, and then wraps the connection in
"""Connects to remote ADDR, and then wraps the connection in
...
...
Lib/test/test_ssl.py
View file @
40f12ab0
...
@@ -280,6 +280,34 @@ class NetworkedTests(unittest.TestCase):
...
@@ -280,6 +280,34 @@ class NetworkedTests(unittest.TestCase):
finally
:
finally
:
s
.
close
()
s
.
close
()
def
test_timeout_connect_ex
(
self
):
# Issue #12065: on a timeout, connect_ex() should return the original
# errno (mimicking the behaviour of non-SSL sockets).
with
test_support
.
transient_internet
(
"svn.python.org"
):
s
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
),
cert_reqs
=
ssl
.
CERT_REQUIRED
,
ca_certs
=
SVN_PYTHON_ORG_ROOT_CERT
,
do_handshake_on_connect
=
False
)
try
:
s
.
settimeout
(
0.0000001
)
rc
=
s
.
connect_ex
((
'svn.python.org'
,
443
))
if
rc
==
0
:
self
.
skipTest
(
"svn.python.org responded too quickly"
)
self
.
assertIn
(
rc
,
(
errno
.
EAGAIN
,
errno
.
EWOULDBLOCK
))
finally
:
s
.
close
()
def
test_connect_ex_error
(
self
):
with
test_support
.
transient_internet
(
"svn.python.org"
):
s
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
),
cert_reqs
=
ssl
.
CERT_REQUIRED
,
ca_certs
=
SVN_PYTHON_ORG_ROOT_CERT
)
try
:
self
.
assertEqual
(
errno
.
ECONNREFUSED
,
s
.
connect_ex
((
"svn.python.org"
,
444
)))
finally
:
s
.
close
()
@
unittest
.
skipIf
(
os
.
name
==
"nt"
,
"Can't use a socket as a file under Windows"
)
@
unittest
.
skipIf
(
os
.
name
==
"nt"
,
"Can't use a socket as a file under Windows"
)
def
test_makefile_close
(
self
):
def
test_makefile_close
(
self
):
# Issue #5238: creating a file-like object with makefile() shouldn't
# Issue #5238: creating a file-like object with makefile() shouldn't
...
...
Misc/NEWS
View file @
40f12ab0
...
@@ -175,6 +175,9 @@ Core and Builtins
...
@@ -175,6 +175,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #12065: connect_ex() on an SSL socket now returns the original errno
when the socket'
s
timeout
expires
(
it
used
to
return
None
).
-
Issue
#
16504
:
IDLE
now
catches
SyntaxErrors
raised
by
tokenizer
.
Patch
by
-
Issue
#
16504
:
IDLE
now
catches
SyntaxErrors
raised
by
tokenizer
.
Patch
by
Roger
Serwy
.
Roger
Serwy
.
...
...
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