Skip to content

Commit a7abcdc

Browse files
authored
Merge branch 'main' into gh-130099-2
2 parents d38929e + 17d06ae commit a7abcdc

File tree

156 files changed

+3257
-1293
lines changed

Some content is hidden

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

156 files changed

+3257
-1293
lines changed

Doc/library/stdtypes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,6 +2744,10 @@ data and are closely related to string objects in a variety of other ways.
27442744
:meth:`bytes.fromhex` now skips all ASCII whitespace in the string,
27452745
not just spaces.
27462746

2747+
.. versionchanged:: next
2748+
:meth:`bytes.fromhex` now accepts ASCII :class:`bytes` and
2749+
:term:`bytes-like objects <bytes-like object>` as input.
2750+
27472751
A reverse conversion function exists to transform a bytes object into its
27482752
hexadecimal representation.
27492753

@@ -2829,6 +2833,10 @@ objects.
28292833
:meth:`bytearray.fromhex` now skips all ASCII whitespace in the string,
28302834
not just spaces.
28312835

2836+
.. versionchanged:: next
2837+
:meth:`bytearray.fromhex` now accepts ASCII :class:`bytes` and
2838+
:term:`bytes-like objects <bytes-like object>` as input.
2839+
28322840
A reverse conversion function exists to transform a bytearray object into its
28332841
hexadecimal representation.
28342842

Doc/library/typing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2771,7 +2771,7 @@ types.
27712771

27722772
.. versionadded:: 3.13
27732773

2774-
See :pep:`589` for more examples and detailed rules of using ``TypedDict``.
2774+
See the `TypedDict <https://typing.python.org/en/latest/spec/typeddict.html#typeddict>`_ section in the typing documentation for more examples and detailed rules.
27752775

27762776
.. versionadded:: 3.8
27772777

Doc/whatsnew/3.14.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ Other language changes
354354
(with :func:`format` or :ref:`f-strings`).
355355
(Contrubuted by Sergey B Kirpichev in :gh:`87790`.)
356356

357+
* The :func:`bytes.fromhex` and :func:`bytearray.fromhex` methods now accept
358+
ASCII :class:`bytes` and :term:`bytes-like objects <bytes-like object>`.
359+
(Contributed by Daniel Pope in :gh:`129349`.)
360+
357361
* ``\B`` in :mod:`regular expression <re>` now matches empty input string.
358362
Now it is always the opposite of ``\b``.
359363
(Contributed by Serhiy Storchaka in :gh:`124130`.)

Include/cpython/pyatomic_gcc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ _Py_atomic_store_ullong_relaxed(unsigned long long *obj,
519519

520520
static inline void
521521
_Py_atomic_store_char_relaxed(char *obj, char value)
522-
{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); }
522+
{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }
523523

524524
static inline void
525525
_Py_atomic_store_uchar_relaxed(unsigned char *obj, unsigned char value)

Include/internal/pycore_condvar.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#define Py_HAVE_CONDVAR
3232

3333
/* include windows if it hasn't been done before */
34-
#define WIN32_LEAN_AND_MEAN
34+
#ifndef WIN32_LEAN_AND_MEAN
35+
# define WIN32_LEAN_AND_MEAN
36+
#endif
3537
#include <windows.h> // CRITICAL_SECTION
3638

3739
/* options */

Include/internal/pycore_list.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11+
#ifdef Py_GIL_DISABLED
12+
#include "pycore_stackref.h"
13+
#endif
14+
1115
PyAPI_FUNC(PyObject*) _PyList_Extend(PyListObject *, PyObject *);
1216
extern void _PyList_DebugMallocStats(FILE *out);
1317
// _PyList_GetItemRef should be used only when the object is known as a list
1418
// because it doesn't raise TypeError when the object is not a list, whereas PyList_GetItemRef does.
1519
extern PyObject* _PyList_GetItemRef(PyListObject *, Py_ssize_t i);
20+
#ifdef Py_GIL_DISABLED
21+
// Returns -1 in case of races with other threads.
22+
extern int _PyList_GetItemRefNoLock(PyListObject *, Py_ssize_t, _PyStackRef *);
23+
#endif
1624

1725
#define _PyList_ITEMS(op) _Py_RVALUE(_PyList_CAST(op)->ob_item)
1826

Include/internal/pycore_object.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,20 @@ static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
135135
_Py_INCREF_IMMORTAL_STAT_INC();
136136
return;
137137
}
138-
#ifdef Py_REF_DEBUG
139-
_Py_AddRefTotal(_PyThreadState_GET(), n);
140-
#endif
141-
#if !defined(Py_GIL_DISABLED)
142-
#if SIZEOF_VOID_P > 4
143-
op->ob_refcnt += (PY_UINT32_T)n;
144-
#else
145-
op->ob_refcnt += n;
146-
#endif
138+
#ifndef Py_GIL_DISABLED
139+
Py_ssize_t refcnt = _Py_REFCNT(op);
140+
Py_ssize_t new_refcnt = refcnt + n;
141+
if (new_refcnt >= (Py_ssize_t)_Py_IMMORTAL_MINIMUM_REFCNT) {
142+
new_refcnt = _Py_IMMORTAL_INITIAL_REFCNT;
143+
}
144+
# if SIZEOF_VOID_P > 4
145+
op->ob_refcnt = (PY_UINT32_T)new_refcnt;
146+
# else
147+
op->ob_refcnt = new_refcnt;
148+
# endif
149+
# ifdef Py_REF_DEBUG
150+
_Py_AddRefTotal(_PyThreadState_GET(), new_refcnt - refcnt);
151+
# endif
147152
#else
148153
if (_Py_IsOwnedByCurrentThread(op)) {
149154
uint32_t local = op->ob_ref_local;
@@ -160,6 +165,9 @@ static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
160165
else {
161166
_Py_atomic_add_ssize(&op->ob_ref_shared, (n << _Py_REF_SHARED_SHIFT));
162167
}
168+
# ifdef Py_REF_DEBUG
169+
_Py_AddRefTotal(_PyThreadState_GET(), n);
170+
# endif
163171
#endif
164172
// Although the ref count was increased by `n` (which may be greater than 1)
165173
// it is only a single increment (i.e. addition) operation, so only 1 refcnt

Include/internal/pycore_opcode_metadata.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_semaphore.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include "pycore_pythread.h" // _POSIX_SEMAPHORES
1111

1212
#ifdef MS_WINDOWS
13-
# define WIN32_LEAN_AND_MEAN
13+
# ifndef WIN32_LEAN_AND_MEAN
14+
# define WIN32_LEAN_AND_MEAN
15+
# endif
1416
# include <windows.h>
1517
#elif defined(HAVE_PTHREAD_H)
1618
# include <pthread.h>

Include/internal/pycore_uop_ids.h

Lines changed: 77 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)