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
f8e8c3cc
Commit
f8e8c3cc
authored
Apr 30, 2020
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow a few tests to fail for dnspython.
A few cases of gethostbyaddr don't match the exception.
parent
e803fb6d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
14 deletions
+45
-14
docs/changes/1459.bugfix
docs/changes/1459.bugfix
+5
-1
src/gevent/resolver/dnspython.py
src/gevent/resolver/dnspython.py
+6
-1
src/gevent/tests/test__socket_dns.py
src/gevent/tests/test__socket_dns.py
+34
-12
No files found.
docs/changes/1459.bugfix
View file @
f8e8c3cc
The c-ares and DNSPython resolvers now raise exceptions much more
consistently with the standard resolver. Types and errnos are more
likely to match.
likely to match. (Depending on the system and configuration, it may
not match exactly, at least with DNSPython. There are still some rare
cases where the system resolver can raise ``herror`` bun DNSPython
will raise ``gaierror`` or vice versa. There doesn't seem to be a
deterministic way to account for this.)
In addition, several other small discrepancies were addressed,
including handling of localhost and broadcast host names.
src/gevent/resolver/dnspython.py
View file @
f8e8c3cc
...
...
@@ -477,7 +477,12 @@ class Resolver(AbstractResolver):
try
:
return
resolver
.
_gethostbyaddr
(
ip_address_bytes
)
except
gaierror
as
ex
:
if
ex
.
errno
==
EAI_NONAME
:
if
ex
.
args
[
0
]
==
EAI_NONAME
:
# Note: The system doesn't *always* raise herror;
# sometimes the original gaierror propagates through.
# It's impossible to say ahead of time or just based
# on the name which it should be. The herror seems to
# be by far the most common, though.
raise
herror
(
1
,
"Unknown host"
)
raise
...
...
src/gevent/tests/test__socket_dns.py
View file @
f8e8c3cc
...
...
@@ -392,8 +392,8 @@ class TestCase(greentest.TestCase):
return
(
result
[
0
],
[],
result
[
2
])
return
result
def
_compare_exceptions
(
self
,
real_result
,
gevent_result
):
msg
=
(
'system:'
,
repr
(
real_result
),
'gevent:'
,
repr
(
gevent_result
))
def
_compare_exceptions
(
self
,
real_result
,
gevent_result
,
func_name
):
msg
=
(
func_name
,
'system:'
,
repr
(
real_result
),
'gevent:'
,
repr
(
gevent_result
))
self
.
assertIs
(
type
(
gevent_result
),
type
(
real_result
),
msg
)
if
isinstance
(
real_result
,
TypeError
):
return
...
...
@@ -402,14 +402,14 @@ class TestCase(greentest.TestCase):
if
hasattr
(
real_result
,
'errno'
):
self
.
assertEqual
(
real_result
.
errno
,
gevent_result
.
errno
)
def
assertEqualResults
(
self
,
real_result
,
gevent_result
,
func
):
def
assertEqualResults
(
self
,
real_result
,
gevent_result
,
func
_name
):
errors
=
(
socket
.
gaierror
,
socket
.
herror
,
TypeError
)
if
isinstance
(
real_result
,
errors
)
and
isinstance
(
gevent_result
,
errors
):
self
.
_compare_exceptions
(
real_result
,
gevent_result
)
self
.
_compare_exceptions
(
real_result
,
gevent_result
,
func_name
)
return
real_result
=
self
.
_normalize_result
(
real_result
,
func
)
gevent_result
=
self
.
_normalize_result
(
gevent_result
,
func
)
real_result
=
self
.
_normalize_result
(
real_result
,
func
_name
)
gevent_result
=
self
.
_normalize_result
(
gevent_result
,
func
_name
)
real_result_repr
=
repr
(
real_result
)
gevent_result_repr
=
repr
(
gevent_result
)
...
...
@@ -418,8 +418,8 @@ class TestCase(greentest.TestCase):
if
relaxed_is_equal
(
gevent_result
,
real_result
):
return
# If we're using
the ares
resolver, allow the real resolver to generate an
# error that the
ares
resolver actually gets an answer to.
# If we're using
a different
resolver, allow the real resolver to generate an
# error that the
gevent
resolver actually gets an answer to.
if
(
RESOLVER_NOT_SYSTEM
...
...
@@ -512,9 +512,27 @@ add(
skip_reason
=
"Can return gaierror(-2)"
)
def
dnspython_lenient_compare_exceptions
(
self
,
real_result
,
gevent_result
,
func_name
):
try
:
TestCase
.
_compare_exceptions
(
self
,
real_result
,
gevent_result
,
func_name
)
except
AssertionError
:
# Allow gethostbyaddr to raise different things in a few rare cases.
if
(
func_name
!=
'gethostbyaddr'
or
type
(
real_result
)
not
in
(
socket
.
herror
,
socket
.
gaierror
)
or
type
(
gevent_result
)
not
in
(
socket
.
herror
,
socket
.
gaierror
)
):
raise
util
.
log
(
'WARNING: error type mismatch for %s: %r (gevent) != %r (stdlib)'
,
func_name
,
gevent_result
,
real_result
,
color
=
'warning'
)
class
TestNonexistent
(
TestCase
):
pass
if
RESOLVER_DNSPYTHON
:
_compare_exceptions
=
dnspython_lenient_compare_exceptions
add
(
TestNonexistent
,
'nonexistentxxxyyy'
)
...
...
@@ -803,13 +821,17 @@ class TestInterrupted_gethostbyname(gevent.testing.timing.AbstractGenericWaitTes
class
TestBadName
(
TestCase
):
pass
if
RESOLVER_DNSPYTHON
:
_compare_exceptions
=
dnspython_lenient_compare_exceptions
add
(
TestBadName
,
'xxxxxxxxxxxx'
)
add
(
TestBadName
,
'xxxxxxxxxxxx'
)
class
TestBadIP
(
TestCase
):
pass
if
RESOLVER_DNSPYTHON
:
_compare_exceptions
=
dnspython_lenient_compare_exceptions
add
(
TestBadIP
,
'1.2.3.400'
)
...
...
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