Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b5b2270a
Commit
b5b2270a
authored
May 18, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make test_socket pass. There was an unchecked error when a Unicode
hostname was passed.
parent
1ab83308
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
24 deletions
+24
-24
Lib/test/test_socket.py
Lib/test/test_socket.py
+22
-23
Modules/socketmodule.c
Modules/socketmodule.c
+2
-1
No files found.
Lib/test/test_socket.py
View file @
b5b2270a
...
...
@@ -9,7 +9,6 @@ import time
import
thread
,
threading
import
Queue
import
sys
import
array
from
weakref
import
proxy
import
signal
...
...
@@ -394,16 +393,16 @@ class GeneralModuleTests(unittest.TestCase):
from
socket
import
inet_aton
as
f
,
inet_pton
,
AF_INET
g
=
lambda
a
:
inet_pton
(
AF_INET
,
a
)
self
.
assertEquals
(
'
\
x00
\
x00
\
x00
\
x00
'
,
f
(
'0.0.0.0'
))
self
.
assertEquals
(
'
\
xff
\
x00
\
xff
\
x00
'
,
f
(
'255.0.255.0'
))
self
.
assertEquals
(
'
\
xaa
\
xaa
\
xaa
\
xaa
'
,
f
(
'170.170.170.170'
))
self
.
assertEquals
(
'
\
x01
\
x02
\
x03
\
x04
'
,
f
(
'1.2.3.4'
))
self
.
assertEquals
(
'
\
xff
\
xff
\
xff
\
xff
'
,
f
(
'255.255.255.255'
))
self
.
assertEquals
(
b
'
\
x00
\
x00
\
x00
\
x00
'
,
f
(
'0.0.0.0'
))
self
.
assertEquals
(
b
'
\
xff
\
x00
\
xff
\
x00
'
,
f
(
'255.0.255.0'
))
self
.
assertEquals
(
b
'
\
xaa
\
xaa
\
xaa
\
xaa
'
,
f
(
'170.170.170.170'
))
self
.
assertEquals
(
b
'
\
x01
\
x02
\
x03
\
x04
'
,
f
(
'1.2.3.4'
))
self
.
assertEquals
(
b
'
\
xff
\
xff
\
xff
\
xff
'
,
f
(
'255.255.255.255'
))
self
.
assertEquals
(
'
\
x00
\
x00
\
x00
\
x00
'
,
g
(
'0.0.0.0'
))
self
.
assertEquals
(
'
\
xff
\
x00
\
xff
\
x00
'
,
g
(
'255.0.255.0'
))
self
.
assertEquals
(
'
\
xaa
\
xaa
\
xaa
\
xaa
'
,
g
(
'170.170.170.170'
))
self
.
assertEquals
(
'
\
xff
\
xff
\
xff
\
xff
'
,
g
(
'255.255.255.255'
))
self
.
assertEquals
(
b
'
\
x00
\
x00
\
x00
\
x00
'
,
g
(
'0.0.0.0'
))
self
.
assertEquals
(
b
'
\
xff
\
x00
\
xff
\
x00
'
,
g
(
'255.0.255.0'
))
self
.
assertEquals
(
b
'
\
xaa
\
xaa
\
xaa
\
xaa
'
,
g
(
'170.170.170.170'
))
self
.
assertEquals
(
b
'
\
xff
\
xff
\
xff
\
xff
'
,
g
(
'255.255.255.255'
))
def
testIPv6toString
(
self
):
if
not
hasattr
(
socket
,
'inet_pton'
):
...
...
@@ -430,14 +429,14 @@ class GeneralModuleTests(unittest.TestCase):
from
socket
import
inet_ntoa
as
f
,
inet_ntop
,
AF_INET
g
=
lambda
a
:
inet_ntop
(
AF_INET
,
a
)
self
.
assertEquals
(
'1.0.1.0'
,
f
(
'
\
x01
\
x00
\
x01
\
x00
'
))
self
.
assertEquals
(
'170.85.170.85'
,
f
(
'
\
xaa
\
x55
\
xaa
\
x55
'
))
self
.
assertEquals
(
'255.255.255.255'
,
f
(
'
\
xff
\
xff
\
xff
\
xff
'
))
self
.
assertEquals
(
'1.2.3.4'
,
f
(
'
\
x01
\
x02
\
x03
\
x04
'
))
self
.
assertEquals
(
'1.0.1.0'
,
f
(
b
'
\
x01
\
x00
\
x01
\
x00
'
))
self
.
assertEquals
(
'170.85.170.85'
,
f
(
b
'
\
xaa
\
x55
\
xaa
\
x55
'
))
self
.
assertEquals
(
'255.255.255.255'
,
f
(
b
'
\
xff
\
xff
\
xff
\
xff
'
))
self
.
assertEquals
(
'1.2.3.4'
,
f
(
b
'
\
x01
\
x02
\
x03
\
x04
'
))
self
.
assertEquals
(
'1.0.1.0'
,
g
(
'
\
x01
\
x00
\
x01
\
x00
'
))
self
.
assertEquals
(
'170.85.170.85'
,
g
(
'
\
xaa
\
x55
\
xaa
\
x55
'
))
self
.
assertEquals
(
'255.255.255.255'
,
g
(
'
\
xff
\
xff
\
xff
\
xff
'
))
self
.
assertEquals
(
'1.0.1.0'
,
g
(
b
'
\
x01
\
x00
\
x01
\
x00
'
))
self
.
assertEquals
(
'170.85.170.85'
,
g
(
b
'
\
xaa
\
x55
\
xaa
\
x55
'
))
self
.
assertEquals
(
'255.255.255.255'
,
g
(
b
'
\
xff
\
xff
\
xff
\
xff
'
))
def
testStringToIPv6
(
self
):
if
not
hasattr
(
socket
,
'inet_ntop'
):
...
...
@@ -1053,25 +1052,25 @@ class BufferIOTest(SocketConnectedTest):
SocketConnectedTest
.
__init__
(
self
,
methodName
=
methodName
)
def
testRecvInto
(
self
):
buf
=
array
.
array
(
'c'
,
' '
*
1024
)
buf
=
b" "
*
1024
nbytes
=
self
.
cli_conn
.
recv_into
(
buf
)
self
.
assertEqual
(
nbytes
,
len
(
MSG
))
msg
=
buf
.
tostring
()[:
len
(
MSG
)]
msg
=
str
(
buf
[:
len
(
MSG
)])
self
.
assertEqual
(
msg
,
MSG
)
def
_testRecvInto
(
self
):
buf
=
b
uffer
(
MSG
)
buf
=
b
ytes
(
MSG
)
self
.
serv_conn
.
send
(
buf
)
def
testRecvFromInto
(
self
):
buf
=
array
.
array
(
'c'
,
' '
*
1024
)
buf
=
b" "
*
1024
nbytes
,
addr
=
self
.
cli_conn
.
recvfrom_into
(
buf
)
self
.
assertEqual
(
nbytes
,
len
(
MSG
))
msg
=
buf
.
tostring
()[:
len
(
MSG
)]
msg
=
str
(
buf
[:
len
(
MSG
)])
self
.
assertEqual
(
msg
,
MSG
)
def
_testRecvFromInto
(
self
):
buf
=
b
uffer
(
MSG
)
buf
=
b
ytes
(
MSG
)
self
.
serv_conn
.
send
(
buf
)
def
test_main
():
...
...
Modules/socketmodule.c
View file @
b5b2270a
...
...
@@ -3854,7 +3854,8 @@ socket_getaddrinfo(PyObject *self, PyObject *args)
idna
=
PyObject_CallMethod
(
hobj
,
"encode"
,
"s"
,
"idna"
);
if
(
!
idna
)
return
NULL
;
hptr
=
PyString_AsString
(
idna
);
assert
(
PyBytes_Check
(
idna
));
hptr
=
PyBytes_AsString
(
idna
);
}
else
if
(
PyString_Check
(
hobj
))
{
hptr
=
PyString_AsString
(
hobj
);
}
else
{
...
...
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