New submission from Brent Gardner :
In Python 3.5.3, a socket with type AF_CAN returns a tuple in the form `(interface, )` from getsockname(). In Python 3.7.3, getsockname() returns a string (the name of the interface). The documentation states "a tuple is used for the AF_CAN address family". The string will break code that worked in 3.5.3 by raising errors such as "Value Error: too many values to unpack (expected 2)".
Example:
#3.5.3
import socket
s = socket.socket(socket.AF_CAN, socket.SOCK_RAW, socket.CAN_RAW)
s.bind(('vcan0',)) # requires tuple
s.getsockname() # returns tuple: ('vcan0', 29)
#3.7.3
import socket
s = socket.socket(socket.AF_CAN, socket.SOCK_RAW, socket.CAN_RAW)
s.bind(('vcan0',)) # requires tuple
s.getsockname() # returns string: 'vcan0'
----------
assignee: docs@python
components: Documentation
messages: 346559
nosy: Brent Gardner, docs@python
priority: normal
severity: normal
status: open
title: socket.getsockname() returns string instead of tuple
versions: Python 3.7
_______________________________________
Python tracker
https://bugs.python.org/issue37405
_______________________________________