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
824c89f4
Commit
824c89f4
authored
Mar 04, 2014
by
Fantix King
Committed by
Denis Bilenko
Mar 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace unicode with text_type
parent
a7b17d41
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
6 deletions
+11
-6
gevent/hub.py
gevent/hub.py
+2
-0
gevent/resolver_ares.py
gevent/resolver_ares.py
+5
-5
greentest/six.py
greentest/six.py
+2
-0
greentest/test__socket.py
greentest/test__socket.py
+2
-1
No files found.
gevent/hub.py
View file @
824c89f4
...
...
@@ -33,6 +33,7 @@ PY3 = sys.version_info[0] >= 3
if
PY3
:
string_types
=
str
,
integer_types
=
int
,
text_type
=
str
xrange
=
range
def
reraise
(
tp
,
value
,
tb
=
None
):
...
...
@@ -43,6 +44,7 @@ if PY3:
else
:
import
__builtin__
string_types
=
__builtin__
.
basestring
,
text_type
=
__builtin__
.
unicode
integer_types
=
(
int
,
__builtin__
.
long
)
xrange
=
__builtin__
.
xrange
...
...
gevent/resolver_ares.py
View file @
824c89f4
...
...
@@ -2,7 +2,7 @@
from
__future__
import
absolute_import
import
os
from
_socket
import
getservbyname
,
getaddrinfo
,
gaierror
,
error
from
gevent.hub
import
Waiter
,
get_hub
,
string_types
from
gevent.hub
import
Waiter
,
get_hub
,
string_types
,
text_type
from
gevent.socket
import
AF_UNSPEC
,
AF_INET
,
AF_INET6
,
SOCK_STREAM
,
SOCK_DGRAM
,
SOCK_RAW
,
AI_NUMERICHOST
,
EAI_SERVICE
,
AI_PASSIVE
from
gevent.ares
import
channel
,
InvalidIP
...
...
@@ -52,7 +52,7 @@ class Resolver(object):
return
self
.
gethostbyname_ex
(
hostname
,
family
)[
-
1
][
0
]
def
gethostbyname_ex
(
self
,
hostname
,
family
=
AF_INET
):
if
isinstance
(
hostname
,
unicod
e
):
if
isinstance
(
hostname
,
text_typ
e
):
hostname
=
hostname
.
encode
(
'ascii'
)
elif
not
isinstance
(
hostname
,
str
):
raise
TypeError
(
'Expected string, not %s'
%
type
(
hostname
).
__name__
)
...
...
@@ -117,7 +117,7 @@ class Resolver(object):
return
port
,
socktypes
def
_getaddrinfo
(
self
,
host
,
port
,
family
=
0
,
socktype
=
0
,
proto
=
0
,
flags
=
0
):
if
isinstance
(
host
,
unicod
e
):
if
isinstance
(
host
,
text_typ
e
):
host
=
host
.
encode
(
'idna'
)
elif
not
isinstance
(
host
,
str
)
or
(
flags
&
AI_NUMERICHOST
):
# this handles cases which do not require network access
...
...
@@ -191,7 +191,7 @@ class Resolver(object):
raise
def
_gethostbyaddr
(
self
,
ip_address
):
if
isinstance
(
ip_address
,
unicod
e
):
if
isinstance
(
ip_address
,
text_typ
e
):
ip_address
=
ip_address
.
encode
(
'ascii'
)
elif
not
isinstance
(
ip_address
,
str
):
raise
TypeError
(
'Expected string, not %s'
%
type
(
ip_address
).
__name__
)
...
...
@@ -228,7 +228,7 @@ class Resolver(object):
raise
TypeError
(
'getnameinfo() argument 1 must be a tuple'
)
address
=
sockaddr
[
0
]
if
isinstance
(
address
,
unicod
e
):
if
isinstance
(
address
,
text_typ
e
):
address
=
address
.
encode
(
'ascii'
)
if
not
isinstance
(
address
,
str
):
...
...
greentest/six.py
View file @
824c89f4
...
...
@@ -20,6 +20,7 @@ if PY3:
del
builtins
xrange
=
range
string_types
=
str
,
text_type
=
str
else
:
def
exec_
(
code
,
globs
=
None
,
locs
=
None
):
...
...
@@ -37,3 +38,4 @@ else:
import
__builtin__
as
builtins
xrange
=
builtins
.
xrange
string_types
=
builtins
.
basestring
,
text_type
=
builtins
.
unicode
greentest/test__socket.py
View file @
824c89f4
...
...
@@ -7,6 +7,7 @@ import traceback
import
time
import
greentest
from
functools
import
wraps
import
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
...
...
@@ -77,7 +78,7 @@ class TestTCP(greentest.TestCase):
self
.
_test_sendall
(
self
.
long_data
)
def
test_sendall_unicode
(
self
):
self
.
_test_sendall
(
unicod
e
(
self
.
long_data
))
self
.
_test_sendall
(
six
.
text_typ
e
(
self
.
long_data
))
def
test_sendall_array
(
self
):
data
=
array
.
array
(
"B"
,
self
.
long_data
)
...
...
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