File tree 5 files changed +15
-7
lines changed
5 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 40
40
- ' pypy-3.8'
41
41
- ' pypy-3.9'
42
42
- ' pypy-3.10'
43
+ - ' pypy-3.11'
43
44
- ' graalpy-24.1'
44
45
45
46
# Items in here will either be added to the build matrix (if not
Original file line number Diff line number Diff line change @@ -81,9 +81,11 @@ The following table provides an overview of available policies:
81
81
| | it is no longer used. Warning: undefined behavior will ensue when the C++ |
82
82
| | side deletes an object that is still referenced and used by Python. |
83
83
+--------------------------------------------------+----------------------------------------------------------------------------+
84
- | :enum: `return_value_policy::reference_internal ` | Indicates that the lifetime of the return value is tied to the lifetime |
85
- | | of a parent object, namely the implicit ``this ``, or ``self `` argument of |
86
- | | the called method or property. Internally, this policy works just like |
84
+ | :enum: `return_value_policy::reference_internal ` | If the return value is an lvalue reference or a pointer, the parent object |
85
+ | | (the implicit ``this ``, or ``self `` argument of the called method or |
86
+ | | property) is kept alive for at least the lifespan of the return value. |
87
+ | | **Otherwise this policy falls back to :enum:`return_value_policy::move` |
88
+ | | (see #5528).** Internally, this policy works just like |
87
89
| | :enum: `return_value_policy::reference ` but additionally applies a |
88
90
| | ``keep_alive<0, 1> `` *call policy * (described in the next section) that |
89
91
| | prevents the parent object from being garbage collected as long as the |
Original file line number Diff line number Diff line change @@ -363,7 +363,7 @@ struct type_record {
363
363
364
364
bases.append ((PyObject *) base_info->type );
365
365
366
- #if PY_VERSION_HEX < 0x030B0000
366
+ #ifdef PYBIND11_BACKWARD_COMPATIBILITY_TP_DICTOFFSET
367
367
dynamic_attr |= base_info->type ->tp_dictoffset != 0 ;
368
368
#else
369
369
dynamic_attr |= (base_info->type ->tp_flags & Py_TPFLAGS_MANAGED_DICT) != 0 ;
Original file line number Diff line number Diff line change @@ -576,9 +576,9 @@ extern "C" inline int pybind11_clear(PyObject *self) {
576
576
inline void enable_dynamic_attributes (PyHeapTypeObject *heap_type) {
577
577
auto *type = &heap_type->ht_type ;
578
578
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
579
- #if PY_VERSION_HEX < 0x030B0000 || defined(PYPY_VERSION) // For PyPy see PR #5508
580
- type->tp_dictoffset = type->tp_basicsize ; // place dict at the end
581
- type->tp_basicsize += (ssize_t ) sizeof (PyObject *); // and allocate enough space for it
579
+ #ifdef PYBIND11_BACKWARD_COMPATIBILITY_TP_DICTOFFSET
580
+ type->tp_dictoffset = type->tp_basicsize ; // place dict at the end
581
+ type->tp_basicsize += (ssize_t ) sizeof (PyObject *); // and allocate enough space for it
582
582
#else
583
583
type->tp_flags |= Py_TPFLAGS_MANAGED_DICT;
584
584
#endif
Original file line number Diff line number Diff line change @@ -1261,5 +1261,10 @@ constexpr
1261
1261
# define PYBIND11_DETAILED_ERROR_MESSAGES
1262
1262
#endif
1263
1263
1264
+ // CPython 3.11+ provides Py_TPFLAGS_MANAGED_DICT, but PyPy3.11 does not, see PR #5508.
1265
+ #if PY_VERSION_HEX < 0x030B0000 || defined(PYPY_VERSION)
1266
+ # define PYBIND11_BACKWARD_COMPATIBILITY_TP_DICTOFFSET
1267
+ #endif
1268
+
1264
1269
PYBIND11_NAMESPACE_END (detail)
1265
1270
PYBIND11_NAMESPACE_END (PYBIND11_NAMESPACE)
You can’t perform that action at this time.
0 commit comments