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
cd77375f
Commit
cd77375f
authored
Aug 21, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #841
parent
75e0d3ca
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
4 deletions
+38
-4
changelog.rst
changelog.rst
+5
-0
src/gevent/_socket3.py
src/gevent/_socket3.py
+10
-4
src/greentest/test__socket.py
src/greentest/test__socket.py
+23
-0
No files found.
changelog.rst
View file @
cd77375f
...
...
@@ -85,6 +85,11 @@ Stdlib Compatibility
and generally only exposes methods appropriate to the mode it is in.
- ``FileObjectPosix`` supports a *bufsize* of 0 in binary write modes.
Reported in :issue:`840` by Mike Lang.
- Python 3: meth:`gevent.socket.connect_ex` was letting
``BlockingIOError`` (and possibly others) get raised instead of
returning the errno due to the refactoring of the exception
hierarchy in Python 3.3. Now the errno is returned. Reported in
:issue:`841` by Dana Powers.
Other Changes
-------------
...
...
src/gevent/_socket3.py
View file @
cd77375f
...
...
@@ -307,11 +307,17 @@ class socket(object):
return
self
.
connect
(
address
)
or
0
except
timeout
:
return
EAGAIN
except
gaierror
:
# gaierror/overflowerror/typerror is not silented by connect_ex;
# gaierror extends OSError (aka error) so catch it first
raise
except
error
as
ex
:
if
type
(
ex
)
is
error
:
# pylint:disable=unidiomatic-typecheck
return
ex
.
args
[
0
]
else
:
raise
# gaierror is not silented by connect_ex
# error is now OSError and it has various subclasses.
# Only those that apply to actually connecting are silenced by
# connect_ex.
if
ex
.
errno
:
return
ex
.
errno
raise
# pragma: no cover
def
recv
(
self
,
*
args
):
while
True
:
...
...
src/greentest/test__socket.py
View file @
cd77375f
...
...
@@ -12,6 +12,7 @@ import _six as six
# we use threading on purpose so that we can test both regular and gevent sockets with the same code
from
threading
import
Thread
as
_Thread
errno_types
=
int
def
wrap_error
(
func
):
...
...
@@ -261,6 +262,28 @@ class TestTCP(greentest.TestCase):
s
.
close
()
def
test_connect_ex_nonblocking_bad_connection
(
self
):
# Issue 841
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
setblocking
(
False
)
ret
=
s
.
connect_ex
((
'localhost'
,
get_port
()))
self
.
assertIsInstance
(
ret
,
errno_types
)
s
.
close
()
def
test_connect_ex_gaierror
(
self
):
# Issue 841
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
with
self
.
assertRaises
(
socket
.
gaierror
):
s
.
connect_ex
((
'foo.bar.fizzbuzz'
,
get_port
()))
s
.
close
()
def
test_connect_ex_nonblocking_overflow
(
self
):
# Issue 841
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
setblocking
(
False
)
with
self
.
assertRaises
(
OverflowError
):
s
.
connect_ex
((
'localhost'
,
65539
))
s
.
close
()
def
get_port
():
tempsock
=
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