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
a7eb93ec
Commit
a7eb93ec
authored
Jun 05, 2007
by
Walter Dörwald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify socket_repr() by using PyUnicode_FromFormat()
directly. Add a test that calls socket_repr().
parent
787b03ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
Lib/test/test_socket.py
Lib/test/test_socket.py
+4
-0
Modules/socketmodule.c
Modules/socketmodule.c
+1
-3
No files found.
Lib/test/test_socket.py
View file @
a7eb93ec
...
...
@@ -217,6 +217,10 @@ class SocketPairTest(unittest.TestCase, ThreadableTest):
class
GeneralModuleTests
(
unittest
.
TestCase
):
def
test_repr
(
self
):
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
assert_
(
repr
(
s
).
startswith
(
"<socket.socket object"
))
def
test_weakref
(
self
):
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
p
=
proxy
(
s
)
...
...
Modules/socketmodule.c
View file @
a7eb93ec
...
...
@@ -2787,13 +2787,11 @@ sock_repr(PySocketSockObject *s)
return
NULL
;
}
#endif
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
return
PyUnicode_FromFormat
(
"<socket object, fd=%ld, family=%d, type=%d, proto=%d>"
,
(
long
)
s
->
sock_fd
,
s
->
sock_family
,
s
->
sock_type
,
s
->
sock_proto
);
return
PyUnicode_FromString
(
buf
);
}
...
...
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