New submission from STINNER Victor:
Currently, the C module _socket has an useful representation of socket: it
gives the file descriptor, family, type, etc. The Python socket module only
shows the memory address. Example:
$ ./python -c 'import _socket; s=_socket.socket(); print(repr(s));'
Changes by STINNER Victor victor.stin...@gmail.com:
--
nosy: +alex
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22081
___
___
Python-bugs-list
STINNER Victor added the comment:
I also fixed repr(_socket.socket) on Windows 64-bit for closed sockets (on
Python 2.7, 3.4 and 3.5):
changeset: 91881:04c916a1e82f
branch: 2.7
tag: tip
user:Victor Stinner victor.stin...@gmail.com
date:Sat Jul 26 14:52:55 2014
Changes by Antoine Pitrou pit...@free.fr:
--
nosy: +gvanrossum
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22081
___
___
Python-bugs-list
Guido van Rossum added the comment:
Antoine, what do you want me to do? I think improving __repr__ of a socket
sounds fine for some Python 2.7 bugfix release.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22081
Serhiy Storchaka added the comment:
I afraid this can break doctests. Isn't this against policy?
--
nosy: +serhiy.storchaka
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22081
___
Guido van Rossum added the comment:
I don't think it's against policy. Do doctests even work for objects that have
an address as part of their repr()?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22081
Serhiy Storchaka added the comment:
See for example test_generators, test_genexps, test_xml_etree or
ctypes.test.test_objects.
dict(a = (i for i in xrange(10))) #doctest: +ELLIPSIS
{'a': generator object genexpr at ...}
repr(element) # doctest: +ELLIPSIS
Element 't\\xe4g'
Guido van Rossum added the comment:
OK, I'm convinced. Sorry Victor.
On Saturday, July 26, 2014, Serhiy Storchaka rep...@bugs.python.org wrote:
Serhiy Storchaka added the comment:
See for example test_generators, test_genexps, test_xml_etree or
ctypes.test.test_objects.
dict(a = (i
Alex Gaynor added the comment:
Personally I don't think it is (or should) be against policy to change reprs,
there's not really any way to improve them otherwise.
That said, my excitement level about this issue is pretty low, so I won't argue
more than this :-)
--
STINNER Victor added the comment:
I afraid this can break doctests. Isn't this against policy?
Ok, I close the issue. A workaround is to use repr(sock._sock) to use
repr(_socket.socket) which contains a lot of information.
--
resolution: - wont fix
status: open - closed
11 matches
Mail list logo