Skip to content

Commit 9b438a5

Browse files
authored
Merge branch 'main' into warnings-as-error-2
2 parents 3d68f6e + ef06508 commit 9b438a5

File tree

8 files changed

+61
-37
lines changed

8 files changed

+61
-37
lines changed

Doc/library/importlib.metadata.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ While the module level API described above is the most common and convenient usa
422422
you can get all of that information from the :class:`!Distribution` class.
423423
:class:`!Distribution` is an abstract object that represents the metadata for
424424
a Python `Distribution Package <https://packaging.python.org/en/latest/glossary/#term-Distribution-Package>`_.
425-
You can get the concreate :class:`!Distribution` subclass instance for an installed
425+
You can get the concrete :class:`!Distribution` subclass instance for an installed
426426
distribution package by calling the :func:`distribution` function::
427427

428428
>>> from importlib.metadata import distribution # doctest: +SKIP

Doc/library/mailbox.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,27 @@ Supported mailbox formats are Maildir, mbox, MH, Babyl, and MMDF.
587587
remarks:
588588

589589

590-
.. method:: get_file(key)
590+
.. method:: get_bytes(key, from_=False)
591+
592+
Note: This method has an extra parameter (*from_*) compared with other classes.
593+
The first line of an mbox file entry is the Unix "From " line.
594+
If *from_* is False, the first line of the file is dropped.
595+
596+
.. method:: get_file(key, from_=False)
591597

592598
Using the file after calling :meth:`~Mailbox.flush` or
593599
:meth:`~Mailbox.close` on the :class:`!mbox` instance may yield
594600
unpredictable results or raise an exception.
595601

602+
Note: This method has an extra parameter (*from_*) compared with other classes.
603+
The first line of an mbox file entry is the Unix "From " line.
604+
If *from_* is False, the first line of the file is dropped.
605+
606+
.. method:: get_string(key, from_=False)
607+
608+
Note: This method has an extra parameter (*from_*) compared with other classes.
609+
The first line of an mbox file entry is the Unix "From " line.
610+
If *from_* is False, the first line of the file is dropped.
596611

597612
.. method:: lock()
598613
unlock()
@@ -851,12 +866,22 @@ Supported mailbox formats are Maildir, mbox, MH, Babyl, and MMDF.
851866
remarks:
852867

853868

854-
.. method:: get_file(key)
869+
.. method:: get_bytes(key, from_=False)
870+
871+
Note: This method has an extra parameter (*from_*) compared with other classes.
872+
The first line of an mbox file entry is the Unix "From " line.
873+
If *from_* is False, the first line of the file is dropped.
874+
875+
.. method:: get_file(key, from_=False)
855876

856877
Using the file after calling :meth:`~Mailbox.flush` or
857878
:meth:`~Mailbox.close` on the :class:`!MMDF` instance may yield
858879
unpredictable results or raise an exception.
859880

881+
Note: This method has an extra parameter (*from_*) compared with other classes.
882+
The first line of an mbox file entry is the Unix "From " line.
883+
If *from_* is False, the first line of the file is dropped.
884+
860885

861886
.. method:: lock()
862887
unlock()

Doc/library/urllib.request.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,48 +1215,49 @@ In addition to the examples below, more examples are given in
12151215
:ref:`urllib-howto`.
12161216

12171217
This example gets the python.org main page and displays the first 300 bytes of
1218-
it. ::
1218+
it::
12191219

12201220
>>> import urllib.request
12211221
>>> with urllib.request.urlopen('http://www.python.org/') as f:
12221222
... print(f.read(300))
12231223
...
1224-
b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1225-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n\n\n<html
1226-
xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n\n<head>\n
1227-
<meta http-equiv="content-type" content="text/html; charset=utf-8" />\n
1228-
<title>Python Programming '
1224+
b'<!doctype html>\n<!--[if lt IE 7]> <html class="no-js ie6 lt-ie7 lt-ie8 lt-ie9"> <![endif]-->\n<!--[if IE 7]> <html class="no-js ie7 lt-ie8 lt-ie9"> <![endif]-->\n<!--[if IE 8]> <html class="no-js ie8 lt-ie9">
12291225

12301226
Note that urlopen returns a bytes object. This is because there is no way
12311227
for urlopen to automatically determine the encoding of the byte stream
12321228
it receives from the HTTP server. In general, a program will decode
12331229
the returned bytes object to string once it determines or guesses
12341230
the appropriate encoding.
12351231

1236-
The following W3C document, https://www.w3.org/International/O-charset\ , lists
1237-
the various ways in which an (X)HTML or an XML document could have specified its
1232+
The following HTML spec document, https://html.spec.whatwg.org/#charset, lists
1233+
the various ways in which an HTML or an XML document could have specified its
12381234
encoding information.
12391235

1236+
For additional information, see the W3C document: https://www.w3.org/International/questions/qa-html-encoding-declarations.
1237+
12401238
As the python.org website uses *utf-8* encoding as specified in its meta tag, we
1241-
will use the same for decoding the bytes object. ::
1239+
will use the same for decoding the bytes object::
12421240

12431241
>>> with urllib.request.urlopen('http://www.python.org/') as f:
12441242
... print(f.read(100).decode('utf-8'))
12451243
...
1246-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1247-
"http://www.w3.org/TR/xhtml1/DTD/xhtm
1244+
<!doctype html>
1245+
<!--[if lt IE 7]> <html class="no-js ie6 lt-ie7 lt-ie8 lt-ie9"> <![endif]-->
1246+
<!-
12481247

12491248
It is also possible to achieve the same result without using the
1250-
:term:`context manager` approach. ::
1249+
:term:`context manager` approach::
12511250

12521251
>>> import urllib.request
12531252
>>> f = urllib.request.urlopen('http://www.python.org/')
12541253
>>> try:
12551254
... print(f.read(100).decode('utf-8'))
12561255
... finally:
12571256
... f.close()
1258-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1259-
"http://www.w3.org/TR/xhtml1/DTD/xhtm
1257+
...
1258+
<!doctype html>
1259+
<!--[if lt IE 7]> <html class="no-js ie6 lt-ie7 lt-ie8 lt-ie9"> <![endif]-->
1260+
<!--
12601261

12611262
In the following example, we are sending a data-stream to the stdin of a CGI
12621263
and reading the data it returns to us. Note that this example will only work

Lib/test/test_ast/test_ast.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3238,6 +3238,18 @@ def get_match_case_values(node):
32383238
values = get_match_case_values(case.pattern)
32393239
self.assertListEqual(constants, values)
32403240

3241+
def test_match_case_not_folded_in_unoptimized_ast(self):
3242+
src = textwrap.dedent("""
3243+
match a:
3244+
case 1+2j:
3245+
pass
3246+
""")
3247+
3248+
unfolded = "MatchValue(value=BinOp(left=Constant(value=1), op=Add(), right=Constant(value=2j))"
3249+
folded = "MatchValue(value=Constant(value=(1+2j)))"
3250+
for optval in (0, 1, 2):
3251+
self.assertIn(folded if optval else unfolded, ast.dump(ast.parse(src, optimize=optval)))
3252+
32413253

32423254
if __name__ == '__main__':
32433255
if len(sys.argv) > 1 and sys.argv[1] == '--snapshot-update':

Modules/_asynciomodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,16 +2121,17 @@ TaskStepMethWrapper_traverse(PyObject *op,
21212121
}
21222122

21232123
static PyObject *
2124-
TaskStepMethWrapper_get___self__(TaskStepMethWrapper *o, void *Py_UNUSED(ignored))
2124+
TaskStepMethWrapper_get___self__(PyObject *op, void *Py_UNUSED(closure))
21252125
{
2126+
TaskStepMethWrapper *o = (TaskStepMethWrapper*)op;
21262127
if (o->sw_task) {
21272128
return Py_NewRef(o->sw_task);
21282129
}
21292130
Py_RETURN_NONE;
21302131
}
21312132

21322133
static PyGetSetDef TaskStepMethWrapper_getsetlist[] = {
2133-
{"__self__", (getter)TaskStepMethWrapper_get___self__, NULL, NULL},
2134+
{"__self__", TaskStepMethWrapper_get___self__, NULL, NULL},
21342135
{NULL} /* Sentinel */
21352136
};
21362137

Modules/md5module.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ class MD5Type "MD5object *" "&PyType_Type"
2929
[clinic start generated code]*/
3030
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=6e5261719957a912]*/
3131

32-
/* Some useful types */
33-
34-
#if SIZEOF_INT == 4
35-
typedef unsigned int MD5_INT32; /* 32-bit integer */
36-
typedef long long MD5_INT64; /* 64-bit integer */
37-
#else
38-
/* not defined. compilation will die. */
39-
#endif
40-
4132
/* The MD5 block size and message digest sizes, in bytes */
4233

4334
#define MD5_BLOCKSIZE 64

Modules/sha1module.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ class SHA1Type "SHA1object *" "&PyType_Type"
3030
[clinic start generated code]*/
3131
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=3dc9a20d1becb759]*/
3232

33-
/* Some useful types */
34-
35-
#if SIZEOF_INT == 4
36-
typedef unsigned int SHA1_INT32; /* 32-bit integer */
37-
typedef long long SHA1_INT64; /* 64-bit integer */
38-
#else
39-
/* not defined. compilation will die. */
40-
#endif
41-
4233
/* The SHA1 block size and message digest sizes, in bytes */
4334

4435
#define SHA1_BLOCKSIZE 64

Python/ast_opt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,9 @@ astfold_withitem(withitem_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
824824
static int
825825
fold_const_match_patterns(expr_ty node, PyArena *ctx_, _PyASTOptimizeState *state)
826826
{
827+
if (state->syntax_check_only) {
828+
return 1;
829+
}
827830
switch (node->kind)
828831
{
829832
case UnaryOp_kind:

0 commit comments

Comments
 (0)