Skip to content

Commit 61616fc

Browse files
committed
Catch up with master
2 parents ca6e332 + 1f43340 commit 61616fc

16 files changed

+99
-15
lines changed

Doc/c-api/arg.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ which disallows mutable objects such as :class:`bytearray`.
149149
Previously, :exc:`TypeError` was raised when embedded null code points
150150
were encountered in the Python string.
151151

152-
.. deprecated-removed:: 3.3 4.0
152+
.. deprecated-removed:: 3.3 3.12
153153
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
154154
:c:func:`PyUnicode_AsWideCharString`.
155155

@@ -158,23 +158,23 @@ which disallows mutable objects such as :class:`bytearray`.
158158
Unicode data buffer, the second one its length. This variant allows
159159
null code points.
160160

161-
.. deprecated-removed:: 3.3 4.0
161+
.. deprecated-removed:: 3.3 3.12
162162
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
163163
:c:func:`PyUnicode_AsWideCharString`.
164164

165165
``Z`` (:class:`str` or ``None``) [const Py_UNICODE \*]
166166
Like ``u``, but the Python object may also be ``None``, in which case the
167167
:c:type:`Py_UNICODE` pointer is set to ``NULL``.
168168

169-
.. deprecated-removed:: 3.3 4.0
169+
.. deprecated-removed:: 3.3 3.12
170170
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
171171
:c:func:`PyUnicode_AsWideCharString`.
172172

173173
``Z#`` (:class:`str` or ``None``) [const Py_UNICODE \*, :c:type:`Py_ssize_t`]
174174
Like ``u#``, but the Python object may also be ``None``, in which case the
175175
:c:type:`Py_UNICODE` pointer is set to ``NULL``.
176176

177-
.. deprecated-removed:: 3.3 4.0
177+
.. deprecated-removed:: 3.3 3.12
178178
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
179179
:c:func:`PyUnicode_AsWideCharString`.
180180

Doc/c-api/unicode.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ points must be below 1114112 (which is the full Unicode range).
1919

2020
:c:type:`Py_UNICODE*` and UTF-8 representations are created on demand and cached
2121
in the Unicode object. The :c:type:`Py_UNICODE*` representation is deprecated
22-
and inefficient; it should be avoided in performance- or memory-sensitive
23-
situations.
22+
and inefficient.
2423

2524
Due to the transition between the old APIs and the new APIs, Unicode objects
2625
can internally be in two states depending on how they were created:
@@ -434,7 +433,7 @@ APIs:
434433
435434
If *u* is ``NULL``, this function behaves like :c:func:`PyUnicode_FromUnicode`
436435
with the buffer set to ``NULL``. This usage is deprecated in favor of
437-
:c:func:`PyUnicode_New`.
436+
:c:func:`PyUnicode_New`, and will be removed in Python 3.12.
438437
439438
440439
.. c:function:: PyObject *PyUnicode_FromString(const char *u)
@@ -676,7 +675,7 @@ APIs:
676675
Deprecated Py_UNICODE APIs
677676
""""""""""""""""""""""""""
678677
679-
.. deprecated-removed:: 3.3 4.0
678+
.. deprecated-removed:: 3.3 3.12
680679
681680
These API functions are deprecated with the implementation of :pep:`393`.
682681
Extension modules can continue using them, as they will not be removed in Python

Doc/library/idle.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,15 @@ with objects that get input from and send output to the Shell window.
726726
The original values stored in ``sys.__stdin__``, ``sys.__stdout__``, and
727727
``sys.__stderr__`` are not touched, but may be ``None``.
728728

729+
Sending print output from one process to a text widget in another is
730+
slower than printing to a system terminal in the same process.
731+
This has the most effect when printing multiple arguments, as the string
732+
for each argument, each separator, the newline are sent separately.
733+
For development, this is usually not a problem, but if one wants to
734+
print faster in IDLE, format and join together everything one wants
735+
displayed together and then print a single string. Both format strings
736+
and :meth:`str.join` can help combine fields and lines.
737+
729738
IDLE's standard stream replacements are not inherited by subprocesses
730739
created in the execution process, whether directly by user code or by
731740
modules such as multiprocessing. If such subprocess use ``input`` from

Include/methodobject.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ struct PyMethodDef {
4141
};
4242
typedef struct PyMethodDef PyMethodDef;
4343

44+
/* PyCFunction_New is declared as a function for stable ABI (declaration is
45+
* needed for e.g. GCC with -fvisibility=hidden), but redefined as a macro
46+
* that calls PyCFunction_NewEx. */
47+
PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *);
4448
#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
49+
50+
/* PyCFunction_NewEx is similar: on 3.9+, this calls PyCMethod_New. */
4551
PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
4652
PyObject *);
4753

Lib/idlelib/NEWS.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
What's New in IDLE 3.10.0 (since 3.9.0)
1+
What's New in IDLE 3.10.0
2+
(since 3.9.0)
23
Released on 2021-10-04?
3-
======================================
4+
=========================
5+
46

7+
bpo-43283: Document why printing to IDLE's Shell is often slower than
8+
printing to a system terminal and that it can be made faster by
9+
pre-formatting a single string before printing.
510

611
bpo-23544: Disable Debug=>Stack Viewer when user code is running or
712
Debugger is active, to prevent hang or crash. Patch by Zackery Spytz.

Lib/idlelib/help.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,14 @@ <h3>Running user code<a class="headerlink" href="#running-user-code" title="Perm
679679
with objects that get input from and send output to the Shell window.
680680
The original values stored in <code class="docutils literal notranslate"><span class="pre">sys.__stdin__</span></code>, <code class="docutils literal notranslate"><span class="pre">sys.__stdout__</span></code>, and
681681
<code class="docutils literal notranslate"><span class="pre">sys.__stderr__</span></code> are not touched, but may be <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
682+
<p>Sending print output from one process to a text widget in another is
683+
slower than printing to a system terminal in the same process.
684+
This has the most effect when printing multiple arguments, as the string
685+
for each argument, each separator, the newline are sent separately.
686+
For development, this is usually not a problem, but if one wants to
687+
print faster in IDLE, format and join together everything one wants
688+
displayed together and then print a single string. Both format strings
689+
and <a class="reference internal" href="stdtypes.html#str.join" title="str.join"><code class="xref py py-meth docutils literal notranslate"><span class="pre">str.join()</span></code></a> can help combine fields and lines.</p>
682690
<p>IDLE’s standard stream replacements are not inherited by subprocesses
683691
created in the execution process, whether directly by user code or by
684692
modules such as multiprocessing. If such subprocess use <code class="docutils literal notranslate"><span class="pre">input</span></code> from
@@ -982,7 +990,7 @@ <h3>Navigation</h3>
982990
<br />
983991
<br />
984992

985-
Last updated on Feb 21, 2021.
993+
Last updated on Feb 23, 2021.
986994
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
987995
<br />
988996

Lib/test/test_traceback.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,29 @@ def test_format_exception_only_exc(self):
232232
output = traceback.format_exception_only(Exception("projector"))
233233
self.assertEqual(output, ["Exception: projector\n"])
234234

235+
def test_exception_is_None(self):
236+
NONE_EXC_STRING = 'NoneType: None\n'
237+
excfile = StringIO()
238+
traceback.print_exception(None, file=excfile)
239+
self.assertEqual(excfile.getvalue(), NONE_EXC_STRING)
240+
241+
excfile = StringIO()
242+
traceback.print_exception(None, None, None, file=excfile)
243+
self.assertEqual(excfile.getvalue(), NONE_EXC_STRING)
244+
245+
excfile = StringIO()
246+
traceback.print_exc(None, file=excfile)
247+
self.assertEqual(excfile.getvalue(), NONE_EXC_STRING)
248+
249+
self.assertEqual(traceback.format_exc(None), NONE_EXC_STRING)
250+
self.assertEqual(traceback.format_exception(None), [NONE_EXC_STRING])
251+
self.assertEqual(
252+
traceback.format_exception(None, None, None), [NONE_EXC_STRING])
253+
self.assertEqual(
254+
traceback.format_exception_only(None), [NONE_EXC_STRING])
255+
self.assertEqual(
256+
traceback.format_exception_only(None, None), [NONE_EXC_STRING])
257+
235258

236259
class TracebackFormatTests(unittest.TestCase):
237260

Lib/test/test_xml_etree.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@
108108
<document>&entity;</document>
109109
"""
110110

111+
ATTLIST_XML = """\
112+
<?xml version="1.0" encoding="UTF-8"?>
113+
<!DOCTYPE Foo [
114+
<!ELEMENT foo (bar*)>
115+
<!ELEMENT bar (#PCDATA)*>
116+
<!ATTLIST bar xml:lang CDATA "eng">
117+
<!ENTITY qux "quux">
118+
]>
119+
<foo>
120+
<bar>&qux;</bar>
121+
</foo>
122+
"""
123+
111124
def checkwarnings(*filters, quiet=False):
112125
def decorator(test):
113126
def newtest(*args, **kwargs):
@@ -1354,6 +1367,12 @@ def test_tree_write_attribute_order(self):
13541367
self.assertEqual(serialize(root, method='html'),
13551368
'<cirriculum status="public" company="example"></cirriculum>')
13561369

1370+
def test_attlist_default(self):
1371+
# Test default attribute values; See BPO 42151.
1372+
root = ET.fromstring(ATTLIST_XML)
1373+
self.assertEqual(root[0].attrib,
1374+
{'{http://www.w3.org/XML/1998/namespace}lang': 'eng'})
1375+
13571376

13581377
class XMLPullParserTest(unittest.TestCase):
13591378

Lib/traceback.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ def _parse_value_tb(exc, value, tb):
9191
if (value is _sentinel) != (tb is _sentinel):
9292
raise ValueError("Both or neither of value and tb must be given")
9393
if value is tb is _sentinel:
94-
return exc, exc.__traceback__
94+
if exc is not None:
95+
return exc, exc.__traceback__
96+
else:
97+
return None, None
9598
return value, tb
9699

97100

@@ -528,7 +531,9 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
528531
cause = None
529532

530533
if compact:
531-
need_context = cause is None and not e.__suppress_context__
534+
need_context = (cause is None and
535+
e is not None and
536+
not e.__suppress_context__)
532537
else:
533538
need_context = True
534539
if (e and e.__context__ is not None

Lib/xml/etree/ElementTree.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,6 @@ def __init__(self, *, target=None, encoding=None):
15601560
# Configure pyexpat: buffering, new-style attribute handling.
15611561
parser.buffer_text = 1
15621562
parser.ordered_attributes = 1
1563-
parser.specified_attributes = 1
15641563
self._doctype = None
15651564
self.entity = {}
15661565
try:
@@ -1580,7 +1579,6 @@ def _setevents(self, events_queue, events_to_report):
15801579
for event_name in events_to_report:
15811580
if event_name == "start":
15821581
parser.ordered_attributes = 1
1583-
parser.specified_attributes = 1
15841582
def handler(tag, attrib_in, event=event_name, append=append,
15851583
start=self._start):
15861584
append((event, start(tag, attrib_in)))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The :c:func:`PyCFunction_New` function is now exported in the ABI when
2+
compiled with ``-fvisibility=hidden``.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Update some deprecated unicode APIs which are documented as "will be removed
2+
in 4.0" to "3.12". See :pep:`623` for detail.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Document why printing to IDLE's Shell is often slower than printing to a
2+
system terminal and that it can be made faster by pre-formatting a single
3+
string before printing.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Make the pure Python implementation of :mod:`xml.etree.ElementTree` behave
2+
the same as the C implementation (:mod:`_elementree`) regarding default
3+
attribute values (by not setting ``specified_attributes=1``).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix recent regression in None argument handling in :mod:`~traceback` module functions.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Handle None in single-arg versions of :func:`~traceback.print_exception` and :func:`~traceback.format_exception`.

0 commit comments

Comments
 (0)