Skip to content

Commit 44c1cd4

Browse files
authored
Merge branch 'main' into gh-122320-limit-dict-keys-versions
2 parents 1a88601 + 4f18916 commit 44c1cd4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+624
-345
lines changed

Doc/c-api/arg.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,19 @@ small to receive the value.
274274
Convert a Python integer to a C :c:expr:`unsigned long` without
275275
overflow checking.
276276

277+
.. versionchanged:: next
278+
Use :meth:`~object.__index__` if available.
279+
277280
``L`` (:class:`int`) [long long]
278281
Convert a Python integer to a C :c:expr:`long long`.
279282

280283
``K`` (:class:`int`) [unsigned long long]
281284
Convert a Python integer to a C :c:expr:`unsigned long long`
282285
without overflow checking.
283286

287+
.. versionchanged:: next
288+
Use :meth:`~object.__index__` if available.
289+
284290
``n`` (:class:`int`) [:c:type:`Py_ssize_t`]
285291
Convert a Python integer to a C :c:type:`Py_ssize_t`.
286292

Doc/library/socket.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ Constants
476476
network interface instead of its name.
477477

478478
.. versionchanged:: 3.14
479-
Added missing ``IP_RECVERR``, ``IPV6_RECVERR``, ``IP_RECVTTL``, and
480-
``IP_RECVORIGDSTADDR`` on Linux.
479+
Added missing ``IP_FREEBIND``, ``IP_RECVERR``, ``IPV6_RECVERR``,
480+
``IP_RECVTTL``, and ``IP_RECVORIGDSTADDR`` on Linux.
481481

482482
.. versionchanged:: 3.14
483483
Added support for ``TCP_QUICKACK`` on Windows platforms when available.

Doc/whatsnew/3.14.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,11 @@ New features
20732073
Adding ``?`` after any format unit makes ``None`` be accepted as a value.
20742074
(Contributed by Serhiy Storchaka in :gh:`112068`.)
20752075

2076+
* The ``k`` and ``K`` formats in :c:func:`PyArg_ParseTuple` and
2077+
similar functions now use :meth:`~object.__index__` if available,
2078+
like all other integer formats.
2079+
(Contributed by Serhiy Storchaka in :gh:`112068`.)
2080+
20762081
* Add macros :c:func:`Py_PACK_VERSION` and :c:func:`Py_PACK_FULL_VERSION` for
20772082
bit-packing Python version numbers.
20782083
(Contributed by Petr Viktorin in :gh:`128629`.)

Include/internal/pycore_crossinterp.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,26 +97,22 @@ PyAPI_FUNC(void) _PyXIData_Free(_PyXIData_t *data);
9797

9898
typedef int (*xidatafunc)(PyThreadState *tstate, PyObject *, _PyXIData_t *);
9999

100-
typedef struct _xid_lookup_state _PyXIData_lookup_t;
101-
102-
typedef struct {
103-
_PyXIData_lookup_t *global;
104-
_PyXIData_lookup_t *local;
105-
PyObject *PyExc_NotShareableError;
106-
} _PyXIData_lookup_context_t;
107-
108-
PyAPI_FUNC(int) _PyXIData_GetLookupContext(
109-
PyInterpreterState *,
110-
_PyXIData_lookup_context_t *);
100+
PyAPI_FUNC(PyObject *) _PyXIData_GetNotShareableErrorType(PyThreadState *);
101+
PyAPI_FUNC(void) _PyXIData_SetNotShareableError(PyThreadState *, const char *);
102+
PyAPI_FUNC(void) _PyXIData_FormatNotShareableError(
103+
PyThreadState *,
104+
const char *,
105+
...);
111106

112107
PyAPI_FUNC(xidatafunc) _PyXIData_Lookup(
113-
_PyXIData_lookup_context_t *,
108+
PyThreadState *,
114109
PyObject *);
115110
PyAPI_FUNC(int) _PyObject_CheckXIData(
116-
_PyXIData_lookup_context_t *,
111+
PyThreadState *,
117112
PyObject *);
113+
118114
PyAPI_FUNC(int) _PyObject_GetXIData(
119-
_PyXIData_lookup_context_t *,
115+
PyThreadState *,
120116
PyObject *,
121117
_PyXIData_t *);
122118

@@ -171,6 +167,8 @@ PyAPI_FUNC(void) _PyXIData_Clear( PyInterpreterState *, _PyXIData_t *);
171167
/* runtime state & lifecycle */
172168
/*****************************/
173169

170+
typedef struct _xid_lookup_state _PyXIData_lookup_t;
171+
174172
typedef struct {
175173
// builtin types
176174
_PyXIData_lookup_t data_lookup;

Include/internal/pycore_crossinterp_data_registry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ typedef struct {
2828
} _PyXIData_registry_t;
2929

3030
PyAPI_FUNC(int) _PyXIData_RegisterClass(
31-
_PyXIData_lookup_context_t *,
31+
PyThreadState *,
3232
PyTypeObject *,
3333
xidatafunc);
3434
PyAPI_FUNC(int) _PyXIData_UnregisterClass(
35-
_PyXIData_lookup_context_t *,
35+
PyThreadState *,
3636
PyTypeObject *);
3737

3838
struct _xid_lookup_state {

Include/internal/pycore_pyerrors.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ extern PyObject* _PyErr_SetImportErrorWithNameFrom(
6060
PyObject *,
6161
PyObject *,
6262
PyObject *);
63+
extern int _PyErr_SetModuleNotFoundError(PyObject *name);
6364

6465

6566
/* runtime lifecycle */
@@ -113,6 +114,7 @@ extern void _PyErr_SetObject(
113114
PyObject *value);
114115

115116
extern void _PyErr_ChainStackItem(void);
117+
extern void _PyErr_ChainExceptions1Tstate(PyThreadState *, PyObject *);
116118

117119
PyAPI_FUNC(void) _PyErr_Clear(PyThreadState *tstate);
118120

@@ -148,6 +150,12 @@ PyAPI_FUNC(PyObject*) _PyErr_Format(
148150
const char *format,
149151
...);
150152

153+
PyAPI_FUNC(PyObject*) _PyErr_FormatV(
154+
PyThreadState *tstate,
155+
PyObject *exception,
156+
const char *format,
157+
va_list vargs);
158+
151159
extern void _PyErr_NormalizeException(
152160
PyThreadState *tstate,
153161
PyObject **exc,

Lib/pdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ def do_quit(self, arg):
18341834
reply = 'y'
18351835
self.message('')
18361836
if reply == 'y' or reply == '':
1837-
sys.exit(0)
1837+
sys.exit(1)
18381838
elif reply.lower() == 'n':
18391839
return
18401840

Lib/test/clinic.test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ test_unsigned_long_converter(PyObject *module, PyObject *const *args, Py_ssize_t
14101410
if (nargs < 3) {
14111411
goto skip_optional;
14121412
}
1413-
if (!PyLong_Check(args[2])) {
1413+
if (!PyIndex_Check(args[2])) {
14141414
_PyArg_BadArgument("test_unsigned_long_converter", "argument 3", "int", args[2]);
14151415
goto exit;
14161416
}
@@ -1425,7 +1425,7 @@ test_unsigned_long_converter(PyObject *module, PyObject *const *args, Py_ssize_t
14251425
static PyObject *
14261426
test_unsigned_long_converter_impl(PyObject *module, unsigned long a,
14271427
unsigned long b, unsigned long c)
1428-
/*[clinic end generated code: output=540bb0ba2894e1fe input=f450d94cae1ef73b]*/
1428+
/*[clinic end generated code: output=d74eed227d77a31b input=f450d94cae1ef73b]*/
14291429

14301430

14311431
/*[clinic input]
@@ -1525,7 +1525,7 @@ test_unsigned_long_long_converter(PyObject *module, PyObject *const *args, Py_ss
15251525
if (nargs < 3) {
15261526
goto skip_optional;
15271527
}
1528-
if (!PyLong_Check(args[2])) {
1528+
if (!PyIndex_Check(args[2])) {
15291529
_PyArg_BadArgument("test_unsigned_long_long_converter", "argument 3", "int", args[2]);
15301530
goto exit;
15311531
}
@@ -1542,7 +1542,7 @@ test_unsigned_long_long_converter_impl(PyObject *module,
15421542
unsigned long long a,
15431543
unsigned long long b,
15441544
unsigned long long c)
1545-
/*[clinic end generated code: output=3d69994f618b46bb input=a15115dc41866ff4]*/
1545+
/*[clinic end generated code: output=5ca4e4dfb3db644b input=a15115dc41866ff4]*/
15461546

15471547

15481548
/*[clinic input]

Lib/test/pythoninfo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def collect_sys(info_add):
146146
text = 'No (sys.getobjects() missing)'
147147
info_add('build.Py_TRACE_REFS', text)
148148

149+
info_add('sys.is_remote_debug_enabled', sys.is_remote_debug_enabled())
150+
149151

150152
def collect_platform(info_add):
151153
import platform
@@ -528,6 +530,7 @@ def collect_sysconfig(info_add):
528530
'Py_DEBUG',
529531
'Py_ENABLE_SHARED',
530532
'Py_GIL_DISABLED',
533+
'Py_REMOTE_DEBUG',
531534
'SHELL',
532535
'SOABI',
533536
'TEST_MODULES',

Lib/test/test__interpreters.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
_interpreters = import_helper.import_module('_interpreters')
1717
_testinternalcapi = import_helper.import_module('_testinternalcapi')
18-
from _interpreters import InterpreterNotFoundError
18+
from _interpreters import InterpreterNotFoundError, NotShareableError
1919

2020

2121
##################################
@@ -189,8 +189,9 @@ def test_non_shareable_int(self):
189189
]
190190
for i in ints:
191191
with self.subTest(i):
192-
with self.assertRaises(OverflowError):
192+
with self.assertRaises(NotShareableError) as cm:
193193
_testinternalcapi.get_crossinterp_data(i)
194+
self.assertIsInstance(cm.exception.__cause__, OverflowError)
194195

195196
def test_bool(self):
196197
self._assert_values([True, False])
@@ -215,14 +216,12 @@ def test_tuples_containing_non_shareable_types(self):
215216
for s in non_shareables:
216217
value = tuple([0, 1.0, s])
217218
with self.subTest(repr(value)):
218-
# XXX Assert the NotShareableError when it is exported
219-
with self.assertRaises(ValueError):
219+
with self.assertRaises(NotShareableError):
220220
_testinternalcapi.get_crossinterp_data(value)
221221
# Check nested as well
222222
value = tuple([0, 1., (s,)])
223223
with self.subTest("nested " + repr(value)):
224-
# XXX Assert the NotShareableError when it is exported
225-
with self.assertRaises(ValueError):
224+
with self.assertRaises(NotShareableError):
226225
_testinternalcapi.get_crossinterp_data(value)
227226

228227

0 commit comments

Comments
 (0)