Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 85f17fa

Browse files
author
Anselm Kruis
committed
Merge branch master into master-slp.
2 parents eaf04d5 + e6bb53b commit 85f17fa

Some content is hidden

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

50 files changed

+385
-334
lines changed

Doc/c-api/typeobj.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ type objects) *must* have the :attr:`ob_size` field.
199199

200200
This field is deprecated. When it is defined, it should point to a function
201201
that acts the same as the :c:member:`~PyTypeObject.tp_getattro` function, but taking a C string
202-
instead of a Python string object to give the attribute name. The signature is
203-
the same as for :c:func:`PyObject_GetAttrString`.
202+
instead of a Python string object to give the attribute name. The signature is ::
203+
204+
PyObject * tp_getattr(PyObject *o, char *attr_name);
204205

205206
This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_getattro`: a subtype
206207
inherits both :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` from its base type when
@@ -213,10 +214,11 @@ type objects) *must* have the :attr:`ob_size` field.
213214

214215
This field is deprecated. When it is defined, it should point to a function
215216
that acts the same as the :c:member:`~PyTypeObject.tp_setattro` function, but taking a C string
216-
instead of a Python string object to give the attribute name. The signature is
217-
the same as for :c:func:`PyObject_SetAttrString`, but setting
218-
*v* to *NULL* to delete an attribute must be supported.
217+
instead of a Python string object to give the attribute name. The signature is ::
218+
219+
PyObject * tp_setattr(PyObject *o, char *attr_name, PyObject *v);
219220

221+
The *v* argument is set to *NULL* to delete the attribute.
220222
This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattro`: a subtype
221223
inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when
222224
the subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` are both *NULL*.

Doc/howto/clinic.rst

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. highlightlang:: c
2+
13
**********************
24
Argument Clinic How-To
35
**********************
@@ -78,17 +80,23 @@ Basic Concepts And Usage
7880
========================
7981

8082
Argument Clinic ships with CPython; you'll find it in ``Tools/clinic/clinic.py``.
81-
If you run that script, specifying a C file as an argument::
83+
If you run that script, specifying a C file as an argument:
84+
85+
.. code-block:: shell-session
8286
83-
% python3 Tools/clinic/clinic.py foo.c
87+
$ python3 Tools/clinic/clinic.py foo.c
8488
8589
Argument Clinic will scan over the file looking for lines that
86-
look exactly like this::
90+
look exactly like this:
91+
92+
.. code-block:: none
8793
8894
/*[clinic input]
8995
9096
When it finds one, it reads everything up to a line that looks
91-
exactly like this::
97+
exactly like this:
98+
99+
.. code-block:: none
92100
93101
[clinic start generated code]*/
94102
@@ -99,7 +107,9 @@ lines, are collectively called an Argument Clinic "block".
99107
When Argument Clinic parses one of these blocks, it
100108
generates output. This output is rewritten into the C file
101109
immediately after the block, followed by a comment containing a checksum.
102-
The Argument Clinic block now looks like this::
110+
The Argument Clinic block now looks like this:
111+
112+
.. code-block:: none
103113
104114
/*[clinic input]
105115
... clinic input goes here ...
@@ -378,9 +388,7 @@ Let's dive in!
378388
12. Save and close the file, then run ``Tools/clinic/clinic.py`` on
379389
it. With luck everything worked---your block now has output, and
380390
a ``.c.h`` file has been generated! Reopen the file in your
381-
text editor to see:
382-
383-
.. code-block:: c
391+
text editor to see::
384392

385393
/*[clinic input]
386394
_pickle.Pickler.dump
@@ -402,9 +410,7 @@ Let's dive in!
402410

403411
For readability, most of the glue code has been generated to a ``.c.h``
404412
file. You'll need to include that in your original ``.c`` file,
405-
typically right after the clinic module block:
406-
407-
.. code-block:: c
413+
typically right after the clinic module block::
408414

409415
#include "clinic/_pickle.c.h"
410416

@@ -1028,7 +1034,9 @@ that value, and an error has been set (``PyErr_Occurred()`` returns a true
10281034
value), then the generated code will propagate the error. Otherwise it will
10291035
encode the value you return like normal.
10301036

1031-
Currently Argument Clinic supports only a few return converters::
1037+
Currently Argument Clinic supports only a few return converters:
1038+
1039+
.. code-block:: none
10321040
10331041
bool
10341042
int
@@ -1607,7 +1615,9 @@ code probably looks like this::
16071615
#endif /* HAVE_FUNCTIONNAME */
16081616

16091617
And then in the ``PyMethodDef`` structure at the bottom the existing code
1610-
will have::
1618+
will have:
1619+
1620+
.. code-block:: none
16111621
16121622
#ifdef HAVE_FUNCTIONNAME
16131623
{'functionname', ... },
@@ -1657,7 +1667,9 @@ extra code when using the "block" output preset? It can't go in the output bloc
16571667
because that could be deactivated by the ``#ifdef``. (That's the whole point!)
16581668

16591669
In this situation, Argument Clinic writes the extra code to the "buffer" destination.
1660-
This may mean that you get a complaint from Argument Clinic::
1670+
This may mean that you get a complaint from Argument Clinic:
1671+
1672+
.. code-block:: none
16611673
16621674
Warning in file "Modules/posixmodule.c" on line 12357:
16631675
Destination buffer 'buffer' not empty at end of file, emptying.
@@ -1677,7 +1689,9 @@ wouldn't make any sense to the Python interpreter. But using Argument Clinic
16771689
to run Python blocks lets you use Python as a Python preprocessor!
16781690

16791691
Since Python comments are different from C comments, Argument Clinic
1680-
blocks embedded in Python files look slightly different. They look like this::
1692+
blocks embedded in Python files look slightly different. They look like this:
1693+
1694+
.. code-block:: python3
16811695
16821696
#/*[python input]
16831697
#print("def foo(): pass")

Doc/howto/urllib2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ Footnotes
578578
This document was reviewed and revised by John Lee.
579579

580580
.. [#] Google for example.
581-
.. [#] Browser sniffing is a very bad practise for website design - building
581+
.. [#] Browser sniffing is a very bad practice for website design - building
582582
sites using web standards is much more sensible. Unfortunately a lot of
583583
sites still send different versions to different browsers.
584584
.. [#] The user agent for MSIE 6 is

Doc/library/asyncio-protocol.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ the transport's kind.
2525

2626
The transport classes are :ref:`not thread safe <asyncio-multithreading>`.
2727

28+
.. versionchanged:: 3.6
29+
The socket option ``TCP_NODELAY`` is now set by default.
30+
2831

2932
BaseTransport
3033
-------------

Doc/library/pkgutil.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,6 @@ support.
224224

225225
If the package cannot be located or loaded, or it uses a :term:`loader`
226226
which does not support :meth:`get_data <importlib.abc.ResourceLoader.get_data>`,
227-
then ``None`` is returned.
227+
then ``None`` is returned. In particular, the :term:`loader` for
228+
:term:`namespace packages <namespace package>` does not support
229+
:meth:`get_data <importlib.abc.ResourceLoader.get_data>`.

Doc/library/stdtypes.rst

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,18 +1644,20 @@ expression support in the :mod:`re` module).
16441644

16451645
Return true if all characters in the string are decimal
16461646
characters and there is at least one character, false
1647-
otherwise. Decimal characters are those from general category "Nd". This category
1648-
includes digit characters, and all characters
1649-
that can be used to form decimal-radix numbers, e.g. U+0660,
1650-
ARABIC-INDIC DIGIT ZERO.
1647+
otherwise. Decimal characters are those that can be used to form
1648+
numbers in base 10, e.g. U+0660, ARABIC-INDIC DIGIT
1649+
ZERO. Formally a decimal character is a character in the Unicode
1650+
General Category "Nd".
16511651

16521652

16531653
.. method:: str.isdigit()
16541654

16551655
Return true if all characters in the string are digits and there is at least one
16561656
character, false otherwise. Digits include decimal characters and digits that need
1657-
special handling, such as the compatibility superscript digits. Formally, a digit
1658-
is a character that has the property value Numeric_Type=Digit or Numeric_Type=Decimal.
1657+
special handling, such as the compatibility superscript digits.
1658+
This covers digits which cannot be used to form numbers in base 10,
1659+
like the Kharosthi numbers. Formally, a digit is a character that has the
1660+
property value Numeric_Type=Digit or Numeric_Type=Decimal.
16591661

16601662

16611663
.. method:: str.isidentifier()
@@ -2199,15 +2201,12 @@ The conversion types are:
21992201
Notes:
22002202

22012203
(1)
2202-
The alternate form causes a leading zero (``'0'``) to be inserted between
2203-
left-hand padding and the formatting of the number if the leading character
2204-
of the result is not already a zero.
2204+
The alternate form causes a leading octal specifier (``'0o'``) to be
2205+
inserted before the first digit.
22052206

22062207
(2)
22072208
The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on whether
2208-
the ``'x'`` or ``'X'`` format was used) to be inserted between left-hand padding
2209-
and the formatting of the number if the leading character of the result is not
2210-
already a zero.
2209+
the ``'x'`` or ``'X'`` format was used) to be inserted before the first digit.
22112210

22122211
(3)
22132212
The alternate form causes the result to always contain a decimal point, even if
@@ -3303,15 +3302,12 @@ The conversion types are:
33033302
Notes:
33043303

33053304
(1)
3306-
The alternate form causes a leading zero (``'0'``) to be inserted between
3307-
left-hand padding and the formatting of the number if the leading character
3308-
of the result is not already a zero.
3305+
The alternate form causes a leading octal specifier (``'0o'``) to be
3306+
inserted before the first digit.
33093307

33103308
(2)
33113309
The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on whether
3312-
the ``'x'`` or ``'X'`` format was used) to be inserted between left-hand padding
3313-
and the formatting of the number if the leading character of the result is not
3314-
already a zero.
3310+
the ``'x'`` or ``'X'`` format was used) to be inserted before the first digit.
33153311

33163312
(3)
33173313
The alternate form causes the result to always contain a decimal point, even if

Doc/tutorial/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ when the ``from...import`` statement is executed. (This also works when
501501
``__all__`` is defined.)
502502

503503
Although certain modules are designed to export only names that follow certain
504-
patterns when you use ``import *``, it is still considered bad practise in
504+
patterns when you use ``import *``, it is still considered bad practice in
505505
production code.
506506

507507
Remember, there is nothing wrong with using ``from Package import

Doc/whatsnew/3.6.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,9 @@ Notable changes in the :mod:`asyncio` module since Python 3.5.0
875875
but that use asyncio to handle them.
876876
(Contributed by Jim Fulton in :issue:`27392`.)
877877

878+
* ``TCP_NODELAY`` flag is now set for all TCP transports by default.
879+
(Contributed by Yury Selivanov in :issue:`27456`.)
880+
878881

879882
binascii
880883
--------
-2 KB
Binary file not shown.
-2 KB
Binary file not shown.

Lib/importlib/_bootstrap_external.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,4 @@ def _install(_bootstrap_module):
14401440
_setup(_bootstrap_module)
14411441
supported_loaders = _get_supported_file_loaders()
14421442
sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)])
1443-
if _os.__name__ == 'nt':
1444-
sys.meta_path.append(WindowsRegistryFinder)
14451443
sys.meta_path.append(PathFinder)

Lib/mailbox.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,12 @@ def add(self, message):
313313
# final position in order to prevent race conditions with changes
314314
# from other programs
315315
try:
316-
if hasattr(os, 'link'):
316+
try:
317317
os.link(tmp_file.name, dest)
318-
os.remove(tmp_file.name)
319-
else:
318+
except (AttributeError, PermissionError):
320319
os.rename(tmp_file.name, dest)
320+
else:
321+
os.remove(tmp_file.name)
321322
except OSError as e:
322323
os.remove(tmp_file.name)
323324
if e.errno == errno.EEXIST:
@@ -1200,13 +1201,14 @@ def pack(self):
12001201
for key in self.iterkeys():
12011202
if key - 1 != prev:
12021203
changes.append((key, prev + 1))
1203-
if hasattr(os, 'link'):
1204+
try:
12041205
os.link(os.path.join(self._path, str(key)),
12051206
os.path.join(self._path, str(prev + 1)))
1206-
os.unlink(os.path.join(self._path, str(key)))
1207-
else:
1207+
except (AttributeError, PermissionError):
12081208
os.rename(os.path.join(self._path, str(key)),
12091209
os.path.join(self._path, str(prev + 1)))
1210+
else:
1211+
os.unlink(os.path.join(self._path, str(key)))
12101212
prev += 1
12111213
self._next_key = prev + 1
12121214
if len(changes) == 0:
@@ -2076,13 +2078,14 @@ def _lock_file(f, dotlock=True):
20762078
else:
20772079
raise
20782080
try:
2079-
if hasattr(os, 'link'):
2081+
try:
20802082
os.link(pre_lock.name, f.name + '.lock')
20812083
dotlock_done = True
2082-
os.unlink(pre_lock.name)
2083-
else:
2084+
except (AttributeError, PermissionError):
20842085
os.rename(pre_lock.name, f.name + '.lock')
20852086
dotlock_done = True
2087+
else:
2088+
os.unlink(pre_lock.name)
20862089
except FileExistsError:
20872090
os.remove(pre_lock.name)
20882091
raise ExternalClashError('dot lock unavailable: %s' %

Lib/multiprocessing/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def get_context(self, method=None):
196196
def get_start_method(self, allow_none=False):
197197
return self._name
198198

199-
def set_start_method(self, method=None):
199+
def set_start_method(self, method, force=False):
200200
raise ValueError('cannot set start method of concrete context')
201201

202202
@property

Lib/multiprocessing/spawn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def prepare(data):
217217
process.ORIGINAL_DIR = data['orig_dir']
218218

219219
if 'start_method' in data:
220-
set_start_method(data['start_method'])
220+
set_start_method(data['start_method'], force=True)
221221

222222
if 'init_main_from_name' in data:
223223
_fixup_main_from_name(data['init_main_from_name'])

Lib/subprocess.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,10 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
12041204
args = list(args)
12051205

12061206
if shell:
1207-
args = ["/bin/sh", "-c"] + args
1207+
# On Android the default shell is at '/system/bin/sh'.
1208+
unix_shell = ('/system/bin/sh' if
1209+
hasattr(sys, 'getandroidapilevel') else '/bin/sh')
1210+
args = [unix_shell, "-c"] + args
12081211
if executable:
12091212
args[0] = executable
12101213

Lib/test/_test_multiprocessing.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3824,6 +3824,19 @@ def test_get_all(self):
38243824
self.assertTrue(methods == ['fork', 'spawn'] or
38253825
methods == ['fork', 'spawn', 'forkserver'])
38263826

3827+
def test_preload_resources(self):
3828+
if multiprocessing.get_start_method() != 'forkserver':
3829+
self.skipTest("test only relevant for 'forkserver' method")
3830+
name = os.path.join(os.path.dirname(__file__), 'mp_preload.py')
3831+
rc, out, err = test.support.script_helper.assert_python_ok(name)
3832+
out = out.decode()
3833+
err = err.decode()
3834+
if out.rstrip() != 'ok' or err != '':
3835+
print(out)
3836+
print(err)
3837+
self.fail("failed spawning forkserver or grandchild")
3838+
3839+
38273840
#
38283841
# Check that killing process does not leak named semaphores
38293842
#

Lib/test/eintrdata/eintr_tester.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import unittest
2121

2222
from test import support
23+
android_not_root = support.android_not_root
2324

2425
@contextlib.contextmanager
2526
def kill_on_error(proc):
@@ -311,6 +312,7 @@ def test_accept(self):
311312
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203162
312313
@support.requires_freebsd_version(10, 3)
313314
@unittest.skipUnless(hasattr(os, 'mkfifo'), 'needs mkfifo()')
315+
@unittest.skipIf(android_not_root, "mkfifo not allowed, non root user")
314316
def _test_open(self, do_open_close_reader, do_open_close_writer):
315317
filename = support.TESTFN
316318

Lib/test/mp_preload.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import multiprocessing
2+
3+
multiprocessing.Lock()
4+
5+
6+
def f():
7+
print("ok")
8+
9+
10+
if __name__ == "__main__":
11+
ctx = multiprocessing.get_context("forkserver")
12+
modname = "test.mp_preload"
13+
# Make sure it's importable
14+
__import__(modname)
15+
ctx.set_forkserver_preload([modname])
16+
proc = ctx.Process(target=f)
17+
proc.start()
18+
proc.join()

0 commit comments

Comments
 (0)