[Python-Dev] [Python-checkins] cpython: Provide a more readable representation of socket on repr().

Victor Stinner victor.stinner at gmail.com
Tue Nov 12 23:52:56 CET 2013


Hi Giampaolo,

You forgot to update tests after your change in repr(socket). Tests
are failing on buildbots, just one example:

======================================================================
FAIL: test_repr (test.test_socket.GeneralModuleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/test_socket.py",
line 653, in test_repr
    self.assertIn('family=%i' % socket.AF_INET, repr(s))
AssertionError: 'family=2' not found in "<socket.socket fd=22,
family=AddressFamily.AF_INET, type=SocketType.SOCK_STREAM, proto=0,
laddr=('0.0.0.0', 0)>"

----------------------------------------------------------------------

Victor

2013/11/12 giampaolo.rodola <python-checkins at python.org>:
> http://hg.python.org/cpython/rev/c5751f01b09b
> changeset:   87074:c5751f01b09b
> parent:      85942:0d079c66dc23
> user:        Giampaolo Rodola' <g.rodola at gmail.com>
> date:        Thu Oct 03 21:01:43 2013 +0200
> summary:
>   Provide a more readable representation of socket on repr().
>
> Before:
> <socket.socket fd=3, family=2, type=1, proto=0, laddr=('0.0.0.0', 0)>
>
> Now:
> <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketType.SOCK_STREAM, proto=0, laddr=('0.0.0.0', 0)>
>
> files:
>   Lib/socket.py |  2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
>
> diff --git a/Lib/socket.py b/Lib/socket.py
> --- a/Lib/socket.py
> +++ b/Lib/socket.py
> @@ -136,7 +136,7 @@
>          address(es).
>          """
>          closed = getattr(self, '_closed', False)
> -        s = "<%s.%s%s fd=%i, family=%i, type=%i, proto=%i" \
> +        s = "<%s.%s%s fd=%i, family=%s, type=%s, proto=%i" \
>              % (self.__class__.__module__,
>                 self.__class__.__name__,
>                 " [closed]" if closed else "",
>
> --
> Repository URL: http://hg.python.org/cpython
>
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> https://mail.python.org/mailman/listinfo/python-checkins
>


More information about the Python-Dev mailing list