Skip to content

Commit 69e94e0

Browse files
authored
gh-111178: Fix function signatures for test_socket (#131667)
Add unicode_fsdecode() wrapper for PyUnicode_DecodeFSDefault() to use the correct API for Py_BuildValue() converter API.
1 parent 4efe397 commit 69e94e0

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Modules/socketmodule.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,11 @@ makebdaddr(bdaddr_t *bdaddr)
13801380
}
13811381
#endif
13821382

1383+
PyObject*
1384+
unicode_fsdecode(void *arg)
1385+
{
1386+
return PyUnicode_DecodeFSDefault((const char*)arg);
1387+
}
13831388

13841389
/* Create an object representing the given socket address,
13851390
suitable for passing it back to bind(), connect() etc.
@@ -1616,26 +1621,25 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
16161621
#ifdef CAN_ISOTP
16171622
case CAN_ISOTP:
16181623
{
1619-
return Py_BuildValue("O&kk", PyUnicode_DecodeFSDefault,
1620-
ifname,
1621-
a->can_addr.tp.rx_id,
1622-
a->can_addr.tp.tx_id);
1624+
return Py_BuildValue("O&kk", unicode_fsdecode,
1625+
ifname,
1626+
a->can_addr.tp.rx_id,
1627+
a->can_addr.tp.tx_id);
16231628
}
16241629
#endif /* CAN_ISOTP */
16251630
#ifdef CAN_J1939
16261631
case CAN_J1939:
16271632
{
1628-
return Py_BuildValue("O&KIB", PyUnicode_DecodeFSDefault,
1629-
ifname,
1630-
(unsigned long long)a->can_addr.j1939.name,
1631-
(unsigned int)a->can_addr.j1939.pgn,
1632-
a->can_addr.j1939.addr);
1633+
return Py_BuildValue("O&KIB", unicode_fsdecode,
1634+
ifname,
1635+
(unsigned long long)a->can_addr.j1939.name,
1636+
(unsigned int)a->can_addr.j1939.pgn,
1637+
a->can_addr.j1939.addr);
16331638
}
16341639
#endif /* CAN_J1939 */
16351640
default:
16361641
{
1637-
return Py_BuildValue("(O&)", PyUnicode_DecodeFSDefault,
1638-
ifname);
1642+
return Py_BuildValue("(O&)", unicode_fsdecode, ifname);
16391643
}
16401644
}
16411645
}
@@ -7161,7 +7165,7 @@ socket_if_nameindex(PyObject *self, PyObject *arg)
71617165
}
71627166
#endif
71637167
PyObject *ni_tuple = Py_BuildValue("IO&",
7164-
ni[i].if_index, PyUnicode_DecodeFSDefault, ni[i].if_name);
7168+
ni[i].if_index, unicode_fsdecode, ni[i].if_name);
71657169

71667170
if (ni_tuple == NULL || PyList_Append(list, ni_tuple) == -1) {
71677171
Py_XDECREF(ni_tuple);

0 commit comments

Comments
 (0)