8000 Merge branch 'main' into specialize-load-attr · python/cpython@6d9ef8d · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d9ef8d

Browse files
committed
Merge branch 'main' into specialize-load-attr
2 parents b07f219 + 5571cab commit 6d9ef8d

26 files changed

+764
-439
lines changed

.github/workflows/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: 'Install build dependencies'
3939
run: make -C Doc/ PYTHON=../python venv
4040
- name: 'Build documentation'
41-
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" doctest html suspicious
41+
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" doctest html
4242
- name: 'Upload'
4343
uses: actions/upload-artifact@v2.2.3
4444
with:

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ matrix:
5353
- cd Doc
5454
- make venv PYTHON=python
5555
script:
56-
- make check html suspicious SPHINXOPTS="-q -W -j4"
56+
- make check html SPHINXOPTS="-q -W -j4"
5757
- name: "Documentation tests"
5858
os: linux
5959
language: c

Doc/c-api/structures.rst

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ the definition of all other Python objects.
9999
100100
Return a :term:`borrowed reference`.
101101
102-
Use the :c:func:`Py_SET_TYPE` function to set an object type.
103-
104-
.. versionchanged:: 3.11
105-
:c:func:`Py_TYPE()` is changed to an inline static function.
102+
The :c:func:`Py_SET_TYPE` function must be used to set an object type.
106103
107104
108105
.. c:function:: int Py_IS_TYPE(PyObject *o, PyTypeObject *type)
@@ -124,10 +121,9 @@ the definition of all other Python objects.
124121
125122
Get the reference count of the Python object *o*.
126123
127-
Use the :c:func:`Py_SET_REFCNT()` function to set an object reference count.
128-
129124
.. versionchanged:: 3.10
130125
:c:func:`Py_REFCNT()` is changed to the inline static function.
126+
Use :c:func:`Py_SET_REFCNT()` to set an object reference count.
131127
132128
133129
.. c:function:: void Py_SET_REFCNT(PyObject *o, Py_ssize_t refcnt)
@@ -141,10 +137,7 @@ the definition of all other Python objects.
141137
142138
Get the size of the Python object *o*.
143139
144-
Use the :c:func:`Py_SET_SIZE` function to set an object size.
145-
146-
.. versionchanged:: 3.11
147-
:c:func:`Py_SIZE()` is changed to an inline static function.
140+
The :c:func:`Py_SET_SIZE` function must be used to set an object size.
148141
149142
150143
.. c:function:: void Py_SET_SIZE(PyVarObject *o, Py_ssize_t size)

Doc/whatsnew/3.10.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,17 @@ Optimizations
14441444
Deprecated
14451445
==========
14461446
1447+
* Currently Python accepts numeric literals immediately followed by keywords,
1448+
for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing
1449+
and ambigious expressions like ``[0x1for x in y]`` (which can be
1450+
interpreted as ``[0x1 for x in y]`` or ``[0x1f or x in y]``). Starting in
1451+
this release, a deprecation warning is raised if the numeric literal is
1452+
immediately followed by one of keywords :keyword:`and`, :keyword:`else`,
1453+
:keyword:`for`, :keyword:`if`, :keyword:`in`, :keyword:`is` and :keyword:`or`.
1454+
If future releases it will be changed to syntax warning, and finally to
1455+
syntax error.
1456+
(Contributed by Serhiy Storchaka in :issue:`43833`).
1457+
14471458
* Starting in this release, there will be a concerted effort to begin
14481459
cleaning up old import semantics that were kept for Python 2.7
14491460
compatibility. Specifically,
@@ -1670,6 +1681,18 @@ This section lists previously described changes and other bugfixes
16701681
that may require changes to your code.
16711682
16721683
1684+
Changes in the Python syntax
1685+
----------------------------
1686+
1687+
* Deprecation warning is now emitted when compiling previously valid syntax
1688+
if the numeric literal is immediately followed by a keyword (like in ``0in x``).
1689+
If future releases it will be changed to syntax warning, and finally to a
1690+
syntax error. To get rid of the warning and make the code compatible with
1691+
future releases just add a space between the numeric literal and the
1692+
following keyword.
1693+
(Contributed by Serhiy Storchaka in :issue:`43833`).
1694+
1695+
16731696
Changes in the Python API
16741697
-------------------------
16751698
@@ -1791,6 +1814,16 @@ Build Changes
17911814
C API Changes
17921815
=============
17931816
1817+
PEP 652: Maintaining the Stable ABI
1818+
-----------------------------------
1819+
1820+
The Stable ABI (Application Binary Interface) for extension modules or
1821+
embedding Python is now explicitly defined.
1822+
:ref:`stable` describes C API and ABI stability guarantees along with best
1823+
practices for using the Stable ABI.
1824+
1825+
(Contributed by Petr Viktorin in :pep:`652` and :issue:`43795`.)
1826+
17941827
New Features
17951828
------------
17961829

Doc/whatsnew/3.11.rst

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -154,34 +154,6 @@ Porting to Python 3.11
154154
(:c:member:`PyTypeObject.tp_traverse`).
155155
(Contributed by Victor Stinner in :issue:`44263`.)
156156

157-
* Since :c:func:`Py_TYPE()` is changed to a inline static function,
158-
``Py_TYPE(obj) = new_type`` must be replaced with
159-
``Py_SET_TYPE(obj, new_type)``: see the :c:func:`Py_SET_TYPE()` function
160-
(available since Python 3.9). For backward compatibility, this macro can be
161-
used::
162-
163-
#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
164-
static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type)
165-
{ ob->ob_type = type; }
166-
#define Py_SET_TYPE(ob, type) _Py_SET_TYPE(_PyObject_CAST(ob), type)
167-
#endif
168-
169-
(Contributed by Victor Stinner in :issue:`39573`.)
170-
171-
* Since :c:func:`Py_SIZE()` is changed to a inline static function,
172-
``Py_SIZE(obj) = new_size`` must be replaced with
173-
``Py_SET_SIZE(obj, new_size)``: see the :c:func:`Py_SET_SIZE()` function
174-
(available since Python 3.9). For backward compatibility, this macro can be
175-
used::
176-
177-
#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_SIZE)
178-
static inline void _Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size)
179-
{ ob->ob_size = size; }
180-
#define Py_SET_SIZE(ob, size) _Py_SET_SIZE((PyVarObject*)(ob), size)
181-
#endif
182-
183-
(Contributed by Victor Stinner in :issue:`39573`.)
184-
185157
Deprecated
186158
----------
187159

Include/object.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,10 @@ static inline Py_ssize_t _Py_REFCNT(const PyObject *ob) {
134134

135135

136136
// bpo-39573: The Py_SET_TYPE() function must be used to set an object type.
137-
static inline PyTypeObject* _Py_TYPE(const PyObject *ob) {
138-
return ob->ob_type;
139-
}
140-
#define Py_TYPE(ob) _Py_TYPE(_PyObject_CAST_CONST(ob))
137+
#define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
141138

142139
// bpo-39573: The Py_SET_SIZE() function must be used to set an object size.
143-
static inline Py_ssize_t _Py_SIZE(const PyVarObject *ob) {
144-
return ob->ob_size;
145-
}
146-
#define Py_SIZE(ob) _Py_SIZE(_PyVarObject_CAST_CONST(ob))
140+
#define Py_SIZE(ob) (_PyVarObject_CAST(ob)->ob_size)
147141

148142

149143
static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {

Lib/concurrent/futures/process.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
from functools import partial
5757
import itertools
5858
import sys
59-
import traceback
59+
from traceback import format_exception
6060

6161

6262
_threads_wakeups = weakref.WeakKeyDictionary()
@@ -123,8 +123,7 @@ def __str__(self):
123123

124124
class _ExceptionWithTraceback:
125125
def __init__(self, exc, tb):
126-
tb = traceback.format_exception(type(exc), exc, tb)
127-
tb = ''.join(tb)
126+
tb = ''.join(format_exception(type(exc), exc, tb))
128127
self.exc = exc
129128
self.tb = '\n"""\n%s"""' % tb
130129
def __reduce__(self):
@@ -166,7 +165,7 @@ def __init__(self, max_size=0, *, ctx, pending_work_items, shutdown_lock,
166165

167166
def _on_queue_feeder_error(self, e, obj):
168167
if isinstance(obj, _CallItem):
169-
tb = traceback.format_exception(type(e), e, e.__traceback__)
168+
tb = format_exception(type(e), e, e.__traceback__)
170169
e.__cause__ = _RemoteTraceback('\n"""\n{}"""'.format(''.join(tb)))
171170
work_item = self.pending_work_items.pop(obj.work_id, None)
172171
with self.shutdown_lock:
@@ -384,7 +383,7 @@ def wait_result_broken_or_wakeup(self):
384383
result_item = result_reader.recv()
385384
is_broken = False
386385
except BaseException as e:
387-
cause = traceback.format_exception(type(e), e, e.__traceback__)
386+
cause = format_exception(type(e), e, e.__traceback__)
388387

389388
elif wakeup_reader in ready:
390389
is_broken = False

0 commit comments

Comments
 (0)
0