Skip to content

Commit a85989c

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/implement-issue-117829' into implement-issue-117829
2 parents ab215b7 + c4b7cd1 commit a85989c

File tree

123 files changed

+6170
-4330
lines changed

Some content is hidden

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

123 files changed

+6170
-4330
lines changed

Doc/reference/datamodel.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,8 @@ Basic customization
16671667

16681668
It is not guaranteed that :meth:`__del__` methods are called for objects
16691669
that still exist when the interpreter exits.
1670+
:class:`weakref.finalize` provides a straightforward way to register
1671+
a cleanup function to be called when an object is garbage collected.
16701672

16711673
.. note::
16721674

Doc/whatsnew/3.13.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,12 @@ Changes in the Python API
22622262
returned by :meth:`zipfile.ZipFile.open` was changed from ``'r'`` to ``'rb'``.
22632263
(Contributed by Serhiy Storchaka in :gh:`115961`.)
22642264

2265+
* :class:`functools.partial` now emits a :exc:`FutureWarning` when it is
2266+
used as a method.
2267+
Its behavior will be changed in future Python versions.
2268+
Wrap it in :func:`staticmethod` if you want to preserve the old behavior.
2269+
(Contributed by Serhiy Storchaka in :gh:`121027`.)
2270+
22652271
.. _pep667-porting-notes-py:
22662272

22672273
* Calling :func:`locals` in an :term:`optimized scope` now produces an

Include/Python.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,5 @@
132132
#include "fileutils.h"
133133
#include "cpython/pyfpe.h"
134134
#include "cpython/tracemalloc.h"
135-
#include "cpython/optimizer.h"
136135

137136
#endif /* !Py_PYTHON_H */

Include/cpython/code.h

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -24,58 +24,6 @@ typedef struct _Py_GlobalMonitors {
2424
uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
2525
} _Py_GlobalMonitors;
2626

27-
typedef struct {
28-
union {
29-
struct {
30-
uint16_t backoff : 4;
31-
uint16_t value : 12;
32-
};
33-
uint16_t as_counter; // For printf("%#x", ...)
34-
};
35-
} _Py_BackoffCounter;
36-
37-
/* Each instruction in a code object is a fixed-width value,
38-
* currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG
39-
* opcode allows for larger values but the current limit is 3 uses
40-
* of EXTENDED_ARG (see Python/compile.c), for a maximum
41-
* 32-bit value. This aligns with the note in Python/compile.c
42-
* (compiler_addop_i_line) indicating that the max oparg value is
43-
* 2**32 - 1, rather than INT_MAX.
44-
*/
45-
46-
typedef union {
47-
uint16_t cache;
48-
struct {
49-
uint8_t code;
50-
uint8_t arg;
51-
} op;
52-
_Py_BackoffCounter counter; // First cache entry of specializable op
53-
} _Py_CODEUNIT;
54-
55-
56-
/* These macros only remain defined for compatibility. */
57-
#define _Py_OPCODE(word) ((word).op.code)
58-
#define _Py_OPARG(word) ((word).op.arg)
59-
60-
static inline _Py_CODEUNIT
61-
_py_make_codeunit(uint8_t opcode, uint8_t oparg)
62-
{
63-
// No designated initialisers because of C++ compat
64-
_Py_CODEUNIT word;
65-
word.op.code = opcode;
66-
word.op.arg = oparg;
67-
return word;
68-
}
69-
70-
static inline void
71-
_py_set_opcode(_Py_CODEUNIT *word, uint8_t opcode)
72-
{
73-
word->op.code = opcode;
74-
}
75-
76-
#define _Py_MAKE_CODEUNIT(opcode, oparg) _py_make_codeunit((opcode), (oparg))
77-
#define _Py_SET_OPCODE(word, opcode) _py_set_opcode(&(word), (opcode))
78-
7927

8028
typedef struct {
8129
PyObject *_co_code;

Include/cpython/longintrepr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ PyAPI_FUNC(PyLongObject*) _PyLong_FromDigits(
119119

120120

121121
static inline int
122-
_PyLong_IsCompact(const PyLongObject* op) {
122+
_PyLong_IsCompact(PyLongObject* op) {
123123
assert(PyType_HasFeature(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS));
124124
return op->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS);
125125
}
126126

127127
#define PyUnstable_Long_IsCompact _PyLong_IsCompact
128128

129129
static inline Py_ssize_t
130-
_PyLong_CompactValue(const PyLongObject *op)
130+
_PyLong_CompactValue(PyLongObject *op)
131131
{
132132
Py_ssize_t sign;
133133
assert(PyType_HasFeature(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS));

Include/cpython/optimizer.h

Lines changed: 0 additions & 135 deletions
This file was deleted.

Include/cpython/pyatomic_gcc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ _Py_atomic_load_ssize(const Py_ssize_t *obj)
297297

298298
static inline void *
299299
_Py_atomic_load_ptr(const void *obj)
300-
{ return (void *)__atomic_load_n((void **)obj, __ATOMIC_SEQ_CST); }
300+
{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_SEQ_CST); }
301301

302302

303303
// --- _Py_atomic_load_relaxed -----------------------------------------------
@@ -356,7 +356,7 @@ _Py_atomic_load_ssize_relaxed(const Py_ssize_t *obj)
356356

357357
static inline void *
358358
_Py_atomic_load_ptr_relaxed(const void *obj)
359-
{ return (void *)__atomic_load_n((const void **)obj, __ATOMIC_RELAXED); }
359+
{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_RELAXED); }
360360

361361
static inline unsigned long long
362362
_Py_atomic_load_ullong_relaxed(const unsigned long long *obj)
@@ -490,11 +490,11 @@ _Py_atomic_store_ullong_relaxed(unsigned long long *obj,
490490

491491
static inline void *
492492
_Py_atomic_load_ptr_acquire(const void *obj)
493-
{ return (void *)__atomic_load_n((void **)obj, __ATOMIC_ACQUIRE); }
493+
{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_ACQUIRE); }
494494

495495
static inline uintptr_t
496496
_Py_atomic_load_uintptr_acquire(const uintptr_t *obj)
497-
{ return (uintptr_t)__atomic_load_n((uintptr_t *)obj, __ATOMIC_ACQUIRE); }
497+
{ return (uintptr_t)__atomic_load_n(obj, __ATOMIC_ACQUIRE); }
498498

499499
static inline void
500500
_Py_atomic_store_ptr_release(void *obj, void *value)

Include/exports.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@
4141
* we may still need to support gcc >= 4, as some Ubuntu LTS and Centos versions
4242
* have 4 < gcc < 5.
4343
*/
44-
#ifndef __has_attribute
45-
#define __has_attribute(x) 0 // Compatibility with non-clang compilers.
46-
#endif
4744
#if (defined(__GNUC__) && (__GNUC__ >= 4)) ||\
48-
(defined(__clang__) && __has_attribute(visibility))
45+
(defined(__clang__) && _Py__has_attribute(visibility))
4946
#define Py_IMPORTED_SYMBOL __attribute__ ((visibility ("default")))
5047
#define Py_EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
5148
#define Py_LOCAL_SYMBOL __attribute__ ((visibility ("hidden")))

Include/internal/pycore_backoff.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ extern "C" {
1313
#include <stdbool.h>
1414
#include <stdint.h>
1515

16+
17+
typedef struct {
18+
union {
19+
struct {
20+
uint16_t backoff : 4;
21+
uint16_t value : 12;
22+
};
23+
uint16_t as_counter; // For printf("%#x", ...)
24+
};
25+
} _Py_BackoffCounter;
26+
27+
1628
/* 16-bit countdown counters using exponential backoff.
1729
1830
These are used by the adaptive specializer to count down until

Include/internal/pycore_call.h

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

11-
#include "pycore_identifier.h" // _Py_Identifier
1211
#include "pycore_pystate.h" // _PyThreadState_GET()
1312

1413
/* Suggested size (number of positional arguments) for arrays of PyObject*

0 commit comments

Comments
 (0)