classification
Title: socket.getsockname() returns string instead of tuple
Type: behavior Stage: patch review
Components: Documentation, Extension Modules Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Brent Gardner, christian.heimes, docs@python
Priority: normal Keywords: patch

Created on 2019-06-25 21:01 by Brent Gardner, last changed 2019-06-26 12:01 by python-dev.

Pull Requests
URL Status Linked Edit
PR 14392 open python-dev, 2019-06-26 12:01
Messages (3)
msg346559 - (view) Author: Brent Gardner (Brent Gardner) * Date: 2019-06-25 21:01
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'
msg346579 - (view) Author: Brent Gardner (Brent Gardner) * Date: 2019-06-26 02:51
Changed caused by commit effc12f8e9e20d0951d2ba5883587666bd8218e3 to cpython/Modules/socketmodule.c on Sep 6, 2017.
msg346580 - (view) Author: Brent Gardner (Brent Gardner) * Date: 2019-06-26 02:54
Correction, change caused by a30f6d45ac3e72761b96a8df0527182029eaee24 to cpython/Modules/socketmodule.c on Aug 28, 2017.
History
Date User Action Args
2019-06-26 12:01:59python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request14206
2019-06-26 05:31:55ned.deilysetnosy: + christian.heimes
2019-06-26 02:54:32Brent Gardnersetmessages: + msg346580
2019-06-26 02:51:26Brent Gardnersetmessages: + msg346579
components: + Extension Modules
2019-06-25 21:01:33Brent Gardnersettype: behavior
2019-06-25 21:01:17Brent Gardnercreate