Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
18ddc987
Commit
18ddc987
authored
Mar 09, 2017
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Python 2 sockets don't pass type/protocol to getaddrinfo in connect. Fixes #944.
parent
ca9c3b8c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
3 deletions
+37
-3
CHANGES.rst
CHANGES.rst
+4
-0
src/gevent/_socket2.py
src/gevent/_socket2.py
+1
-1
src/greentest/test__socket.py
src/greentest/test__socket.py
+29
-2
src/greentest/test__ssl.py
src/greentest/test__ssl.py
+3
-0
No files found.
CHANGES.rst
View file @
18ddc987
...
...
@@ -9,6 +9,10 @@
- Testing on Python 3.5 now uses Python 3.5.3 due to SSL changes. See
:issue:`943`.
- Python 2 sockets are compatible with the ``SOCK_CLOEXEC`` flag found
on Linux. They no longer pass the socket type or protocol to
``getaddrinfo`` when ``connect`` is called. Reported in :issue:`944`
by Bernie Hackett.
1.2.1 (2017-01-12)
==================
...
...
src/gevent/_socket2.py
View file @
18ddc987
...
...
@@ -218,7 +218,7 @@ class socket(object):
return
self
.
_sock
.
connect
(
address
)
sock
=
self
.
_sock
if
isinstance
(
address
,
tuple
):
r
=
getaddrinfo
(
address
[
0
],
address
[
1
],
sock
.
family
,
sock
.
type
,
sock
.
proto
)
r
=
getaddrinfo
(
address
[
0
],
address
[
1
],
sock
.
family
)
address
=
r
[
0
][
-
1
]
if
self
.
timeout
is
not
None
:
timer
=
Timeout
.
start_new
(
self
.
timeout
,
timeout
(
'timed out'
))
...
...
src/greentest/test__socket.py
View file @
18ddc987
...
...
@@ -5,6 +5,7 @@ import array
import
socket
import
traceback
import
time
import
unittest
import
greentest
from
functools
import
wraps
import
_six
as
six
...
...
@@ -212,7 +213,7 @@ class TestTCP(greentest.TestCase):
def
test_makefile
(
self
):
def
accept_once
():
conn
,
addr
=
self
.
listener
.
accept
()
conn
,
_
=
self
.
listener
.
accept
()
fd
=
conn
.
makefile
(
mode
=
'wb'
)
fd
.
write
(
b'hello
\
n
'
)
fd
.
close
()
...
...
@@ -230,7 +231,7 @@ class TestTCP(greentest.TestCase):
def
test_makefile_timeout
(
self
):
def
accept_once
():
conn
,
addr
=
self
.
listener
.
accept
()
conn
,
_
=
self
.
listener
.
accept
()
try
:
time
.
sleep
(
0.3
)
finally
:
...
...
@@ -285,6 +286,32 @@ class TestTCP(greentest.TestCase):
s
.
connect_ex
((
'localhost'
,
65539
))
s
.
close
()
@
unittest
.
skipUnless
(
hasattr
(
socket
,
'SOCK_CLOEXEC'
),
"Requires SOCK_CLOEXEC"
)
def
test_connect_with_type_flags_ignored
(
self
):
# Issue 944
# If we have SOCK_CLOEXEC or similar, we shouldn't be passing
# them through to the getaddrinfo call that connect() makes
SOCK_CLOEXEC
=
socket
.
SOCK_CLOEXEC
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
|
SOCK_CLOEXEC
)
def
accept_once
():
conn
,
_
=
self
.
listener
.
accept
()
fd
=
conn
.
makefile
(
mode
=
'wb'
)
fd
.
write
(
b'hello
\
n
'
)
fd
.
close
()
conn
.
close
()
acceptor
=
Thread
(
target
=
accept_once
)
s
.
connect
((
'127.0.0.1'
,
self
.
port
))
fd
=
s
.
makefile
(
mode
=
'rb'
)
self
.
assertEqual
(
fd
.
readline
(),
b'hello
\
n
'
)
fd
.
close
()
s
.
close
()
acceptor
.
join
()
def
get_port
():
tempsock
=
socket
.
socket
()
tempsock
.
bind
((
''
,
0
))
...
...
src/greentest/test__ssl.py
View file @
18ddc987
...
...
@@ -70,6 +70,9 @@ class TestSSL(test__socket.TestTCP):
# Override; doesn't work with SSL sockets.
pass
def
test_connect_with_type_flags_ignored
(
self
):
# Override; doesn't work with SSL sockets.
pass
def
ssl_listener
(
address
,
private_key
,
certificate
):
raw_listener
=
socket
.
socket
()
...
...
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