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
f20e334a
Commit
f20e334a
authored
Apr 29, 2020
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests on Python 2, and fix tests with DNSPython.
parent
e0da583e
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
129 additions
and
107 deletions
+129
-107
docs/changes/1012.bugfix
docs/changes/1012.bugfix
+2
-1
src/gevent/resolver/_addresses.py
src/gevent/resolver/_addresses.py
+3
-3
src/gevent/resolver/ares.py
src/gevent/resolver/ares.py
+3
-3
src/gevent/resolver/dnspython.py
src/gevent/resolver/dnspython.py
+5
-1
src/gevent/tests/test__socket_dns.py
src/gevent/tests/test__socket_dns.py
+116
-99
No files found.
docs/changes/1012.bugfix
View file @
f20e334a
...
...
@@ -9,4 +9,5 @@ use modern Cython idioms.
A few minor errors and discrepancies were fixed as well, such as
``gethostbyaddr(''localhost')`` working on Python 3 and failing on
Python 2.
Python 2. The DNSpython resolver now raises the expected TypeError in
more cases instead of an AttributeError.
src/gevent/resolver/_addresses.py
View file @
f20e334a
...
...
@@ -142,9 +142,9 @@ def _ipv6_inet_aton(text,
def _is_addr(host, parse=_ipv4_inet_aton):
if not host:
if not host
or not isinstance(host, hostname_types)
:
return False
assert isinstance(host, hostname_types), repr(host)
try:
parse(host)
except AddressSyntaxError:
...
...
@@ -158,7 +158,7 @@ is_ipv4_addr = _is_addr
def is_ipv6_addr(host):
# Return True if host is a valid IPv6 address
if host:
if host
and isinstance(host, hostname_types)
:
s = '
%
' if isinstance(host, str) else b'
%
'
host = host.split(s, 1)[0]
return _is_addr(host, _ipv6_inet_aton)
src/gevent/resolver/ares.py
View file @
f20e334a
...
...
@@ -318,7 +318,7 @@ class Resolver(AbstractResolver):
raise
def
_getnameinfo
(
self
,
sockaddr
,
flags
):
if
not
isinstance
(
flags
,
int
):
if
not
isinstance
(
flags
,
int
eger_types
):
raise
TypeError
(
'an integer is required'
)
if
not
isinstance
(
sockaddr
,
tuple
):
raise
TypeError
(
'getnameinfo() argument 1 must be a tuple'
)
...
...
@@ -331,7 +331,7 @@ class Resolver(AbstractResolver):
raise
TypeError
(
'sockaddr[0] must be a string, not %s'
%
type
(
address
).
__name__
)
port
=
sockaddr
[
1
]
if
not
isinstance
(
port
,
int
):
if
not
isinstance
(
port
,
int
eger_types
):
raise
TypeError
(
'port must be an integer, not %s'
%
type
(
port
))
if
len
(
sockaddr
)
>
2
:
...
...
@@ -340,7 +340,7 @@ class Resolver(AbstractResolver):
if
flowinfo
>
0xfffff
:
raise
OverflowError
(
"getnameinfo(): flowinfo must be 0-1048575."
)
result
=
self
.
_getaddrinfo
(
address
,
str
(
sockaddr
[
1
])
,
result
=
self
.
_getaddrinfo
(
address
,
port
,
family
=
AF_UNSPEC
,
socktype
=
SOCK_DGRAM
,
fill_in_type_proto
=
False
)
if
len
(
result
)
!=
1
:
raise
error
(
'sockaddr resolved to multiple addresses'
)
...
...
src/gevent/resolver/dnspython.py
View file @
f20e334a
...
...
@@ -393,13 +393,17 @@ class Resolver(AbstractResolver):
aliases
=
self
.
_resolver
.
hosts_resolver
.
getaliases
(
hostname
)
net_resolver
=
self
.
_resolver
.
network_resolver
rdtype
=
_family_to_rdtype
(
family
)
while
True
:
while
1
:
try
:
ans
=
net_resolver
.
query
(
hostname
,
dns
.
rdatatype
.
CNAME
,
rdtype
)
except
(
dns
.
resolver
.
NoAnswer
,
dns
.
resolver
.
NXDOMAIN
,
dns
.
resolver
.
NoNameservers
):
break
except
dTimeout
:
break
except
AttributeError
as
ex
:
if
hostname
is
None
or
isinstance
(
hostname
,
int
):
raise
TypeError
(
ex
)
raise
else
:
aliases
.
extend
(
str
(
rr
.
target
)
for
rr
in
ans
.
rrset
)
hostname
=
ans
[
0
].
target
...
...
src/gevent/tests/test__socket_dns.py
View file @
f20e334a
This diff is collapsed.
Click to expand it.
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