Python-checkins
Threads by month
- ----- 2025 -----
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
February 2019
- 3 participants
- 301 discussions

Clean up code which checked presence of os.{stat, lstat, chmod} (#11643)
by Giampaolo Rodola Feb. 25, 2019
by Giampaolo Rodola Feb. 25, 2019
Feb. 25, 2019
https://github.com/python/cpython/commit/8377cd4fcd0d51d86834c9b0518d29aac3…
commit: 8377cd4fcd0d51d86834c9b0518d29aac3b49e18
branch: master
author: Anthony Sottile <asottile(a)umich.edu>
committer: Giampaolo Rodola <g.rodola(a)gmail.com>
date: 2019-02-25T23:32:27+01:00
summary:
Clean up code which checked presence of os.{stat,lstat,chmod} (#11643)
files:
A Misc/NEWS.d/next/Library/2019-01-21-13-56-55.bpo-35802.6633PE.rst
M Lib/dbm/dumb.py
M Lib/fileinput.py
M Lib/shutil.py
M Lib/tarfile.py
M Lib/tempfile.py
M Lib/test/libregrtest/runtest.py
M Lib/test/pickletester.py
M Lib/test/test_compileall.py
M Lib/test/test_dbm_dumb.py
M Lib/test/test_fileinput.py
M Lib/test/test_mailbox.py
M Lib/test/test_mmap.py
M Lib/test/test_os.py
M Lib/test/test_posix.py
M Lib/test/test_shutil.py
M Lib/test/test_tempfile.py
M setup.py
diff --git a/Lib/dbm/dumb.py b/Lib/dbm/dumb.py
index 6cef72a49acc..864ad371ec95 100644
--- a/Lib/dbm/dumb.py
+++ b/Lib/dbm/dumb.py
@@ -278,8 +278,7 @@ def close(self):
__del__ = close
def _chmod(self, file):
- if hasattr(self._os, 'chmod'):
- self._os.chmod(file, self._mode)
+ self._os.chmod(file, self._mode)
def __enter__(self):
return self
diff --git a/Lib/fileinput.py b/Lib/fileinput.py
index a7f8df37aada..4a71cc5ff318 100644
--- a/Lib/fileinput.py
+++ b/Lib/fileinput.py
@@ -357,8 +357,7 @@ def _readline(self):
fd = os.open(self._filename, mode, perm)
self._output = os.fdopen(fd, "w")
try:
- if hasattr(os, 'chmod'):
- os.chmod(self._filename, perm)
+ os.chmod(self._filename, perm)
except OSError:
pass
self._savestdout = sys.stdout
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 29e7564622e1..1f98a348d7e6 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -290,10 +290,8 @@ def copymode(src, dst, *, follow_symlinks=True):
stat_func, chmod_func = os.lstat, os.lchmod
else:
return
- elif hasattr(os, 'chmod'):
- stat_func, chmod_func = _stat, os.chmod
else:
- return
+ stat_func, chmod_func = _stat, os.chmod
st = stat_func(src)
chmod_func(dst, stat.S_IMODE(st.st_mode))
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index ba3e95f281df..bb09d10925b2 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1787,10 +1787,9 @@ def gettarinfo(self, name=None, arcname=None, fileobj=None):
tarinfo = self.tarinfo()
tarinfo.tarfile = self # Not needed
- # Use os.stat or os.lstat, depending on platform
- # and if symlinks shall be resolved.
+ # Use os.stat or os.lstat, depending on if symlinks shall be resolved.
if fileobj is None:
- if hasattr(os, "lstat") and not self.dereference:
+ if not self.dereference:
statres = os.lstat(name)
else:
statres = os.stat(name)
@@ -2235,11 +2234,10 @@ def chown(self, tarinfo, targetpath, numeric_owner):
def chmod(self, tarinfo, targetpath):
"""Set file permissions of targetpath according to tarinfo.
"""
- if hasattr(os, 'chmod'):
- try:
- os.chmod(targetpath, tarinfo.mode)
- except OSError:
- raise ExtractError("could not change mode")
+ try:
+ os.chmod(targetpath, tarinfo.mode)
+ except OSError:
+ raise ExtractError("could not change mode")
def utime(self, tarinfo, targetpath):
"""Set modification time of targetpath according to tarinfo.
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index e6fb3c8e9ad8..a66d6f3750cb 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -70,20 +70,10 @@
_once_lock = _allocate_lock()
-if hasattr(_os, "lstat"):
- _stat = _os.lstat
-elif hasattr(_os, "stat"):
- _stat = _os.stat
-else:
- # Fallback. All we need is something that raises OSError if the
- # file doesn't exist.
- def _stat(fn):
- fd = _os.open(fn, _os.O_RDONLY)
- _os.close(fd)
def _exists(fn):
try:
- _stat(fn)
+ _os.lstat(fn)
except OSError:
return False
else:
diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py
index dc2abf237bc0..4f218b769f98 100644
--- a/Lib/test/libregrtest/runtest.py
+++ b/Lib/test/libregrtest/runtest.py
@@ -249,10 +249,8 @@ def cleanup_test_droppings(testname, verbose):
if verbose:
print("%r left behind %s %r" % (testname, kind, name))
try:
- # if we have chmod, fix possible permissions problems
- # that might prevent cleanup
- if (hasattr(os, 'chmod')):
- os.chmod(name, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
+ # fix possible permissions problems that might prevent cleanup
+ os.chmod(name, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
nuker(name)
except Exception as msg:
print(("%r left behind %s %r and it couldn't be "
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 293393fe3713..8f687c49e690 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -1568,11 +1568,10 @@ def test_structseq(self):
s = self.dumps(t, proto)
u = self.loads(s)
self.assert_is_copy(t, u)
- if hasattr(os, "stat"):
- t = os.stat(os.curdir)
- s = self.dumps(t, proto)
- u = self.loads(s)
- self.assert_is_copy(t, u)
+ t = os.stat(os.curdir)
+ s = self.dumps(t, proto)
+ u = self.loads(s)
+ self.assert_is_copy(t, u)
if hasattr(os, "statvfs"):
t = os.statvfs(os.curdir)
s = self.dumps(t, proto)
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py
index 2e2552303f8d..8e584602de36 100644
--- a/Lib/test/test_compileall.py
+++ b/Lib/test/test_compileall.py
@@ -57,7 +57,6 @@ def timestamp_metadata(self):
compare = struct.pack('<4sll', importlib.util.MAGIC_NUMBER, 0, mtime)
return data, compare
- @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()')
def recreation_check(self, metadata):
"""Check that compileall recreates bytecode when the new metadata is
used."""
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py
index e8e827e5f5bc..a971359d33ff 100644
--- a/Lib/test/test_dbm_dumb.py
+++ b/Lib/test/test_dbm_dumb.py
@@ -40,7 +40,6 @@ def test_dumbdbm_creation(self):
f.close()
@unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()')
- @unittest.skipUnless(hasattr(os, 'chmod'), 'test needs os.chmod()')
def test_dumbdbm_creation_mode(self):
try:
old_umask = os.umask(0o002)
@@ -275,7 +274,6 @@ def test_invalid_flag(self):
"'r', 'w', 'c', or 'n'"):
dumbdbm.open(_fname, flag)
- @unittest.skipUnless(hasattr(os, 'chmod'), 'test needs os.chmod()')
def test_readonly_files(self):
with support.temp_dir() as dir:
fname = os.path.join(dir, 'db')
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py
index c5d722e58f59..3857401ca60f 100644
--- a/Lib/test/test_fileinput.py
+++ b/Lib/test/test_fileinput.py
@@ -428,7 +428,6 @@ def test_readline_os_fstat_raises_OSError(self):
self.assertTrue(os_fstat_replacement.invoked,
"os.fstat() was not invoked")
- @unittest.skipIf(not hasattr(os, "chmod"), "os.chmod does not exist")
def test_readline_os_chmod_raises_OSError(self):
"""Tests invoking FileInput.readline() when os.chmod() raises OSError.
This exception should be silently discarded."""
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index a75c8cb00e80..0995b1e386d0 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -864,7 +864,6 @@ def test_directory_in_folder (self):
pass
@unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()')
- @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()')
def test_file_permissions(self):
# Verify that message files are created without execute permissions
msg = mailbox.MaildirMessage(self._template % 0)
@@ -878,7 +877,6 @@ def test_file_permissions(self):
self.assertFalse(mode & 0o111)
@unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()')
- @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()')
def test_folder_file_perms(self):
# From bug #3228, we want to verify that the file created inside a Maildir
# subfolder isn't marked as executable.
@@ -1120,7 +1118,6 @@ class TestMbox(_TestMboxMMDF, unittest.TestCase):
_factory = lambda self, path, factory=None: mailbox.mbox(path, factory)
@unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()')
- @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()')
def test_file_perms(self):
# From bug #3228, we want to verify that the mailbox file isn't executable,
# even if the umask is set to something that would leave executable bits set.
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 246fdf01f9cd..3e6ecfc95660 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -317,7 +317,6 @@ def test_double_close(self):
mf.close()
f.close()
- @unittest.skipUnless(hasattr(os, "stat"), "needs os.stat()")
def test_entire_file(self):
# test mapping of entire file by passing 0 for map length
f = open(TESTFN, "wb+")
@@ -332,7 +331,6 @@ def test_entire_file(self):
mf.close()
f.close()
- @unittest.skipUnless(hasattr(os, "stat"), "needs os.stat()")
def test_length_0_offset(self):
# Issue #10916: test mapping of remainder of file by passing 0 for
# map length with an offset doesn't cause a segfault.
@@ -345,7 +343,6 @@ def test_length_0_offset(self):
with mmap.mmap(f.fileno(), 0, offset=65536, access=mmap.ACCESS_READ) as mf:
self.assertRaises(IndexError, mf.__getitem__, 80000)
- @unittest.skipUnless(hasattr(os, "stat"), "needs os.stat()")
def test_length_0_large_offset(self):
# Issue #10959: test mapping of a file by passing 0 for
# map length with a large offset doesn't cause a segfault.
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 2cfcebcc8648..2340b848d9b7 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -238,7 +238,6 @@ def setUp(self):
self.addCleanup(support.unlink, self.fname)
create_file(self.fname, b"ABC")
- @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()')
def check_stat_attributes(self, fname):
result = os.stat(fname)
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index e980dd014cd8..fe21b21b3385 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -606,8 +606,6 @@ def test_fstat(self):
finally:
fp.close()
- @unittest.skipUnless(hasattr(posix, 'stat'),
- 'test needs posix.stat()')
def test_stat(self):
self.assertTrue(posix.stat(support.TESTFN))
self.assertTrue(posix.stat(os.fsencode(support.TESTFN)))
@@ -658,7 +656,6 @@ def test_mknod(self):
except OSError as e:
self.assertIn(e.errno, (errno.EPERM, errno.EINVAL, errno.EACCES))
- @unittest.skipUnless(hasattr(posix, 'stat'), 'test needs posix.stat()')
@unittest.skipUnless(hasattr(posix, 'makedev'), 'test needs posix.makedev()')
def test_makedev(self):
st = posix.stat(support.TESTFN)
@@ -755,8 +752,7 @@ def test_chown(self):
# re-create the file
support.create_empty_file(support.TESTFN)
- self._test_all_chown_common(posix.chown, support.TESTFN,
- getattr(posix, 'stat', None))
+ self._test_all_chown_common(posix.chown, support.TESTFN, posix.stat)
@unittest.skipUnless(hasattr(posix, 'fchown'), "test needs os.fchown()")
def test_fchown(self):
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 86f4dc97c3a1..ceafaeda1dc2 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -262,7 +262,6 @@ def onerror(*args):
self.assertIn(errors[1][2][1].filename, possible_args)
- @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod()')
@unittest.skipIf(sys.platform[:6] == 'cygwin',
"This test can't be run on Cygwin (issue #1071513).")
@unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0,
@@ -337,7 +336,6 @@ def raiser(fn, *args, **kwargs):
finally:
os.lstat = orig_lstat
- @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod')
@support.skip_unless_symlink
def test_copymode_follow_symlinks(self):
tmp_dir = self.mkdtemp()
@@ -1022,14 +1020,12 @@ def _copy_file(self, method):
file2 = os.path.join(tmpdir2, fname)
return (file1, file2)
- @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod')
def test_copy(self):
# Ensure that the copied file exists and has the same mode bits.
file1, file2 = self._copy_file(shutil.copy)
self.assertTrue(os.path.exists(file2))
self.assertEqual(os.stat(file1).st_mode, os.stat(file2).st_mode)
- @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod')
@unittest.skipUnless(hasattr(os, 'utime'), 'requires os.utime')
def test_copy2(self):
# Ensure that the copied file exists and has the same mode and
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index e5098d2eea6b..3c0b9a74e5c8 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -8,6 +8,7 @@
import re
import warnings
import contextlib
+import stat
import weakref
from unittest import mock
@@ -16,12 +17,6 @@
from test.support import script_helper
-if hasattr(os, 'stat'):
- import stat
- has_stat = 1
-else:
- has_stat = 0
-
has_textmode = (tempfile._text_openflags != tempfile._bin_openflags)
has_spawnl = hasattr(os, 'spawnl')
@@ -433,7 +428,6 @@ def test_choose_directory(self):
finally:
os.rmdir(dir)
- @unittest.skipUnless(has_stat, 'os.stat not available')
def test_file_mode(self):
# _mkstemp_inner creates files with the proper mode
@@ -738,7 +732,6 @@ def test_choose_directory(self):
finally:
os.rmdir(dir)
- @unittest.skipUnless(has_stat, 'os.stat not available')
def test_mode(self):
# mkdtemp creates directories with the proper mode
@@ -1221,8 +1214,7 @@ def test_truncate_with_size_parameter(self):
f.write(b'abcdefg\n')
f.truncate(20)
self.assertTrue(f._rolled)
- if has_stat:
- self.assertEqual(os.fstat(f.fileno()).st_size, 20)
+ self.assertEqual(os.fstat(f.fileno()).st_size, 20)
if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile:
diff --git a/Misc/NEWS.d/next/Library/2019-01-21-13-56-55.bpo-35802.6633PE.rst b/Misc/NEWS.d/next/Library/2019-01-21-13-56-55.bpo-35802.6633PE.rst
new file mode 100644
index 000000000000..8b73d2bd5851
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-01-21-13-56-55.bpo-35802.6633PE.rst
@@ -0,0 +1,2 @@
+Clean up code which checked presence of ``os.stat`` / ``os.lstat`` /
+``os.chmod`` which are always present. Patch by Anthony Sottile.
diff --git a/setup.py b/setup.py
index 4a01a8f45ac4..33106549458c 100644
--- a/setup.py
+++ b/setup.py
@@ -2266,7 +2266,6 @@ def install(self):
return outfiles
def set_file_modes(self, files, defaultMode, sharedLibMode):
- if not self.is_chmod_supported(): return
if not files: return
for filename in files:
@@ -2277,16 +2276,12 @@ def set_file_modes(self, files, defaultMode, sharedLibMode):
if not self.dry_run: os.chmod(filename, mode)
def set_dir_modes(self, dirname, mode):
- if not self.is_chmod_supported(): return
for dirpath, dirnames, fnames in os.walk(dirname):
if os.path.islink(dirpath):
continue
log.info("changing mode of %s to %o", dirpath, mode)
if not self.dry_run: os.chmod(dirpath, mode)
- def is_chmod_supported(self):
- return hasattr(os, 'chmod')
-
class PyBuildScripts(build_scripts):
def copy_scripts(self):
outfiles, updated_files = build_scripts.copy_scripts(self)
1
0

Feb. 25, 2019
https://github.com/python/cpython/commit/9c3f284de598550be6687964c23fd7599e…
commit: 9c3f284de598550be6687964c23fd7599e53b20e
branch: master
author: Xtreak <tir.karthi(a)gmail.com>
committer: Chris Withers <chris(a)withers.org>
date: 2019-02-25T21:46:34Z
summary:
Autospec functions should propagate mock calls to parent GH-11273
files:
A Misc/NEWS.d/next/Library/2018-12-21-09-54-30.bpo-21478.5gsXtc.rst
M Lib/unittest/mock.py
M Lib/unittest/test/testmock/testmock.py
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index ccbcd355ce31..2ccf0d82ce23 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -321,6 +321,14 @@ def __repr__(self):
def _check_and_set_parent(parent, value, name, new_name):
+ # function passed to create_autospec will have mock
+ # attribute attached to which parent must be set
+ if isinstance(value, FunctionTypes):
+ try:
+ value = value.mock
+ except AttributeError:
+ pass
+
if not _is_instance_mock(value):
return False
if ((value._mock_name or value._mock_new_name) or
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index 04ab52271578..2ad90ea81ec7 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -1830,5 +1830,18 @@ def test_parent_attribute_of_call(self):
self.assertEqual(type(call.parent().parent), _Call)
+ def test_parent_propagation_with_create_autospec(self):
+
+ def foo(a, b):
+ pass
+
+ mock = Mock()
+ mock.child = create_autospec(foo)
+ mock.child(1, 2)
+
+ self.assertRaises(TypeError, mock.child, 1)
+ self.assertEqual(mock.mock_calls, [call.child(1, 2)])
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/Misc/NEWS.d/next/Library/2018-12-21-09-54-30.bpo-21478.5gsXtc.rst b/Misc/NEWS.d/next/Library/2018-12-21-09-54-30.bpo-21478.5gsXtc.rst
new file mode 100644
index 000000000000..1000748c9c48
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-12-21-09-54-30.bpo-21478.5gsXtc.rst
@@ -0,0 +1,2 @@
+Calls to a child function created with :func:`unittest.mock.create_autospec`
+should propagate to the parent. Patch by Karthikeyan Singaravelan.
1
0

bpo-36030: Remove _PyStack_AsTuple() and _PyStack_AsTupleSlice() (GH-12032)
by Victor Stinner Feb. 25, 2019
by Victor Stinner Feb. 25, 2019
Feb. 25, 2019
https://github.com/python/cpython/commit/f1b9abe35f75393351b3d954a392122a3f…
commit: f1b9abe35f75393351b3d954a392122a3f8f6951
branch: master
author: Sergey Fedoseev <fedoseev.sergey(a)gmail.com>
committer: Victor Stinner <vstinner(a)redhat.com>
date: 2019-02-25T22:37:26+01:00
summary:
bpo-36030: Remove _PyStack_AsTuple() and _PyStack_AsTupleSlice() (GH-12032)
files:
M Include/cpython/abstract.h
M Objects/call.c
M Python/bltinmodule.c
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h
index 0e002659f6bf..991bea14ebf0 100644
--- a/Include/cpython/abstract.h
+++ b/Include/cpython/abstract.h
@@ -12,16 +12,6 @@ extern "C" {
# define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT
#endif
-PyAPI_FUNC(PyObject*) _PyStack_AsTuple(
- PyObject *const *stack,
- Py_ssize_t nargs);
-
-PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice(
- PyObject *const *stack,
- Py_ssize_t nargs,
- Py_ssize_t start,
- Py_ssize_t end);
-
/* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
format to a Python dictionary ("kwargs" dict).
diff --git a/Objects/call.c b/Objects/call.c
index 3250f8a10dff..d52e7e26aeba 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -114,7 +114,7 @@ _PyObject_FastCallDict(PyObject *callable, PyObject *const *args, Py_ssize_t nar
return NULL;
}
- argstuple = _PyStack_AsTuple(args, nargs);
+ argstuple = _PyTuple_FromArray(args, nargs);
if (argstuple == NULL) {
return NULL;
}
@@ -176,7 +176,7 @@ _PyObject_FastCallKeywords(PyObject *callable, PyObject *const *stack, Py_ssize_
return NULL;
}
- argstuple = _PyStack_AsTuple(stack, nargs);
+ argstuple = _PyTuple_FromArray(stack, nargs);
if (argstuple == NULL) {
return NULL;
}
@@ -508,7 +508,7 @@ _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self,
case METH_VARARGS | METH_KEYWORDS:
{
/* Slow-path: create a temporary tuple for positional arguments */
- PyObject *argstuple = _PyStack_AsTuple(args, nargs);
+ PyObject *argstuple = _PyTuple_FromArray(args, nargs);
if (argstuple == NULL) {
goto exit;
}
@@ -670,7 +670,7 @@ _PyMethodDef_RawFastCallKeywords(PyMethodDef *method, PyObject *self,
and a temporary dict for keyword arguments */
PyObject *argtuple;
- argtuple = _PyStack_AsTuple(args, nargs);
+ argtuple = _PyTuple_FromArray(args, nargs);
if (argtuple == NULL) {
goto exit;
}
@@ -1271,27 +1271,6 @@ PyObject_CallFunctionObjArgs(PyObject *callable, ...)
/* --- PyStack functions ------------------------------------------ */
-/* Issue #29234: Inlining _PyStack_AsTuple() into callers increases their
- stack consumption, Disable inlining to optimize the stack consumption. */
-_Py_NO_INLINE PyObject *
-_PyStack_AsTuple(PyObject *const *stack, Py_ssize_t nargs)
-{
- return _PyTuple_FromArray(stack, nargs);
-}
-
-
-PyObject*
-_PyStack_AsTupleSlice(PyObject *const *stack, Py_ssize_t nargs,
- Py_ssize_t start, Py_ssize_t end)
-{
- assert(0 <= start);
- assert(end <= nargs);
- assert(start <= end);
-
- return _PyTuple_FromArray(stack + start, end - start);
-}
-
-
PyObject *
_PyStack_AsDict(PyObject *const *values, PyObject *kwnames)
{
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index eebdc5ba0531..a19b8b8ddc86 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -5,6 +5,7 @@
#include "ast.h"
#undef Yield /* undefine macro conflicting with <winbase.h> */
#include "pycore_pystate.h"
+#include "pycore_tupleobject.h"
_Py_IDENTIFIER(__builtins__);
_Py_IDENTIFIER(__dict__);
@@ -121,7 +122,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
"__build_class__: name is not a string");
return NULL;
}
- orig_bases = _PyStack_AsTupleSlice(args, nargs, 2, nargs);
+ orig_bases = _PyTuple_FromArray(args + 2, nargs - 2);
if (orig_bases == NULL)
return NULL;
1
0

bpo-35512: Resolve string target to patch.dict decorator during function call GHGH-12000 (#12021)
by Chris Withers Feb. 25, 2019
by Chris Withers Feb. 25, 2019
Feb. 25, 2019
https://github.com/python/cpython/commit/ea199b90bb61866cd3c2f154341d1eb0d5…
commit: ea199b90bb61866cd3c2f154341d1eb0d5c4a710
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: Chris Withers <chris(a)withers.org>
date: 2019-02-25T21:17:16Z
summary:
bpo-35512: Resolve string target to patch.dict decorator during function call GHGH-12000 (#12021)
* Resolve string target to patch.dict during function call
* Add NEWS entry
* Remove unneeded call
* Restore original value for support.target and refactor assertions
* Add extra assertion to verify unpatched dict
(cherry picked from commit a875ea58b29fbf510f9790ae1653eeaa47dc0de8)
Co-authored-by: Xtreak <tir.karthi(a)gmail.com>
files:
A Misc/NEWS.d/next/Library/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst
M Lib/unittest/mock.py
M Lib/unittest/test/testmock/support.py
M Lib/unittest/test/testmock/testpatch.py
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 42fbc22e748c..c97ea7984a6e 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1595,8 +1595,6 @@ class _patch_dict(object):
"""
def __init__(self, in_dict, values=(), clear=False, **kwargs):
- if isinstance(in_dict, str):
- in_dict = _importer(in_dict)
self.in_dict = in_dict
# support any argument supported by dict(...) constructor
self.values = dict(values)
@@ -1637,6 +1635,8 @@ def __enter__(self):
def _patch_dict(self):
values = self.values
+ if isinstance(self.in_dict, str):
+ self.in_dict = _importer(self.in_dict)
in_dict = self.in_dict
clear = self.clear
diff --git a/Lib/unittest/test/testmock/support.py b/Lib/unittest/test/testmock/support.py
index 205431adcacc..73e406f0a86f 100644
--- a/Lib/unittest/test/testmock/support.py
+++ b/Lib/unittest/test/testmock/support.py
@@ -1,3 +1,6 @@
+target = {'foo': 'FOO'}
+
+
def is_instance(obj, klass):
"""Version of is_instance that doesn't access __class__"""
return issubclass(type(obj), klass)
diff --git a/Lib/unittest/test/testmock/testpatch.py b/Lib/unittest/test/testmock/testpatch.py
index f05225730daf..c484adb60508 100644
--- a/Lib/unittest/test/testmock/testpatch.py
+++ b/Lib/unittest/test/testmock/testpatch.py
@@ -664,6 +664,23 @@ def test():
test()
+ def test_patch_dict_decorator_resolution(self):
+ # bpo-35512: Ensure that patch with a string target resolves to
+ # the new dictionary during function call
+ original = support.target.copy()
+
+ @patch.dict('unittest.test.testmock.support.target', {'bar': 'BAR'})
+ def test():
+ self.assertEqual(support.target, {'foo': 'BAZ', 'bar': 'BAR'})
+
+ try:
+ support.target = {'foo': 'BAZ'}
+ test()
+ self.assertEqual(support.target, {'foo': 'BAZ'})
+ finally:
+ support.target = original
+
+
def test_patch_descriptor(self):
# would be some effort to fix this - we could special case the
# builtin descriptors: classmethod, property, staticmethod
diff --git a/Misc/NEWS.d/next/Library/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst b/Misc/NEWS.d/next/Library/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst
new file mode 100644
index 000000000000..8281b1b2c49a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst
@@ -0,0 +1,3 @@
+:func:`unittest.mock.patch.dict` used as a decorator with string target
+resolves the target during function call instead of during decorator
+construction. Patch by Karthikeyan Singaravelan.
1
0

Feb. 25, 2019
https://github.com/python/cpython/commit/41b48e71ac8a71f56694b548f118bd20ce…
commit: 41b48e71ac8a71f56694b548f118bd20ce203410
branch: 3.5
author: stratakis <cstratak(a)redhat.com>
committer: larryhastings <larry(a)hastings.org>
date: 2019-02-25T13:04:09-08:00
summary:
[3.5] bpo-34623: Use XML_SetHashSalt in _elementtree (#9933)
* bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146)
The C accelerated _elementtree module now initializes hash randomization
salt from _Py_HashSecret instead of libexpat's default CPRNG.
Signed-off-by: Christian Heimes <christian(a)python.org>
https://bugs.python.org/issue34623
(cherry picked from commit cb5778f00ce48631c7140f33ba242496aaf7102b)
Co-authored-by: Christian Heimes <christian(a)python.org>
files:
A Misc/NEWS.d/next/Security/2018-09-10-16-05-39.bpo-34623.Ua9jMv.rst
M Include/pyexpat.h
M Modules/_elementtree.c
M Modules/pyexpat.c
diff --git a/Include/pyexpat.h b/Include/pyexpat.h
index 44259bf6d716..07020b5dc964 100644
--- a/Include/pyexpat.h
+++ b/Include/pyexpat.h
@@ -3,7 +3,7 @@
/* note: you must import expat.h before importing this module! */
-#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.0"
+#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.1"
#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI"
struct PyExpat_CAPI
@@ -48,6 +48,8 @@ struct PyExpat_CAPI
enum XML_Status (*SetEncoding)(XML_Parser parser, const XML_Char *encoding);
int (*DefaultUnknownEncodingHandler)(
void *encodingHandlerData, const XML_Char *name, XML_Encoding *info);
+ /* might be none for expat < 2.1.0 */
+ int (*SetHashSalt)(XML_Parser parser, unsigned long hash_salt);
/* always add new stuff to the end! */
};
diff --git a/Misc/NEWS.d/next/Security/2018-09-10-16-05-39.bpo-34623.Ua9jMv.rst b/Misc/NEWS.d/next/Security/2018-09-10-16-05-39.bpo-34623.Ua9jMv.rst
new file mode 100644
index 000000000000..cbaa4b750644
--- /dev/null
+++ b/Misc/NEWS.d/next/Security/2018-09-10-16-05-39.bpo-34623.Ua9jMv.rst
@@ -0,0 +1,2 @@
+CVE-2018-14647: The C accelerated _elementtree module now initializes hash
+randomization salt from _Py_HashSecret instead of libexpat's default CSPRNG.
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 5dba9f70a94b..90c6daf64a84 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -3282,6 +3282,11 @@ _elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *html,
PyErr_NoMemory();
return -1;
}
+ /* expat < 2.1.0 has no XML_SetHashSalt() */
+ if (EXPAT(SetHashSalt) != NULL) {
+ EXPAT(SetHashSalt)(self->parser,
+ (unsigned long)_Py_HashSecret.expat.hashsalt);
+ }
if (target) {
Py_INCREF(target);
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index adc9b6cde859..948ab1b703d6 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1882,6 +1882,11 @@ MODULE_INITFUNC(void)
capi.SetStartDoctypeDeclHandler = XML_SetStartDoctypeDeclHandler;
capi.SetEncoding = XML_SetEncoding;
capi.DefaultUnknownEncodingHandler = PyUnknownEncodingHandler;
+#if XML_COMBINED_VERSION >= 20100
+ capi.SetHashSalt = XML_SetHashSalt;
+#else
+ capi.SetHashSalt = NULL;
+#endif
/* export using capsule */
capi_object = PyCapsule_New(&capi, PyExpat_CAPSULE_NAME, NULL);
1
0
https://github.com/python/cpython/commit/23f4589b4b7c4a51950a87175ce7fb31b8…
commit: 23f4589b4b7c4a51950a87175ce7fb31b89c8532
branch: master
author: Łukasz Langa <lukasz(a)langa.pl>
committer: Łukasz Langa <lukasz(a)langa.pl>
date: 2019-02-25T13:08:32+01:00
summary:
v3.8.0a2
files:
A Misc/NEWS.d/3.8.0a2.rst
D Misc/NEWS.d/next/Core and Builtins/2018-08-08-20-52-55.bpo-33989.TkLBui.rst
D Misc/NEWS.d/next/Core and Builtins/2018-09-15-12-13-46.bpo-33608.avmvVP.rst
D Misc/NEWS.d/next/Core and Builtins/2019-01-11-14-46-08.bpo-35724.Wv79MG.rst
D Misc/NEWS.d/next/Core and Builtins/2019-01-22-02-06-39.bpo-31506.eJ5FpV.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-01-18-12-14.bpo-35886.0Z-C0V.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-04-21-10-17.bpo-15248.2sXSZZ.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-05-12-48-23.bpo-12822.0x2NDx.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-06-17-50-59.bpo-35911.oiWE8.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-12-20-16-34.bpo-35961.7f7Sne.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-14-00-00-30.bpo-35991.xlbfSk.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-14-09-17-54.bpo-35993.Bvm3fP.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-14-12-01-44.bpo-35992.nG9e2L.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-16-00-42-32.bpo-1054041.BL-WLd.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-17-20-23-54.bpo-36016.5Hns-f.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-18-09-30-55.bpo-35942.oLhL2v.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-19-10-47-51.bpo-36012.xq7C9E.rst
D Misc/NEWS.d/next/Core and Builtins/2019-02-20-17-57-31.bpo-36052.l8lJSi.rst
D Misc/NEWS.d/next/Documentation/2018-07-28-12-41-01.bpo-22062.TaN2hn.rst
D Misc/NEWS.d/next/Documentation/2019-02-15-15-33-41.bpo-36007.OTFrza.rst
D Misc/NEWS.d/next/Documentation/2019-02-24-12-40-13.bpo-36083.JX7zbv.rst
D Misc/NEWS.d/next/IDLE/2019-01-08-17-51-44.bpo-35689.LlaqR8.rst
D Misc/NEWS.d/next/IDLE/2019-02-08-22-14-24.bpo-35833.XKFRvF.rst
D Misc/NEWS.d/next/IDLE/2019-02-23-22-31-20.bpo-24310.j_vJQl.rst
D Misc/NEWS.d/next/Library/2018-09-05-03-02-32.bpo-34572.ayisd2.rst
D Misc/NEWS.d/next/Library/2018-11-03-12-38-03.bpo-35153.009pdF.rst
D Misc/NEWS.d/next/Library/2018-12-04-13-35-36.bpo-32417._Y9SKM.rst
D Misc/NEWS.d/next/Library/2018-12-29-21-59-03.bpo-35606.NjGjou.rst
D Misc/NEWS.d/next/Library/2018-12-30-20-00-05.bpo-35615.Uz1SVh.rst
D Misc/NEWS.d/next/Library/2019-01-14-11-53-10.bpo-34294.3JFdg2.rst
D Misc/NEWS.d/next/Library/2019-01-21-02-15-20.bpo-35378.4oF03i.rst
D Misc/NEWS.d/next/Library/2019-02-02-01-53-36.bpo-35321.1Y4DU4.rst
D Misc/NEWS.d/next/Library/2019-02-06-01-40-55.bpo-24209.awtwPD.rst
D Misc/NEWS.d/next/Library/2019-02-07-16-22-50.bpo-35931._63i7B.rst
D Misc/NEWS.d/next/Library/2019-02-10-00-00-13.bpo-35500.1HOMmo.rst
D Misc/NEWS.d/next/Library/2019-02-10-20-57-12.bpo-35960.bh-6Ja.rst
D Misc/NEWS.d/next/Library/2019-02-11-09-24-08.bpo-18283.BT3Jhc.rst
D Misc/NEWS.d/next/Library/2019-02-11-16-23-10.bpo-35918.oGDlpT.rst
D Misc/NEWS.d/next/Library/2019-02-16-00-55-52.bpo-35904.V88MCD.rst
D Misc/NEWS.d/next/Library/2019-02-21-15-47-00.bpo-36018.qt7QUe.rst
D Misc/NEWS.d/next/Library/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst
D Misc/NEWS.d/next/Tests/2018-12-26-12-31-16.bpo-34720.T268vz.rst
D Misc/NEWS.d/next/Tests/2019-01-10-09-14-58.bpo-35704.FLglYo.rst
D Misc/NEWS.d/next/Tests/2019-02-06-18-06-16.bpo-35917.-Clv1L.rst
D Misc/NEWS.d/next/Tests/2019-02-12-01-33-08.bpo-35505.N9ba_K.rst
D Misc/NEWS.d/next/Tests/2019-02-16-15-19-31.bpo-35798.JF16MP.rst
D Misc/NEWS.d/next/Tests/2019-02-19-15-21-14.bpo-36037.75wG9_.rst
D Misc/NEWS.d/next/Tests/2019-02-21-14-23-51.bpo-36019.zS_OUi.rst
D Misc/NEWS.d/next/Tests/2019-02-24-01-58-38.bpo-27313.Sj9veH.rst
D Misc/NEWS.d/next/Windows/2019-02-02-14-47-12.bpo-35299.1rgEzd.rst
D Misc/NEWS.d/next/Windows/2019-02-02-15-56-50.bpo-35873.UW-qS9.rst
D Misc/NEWS.d/next/Windows/2019-02-02-15-57-19.bpo-35872.Bba2n7.rst
D Misc/NEWS.d/next/Windows/2019-02-02-16-23-57.bpo-35692.cIiiE9.rst
D Misc/NEWS.d/next/Windows/2019-02-11-20-07-43.bpo-35976.toap7O.rst
M Include/patchlevel.h
M Lib/pydoc_data/topics.py
M README.rst
diff --git a/Include/patchlevel.h b/Include/patchlevel.h
index 91efd275af52..d708a57d86df 100644
--- a/Include/patchlevel.h
+++ b/Include/patchlevel.h
@@ -20,10 +20,10 @@
#define PY_MINOR_VERSION 8
#define PY_MICRO_VERSION 0
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
-#define PY_RELEASE_SERIAL 1
+#define PY_RELEASE_SERIAL 2
/* Version as a string */
-#define PY_VERSION "3.8.0a1+"
+#define PY_VERSION "3.8.0a2"
/*--end constants--*/
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py
index 4310ca5ba668..c2f9fa8e2fa6 100644
--- a/Lib/pydoc_data/topics.py
+++ b/Lib/pydoc_data/topics.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Autogenerated by Sphinx on Sun Feb 3 14:00:19 2019
+# Autogenerated by Sphinx on Mon Feb 25 13:03:43 2019
topics = {'assert': 'The "assert" statement\n'
'**********************\n'
'\n'
@@ -962,7 +962,8 @@
'in a parent.)\n'
'\n'
'The space saved over using *__dict__* can be '
- 'significant.\n'
+ 'significant. Attribute\n'
+ 'lookup speed can be significantly improved as well.\n'
'\n'
'object.__slots__\n'
'\n'
@@ -8572,7 +8573,9 @@
'(unless explicitly declared in *__slots__* or available in a '
'parent.)\n'
'\n'
- 'The space saved over using *__dict__* can be significant.\n'
+ 'The space saved over using *__dict__* can be significant. '
+ 'Attribute\n'
+ 'lookup speed can be significantly improved as well.\n'
'\n'
'object.__slots__\n'
'\n'
@@ -11394,7 +11397,8 @@
' Additional information about a function’s definition can be\n'
' retrieved from its code object; see the description of '
'internal\n'
- ' types below.\n'
+ ' types below. The "cell" type can be accessed in the "types"\n'
+ ' module.\n'
'\n'
' Instance methods\n'
' An instance method object combines a class, a class instance '
diff --git a/Misc/NEWS.d/3.8.0a2.rst b/Misc/NEWS.d/3.8.0a2.rst
new file mode 100644
index 000000000000..4bf2269e064c
--- /dev/null
+++ b/Misc/NEWS.d/3.8.0a2.rst
@@ -0,0 +1,544 @@
+.. bpo: 36052
+.. date: 2019-02-20-17-57-31
+.. nonce: l8lJSi
+.. release date: 2019-02-25
+.. section: Core and Builtins
+
+Raise a :exc:`SyntaxError` when assigning a value to `__debug__` with the
+Assignment Operator. Contributed by Stéphane Wirtel and Pablo Galindo.
+
+..
+
+.. bpo: 36012
+.. date: 2019-02-19-10-47-51
+.. nonce: xq7C9E
+.. section: Core and Builtins
+
+Doubled the speed of class variable writes. When a non-dunder attribute was
+updated, there was an unnecessary call to update slots.
+
+..
+
+.. bpo: 35942
+.. date: 2019-02-18-09-30-55
+.. nonce: oLhL2v
+.. section: Core and Builtins
+
+The error message emmited when returning invalid types from ``__fspath__``
+in interfaces that allow passing :class:`~os.PathLike` objects has been
+improved and now it does explain the origin of the error.
+
+..
+
+.. bpo: 36016
+.. date: 2019-02-17-20-23-54
+.. nonce: 5Hns-f
+.. section: Core and Builtins
+
+``gc.get_objects`` can now receive an optional parameter indicating a
+generation to get objects from. Patch by Pablo Galindo.
+
+..
+
+.. bpo: 1054041
+.. date: 2019-02-16-00-42-32
+.. nonce: BL-WLd
+.. section: Core and Builtins
+
+When the main interpreter exits due to an uncaught KeyboardInterrupt, the
+process now exits in the appropriate manner for its parent process to detect
+that a SIGINT or ^C terminated the process. This allows shells and batch
+scripts to understand that the user has asked them to stop.
+
+..
+
+.. bpo: 35992
+.. date: 2019-02-14-12-01-44
+.. nonce: nG9e2L
+.. section: Core and Builtins
+
+Fix ``__class_getitem__()`` not being called on a class with a custom
+non-subscriptable metaclass.
+
+..
+
+.. bpo: 35993
+.. date: 2019-02-14-09-17-54
+.. nonce: Bvm3fP
+.. section: Core and Builtins
+
+Fix a crash on fork when using subinterpreters. Contributed by Stéphane
+Wirtel
+
+..
+
+.. bpo: 35991
+.. date: 2019-02-14-00-00-30
+.. nonce: xlbfSk
+.. section: Core and Builtins
+
+Fix a potential double free in Modules/_randommodule.c.
+
+..
+
+.. bpo: 35961
+.. date: 2019-02-12-20-16-34
+.. nonce: 7f7Sne
+.. section: Core and Builtins
+
+Fix a crash in slice_richcompare(): use strong references rather than stolen
+references for the two temporary internal tuples.
+
+..
+
+.. bpo: 35911
+.. date: 2019-02-06-17-50-59
+.. nonce: oiWE8
+.. section: Core and Builtins
+
+Enable the creation of cell objects by adding a ``cell.__new__`` method, and
+expose the type ``cell`` in ``Lib/types.py`` under the name CellType. Patch
+by Pierre Glaser.
+
+..
+
+.. bpo: 12822
+.. date: 2019-02-05-12-48-23
+.. nonce: 0x2NDx
+.. section: Core and Builtins
+
+Use monotonic clock for ``pthread_cond_timedwait`` when
+``pthread_condattr_setclock`` and ``CLOCK_MONOTONIC`` are available.
+
+..
+
+.. bpo: 15248
+.. date: 2019-02-04-21-10-17
+.. nonce: 2sXSZZ
+.. section: Core and Builtins
+
+The compiler emits now syntax warnings in the case when a comma is likely
+missed before tuple or list.
+
+..
+
+.. bpo: 35886
+.. date: 2019-02-01-18-12-14
+.. nonce: 0Z-C0V
+.. section: Core and Builtins
+
+The implementation of PyInterpreterState has been moved into the internal
+header files (guarded by Py_BUILD_CORE).
+
+..
+
+.. bpo: 31506
+.. date: 2019-01-22-02-06-39
+.. nonce: eJ5FpV
+.. section: Core and Builtins
+
+Clarify the errors reported when ``object.__new__`` and ``object.__init__``
+receive more than one argument. Contributed by Sanyam Khurana.
+
+..
+
+.. bpo: 35724
+.. date: 2019-01-11-14-46-08
+.. nonce: Wv79MG
+.. section: Core and Builtins
+
+Signal-handling is now guaranteed to happen relative to the main
+interpreter.
+
+..
+
+.. bpo: 33608
+.. date: 2018-09-15-12-13-46
+.. nonce: avmvVP
+.. section: Core and Builtins
+
+We added a new internal _Py_AddPendingCall() that operates relative to the
+provided interpreter. This allows us to use the existing implementation to
+ask another interpreter to do work that cannot be done in the current
+interpreter, like decref an object the other interpreter owns. The existing
+Py_AddPendingCall() only operates relative to the main interpreter.
+
+..
+
+.. bpo: 33989
+.. date: 2018-08-08-20-52-55
+.. nonce: TkLBui
+.. section: Core and Builtins
+
+Fix a possible crash in :meth:`list.sort` when sorting objects with
+``ob_type->tp_richcompare == NULL``. Patch by Zackery Spytz.
+
+..
+
+.. bpo: 35512
+.. date: 2019-02-24-00-04-10
+.. nonce: eWDjCJ
+.. section: Library
+
+:func:`unittest.mock.patch.dict` used as a decorator with string target
+resolves the target during function call instead of during decorator
+construction. Patch by Karthikeyan Singaravelan.
+
+..
+
+.. bpo: 36018
+.. date: 2019-02-21-15-47-00
+.. nonce: qt7QUe
+.. section: Library
+
+Add statistics.NormalDist, a tool for creating and manipulating normal
+distributions of random variable. Features a composite class that treats
+the mean and standard deviation of measurement data as single entity.
+
+..
+
+.. bpo: 35904
+.. date: 2019-02-16-00-55-52
+.. nonce: V88MCD
+.. section: Library
+
+Added statistics.fmean() as a faster, floating point variant of the existing
+mean() function.
+
+..
+
+.. bpo: 35918
+.. date: 2019-02-11-16-23-10
+.. nonce: oGDlpT
+.. section: Library
+
+Removed broken ``has_key`` method from
+multiprocessing.managers.SyncManager.dict. Contributed by Rémi Lapeyre.
+
+..
+
+.. bpo: 18283
+.. date: 2019-02-11-09-24-08
+.. nonce: BT3Jhc
+.. section: Library
+
+Add support for bytes to :func:`shutil.which`.
+
+..
+
+.. bpo: 35960
+.. date: 2019-02-10-20-57-12
+.. nonce: bh-6Ja
+.. section: Library
+
+Fix :func:`dataclasses.field` throwing away empty mapping objects passed as
+metadata.
+
+..
+
+.. bpo: 35500
+.. date: 2019-02-10-00-00-13
+.. nonce: 1HOMmo
+.. section: Library
+
+Write expected and actual call parameters on separate lines in
+:meth:`unittest.mock.Mock.assert_called_with` assertion errors. Contributed
+by Susan Su.
+
+..
+
+.. bpo: 35931
+.. date: 2019-02-07-16-22-50
+.. nonce: _63i7B
+.. section: Library
+
+The :mod:`pdb` ``debug`` command now gracefully handles syntax errors.
+
+..
+
+.. bpo: 24209
+.. date: 2019-02-06-01-40-55
+.. nonce: awtwPD
+.. section: Library
+
+In http.server script, rely on getaddrinfo to bind to preferred address
+based on the bind parameter. Now default bind or binding to a name may bind
+to IPv6 or dual-stack, depending on the environment.
+
+..
+
+.. bpo: 35321
+.. date: 2019-02-02-01-53-36
+.. nonce: 1Y4DU4
+.. section: Library
+
+Set ``__spec__.origin`` of ``_frozen_importlib`` to frozen so that it
+matches the behavior of ``_frozen_importlib_external``. Patch by Nina
+Zakharenko.
+
+..
+
+.. bpo: 35378
+.. date: 2019-01-21-02-15-20
+.. nonce: 4oF03i
+.. section: Library
+
+Fix a reference issue inside :class:`multiprocessing.Pool` that caused the
+pool to remain alive if it was deleted without being closed or terminated
+explicitly. A new strong reference is added to the pool iterators to link
+the lifetime of the pool to the lifetime of its iterators so the pool does
+not get destroyed if a pool iterator is still alive.
+
+..
+
+.. bpo: 34294
+.. date: 2019-01-14-11-53-10
+.. nonce: 3JFdg2
+.. section: Library
+
+re module, fix wrong capturing groups in rare cases. :func:`re.search`,
+:func:`re.findall`, :func:`re.sub` and other functions that scan through
+string looking for a match, should reset capturing groups between two match
+attempts. Patch by Ma Lin.
+
+..
+
+.. bpo: 35615
+.. date: 2018-12-30-20-00-05
+.. nonce: Uz1SVh
+.. section: Library
+
+:mod:`weakref`: Fix a RuntimeError when copying a WeakKeyDictionary or a
+WeakValueDictionary, due to some keys or values disappearing while
+iterating.
+
+..
+
+.. bpo: 35606
+.. date: 2018-12-29-21-59-03
+.. nonce: NjGjou
+.. section: Library
+
+Implement :func:`math.prod` as analogous function to :func:`sum` that
+returns the product of a 'start' value (default: 1) times an iterable of
+numbers. Patch by Pablo Galindo.
+
+..
+
+.. bpo: 32417
+.. date: 2018-12-04-13-35-36
+.. nonce: _Y9SKM
+.. section: Library
+
+Performing arithmetic between :class:`datetime.datetime` subclasses and
+:class:`datetime.timedelta` now returns an object of the same type as the
+:class:`datetime.datetime` subclass. As a result,
+:meth:`datetime.datetime.astimezone` and alternate constructors like
+:meth:`datetime.datetime.now` and :meth:`datetime.fromtimestamp` called with
+a ``tz`` argument now *also* retain their subclass.
+
+..
+
+.. bpo: 35153
+.. date: 2018-11-03-12-38-03
+.. nonce: 009pdF
+.. section: Library
+
+Add *headers* optional keyword-only parameter to
+:class:`xmlrpc.client.ServerProxy`, :class:`xmlrpc.client.Transport` and
+:class:`xmlrpc.client.SafeTransport`. Patch by Cédric Krier.
+
+..
+
+.. bpo: 34572
+.. date: 2018-09-05-03-02-32
+.. nonce: ayisd2
+.. section: Library
+
+Fix C implementation of pickle.loads to use importlib's locking mechanisms,
+and thereby avoid using partially-loaded modules. Patch by Tim Burgess.
+
+..
+
+.. bpo: 36083
+.. date: 2019-02-24-12-40-13
+.. nonce: JX7zbv
+.. section: Documentation
+
+Fix formatting of --check-hash-based-pycs options in the manpage Synopsis.
+
+..
+
+.. bpo: 36007
+.. date: 2019-02-15-15-33-41
+.. nonce: OTFrza
+.. section: Documentation
+
+Bump minimum sphinx version to 1.8. Patch by Anthony Sottile.
+
+..
+
+.. bpo: 22062
+.. date: 2018-07-28-12-41-01
+.. nonce: TaN2hn
+.. section: Documentation
+
+Update documentation and docstrings for pathlib. Original patch by Mike
+Short.
+
+..
+
+.. bpo: 27313
+.. date: 2019-02-24-01-58-38
+.. nonce: Sj9veH
+.. section: Tests
+
+Avoid test_ttk_guionly ComboboxTest failure with macOS Cocoa Tk.
+
+..
+
+.. bpo: 36019
+.. date: 2019-02-21-14-23-51
+.. nonce: zS_OUi
+.. section: Tests
+
+Add test.support.TEST_HTTP_URL and replace references of
+http://www.example.com by this new constant. Contributed by Stéphane Wirtel.
+
+..
+
+.. bpo: 36037
+.. date: 2019-02-19-15-21-14
+.. nonce: 75wG9_
+.. section: Tests
+
+Fix test_ssl for strict OpenSSL configuration like RHEL8 strict crypto
+policy. Use older TLS version for minimum TLS version of the server SSL
+context if needed, to test TLS version older than default minimum TLS
+version.
+
+..
+
+.. bpo: 35798
+.. date: 2019-02-16-15-19-31
+.. nonce: JF16MP
+.. section: Tests
+
+Added :func:`test.support.check_syntax_warning`.
+
+..
+
+.. bpo: 35505
+.. date: 2019-02-12-01-33-08
+.. nonce: N9ba_K
+.. section: Tests
+
+Make test_imap4_host_default_value independent on whether the local IMAP
+server is running.
+
+..
+
+.. bpo: 35917
+.. date: 2019-02-06-18-06-16
+.. nonce: -Clv1L
+.. section: Tests
+
+multiprocessing: provide unit tests for SyncManager and SharedMemoryManager
+classes + all the shareable types which are supposed to be supported by
+them. (patch by Giampaolo Rodola)
+
+..
+
+.. bpo: 35704
+.. date: 2019-01-10-09-14-58
+.. nonce: FLglYo
+.. section: Tests
+
+Skip ``test_shutil.test_unpack_archive_xztar`` to prevent a MemoryError on
+32-bit AIX when MAXDATA setting is less than 0x20000000.
+
+Patch by Michael Felt (aixtools)
+
+..
+
+.. bpo: 34720
+.. date: 2018-12-26-12-31-16
+.. nonce: T268vz
+.. section: Tests
+
+Assert m_state != NULL to mimic GC traversal functions that do not correctly
+handle module creation when the module state has not been created.
+
+..
+
+.. bpo: 35976
+.. date: 2019-02-11-20-07-43
+.. nonce: toap7O
+.. section: Windows
+
+Added ARM build support to Windows build files in PCBuild.
+
+..
+
+.. bpo: 35692
+.. date: 2019-02-02-16-23-57
+.. nonce: cIiiE9
+.. section: Windows
+
+``pathlib`` no longer raises when checking file and directory existence on
+drives that are not ready
+
+..
+
+.. bpo: 35872
+.. date: 2019-02-02-15-57-19
+.. nonce: Bba2n7
+.. section: Windows
+
+Uses the base Python executable when invoking venv in a virtual environment
+
+..
+
+.. bpo: 35873
+.. date: 2019-02-02-15-56-50
+.. nonce: UW-qS9
+.. section: Windows
+
+Prevents venv paths being inherited by child processes
+
+..
+
+.. bpo: 35299
+.. date: 2019-02-02-14-47-12
+.. nonce: 1rgEzd
+.. section: Windows
+
+Fix sysconfig detection of the source directory and distutils handling of
+pyconfig.h during PGO profiling
+
+..
+
+.. bpo: 24310
+.. date: 2019-02-23-22-31-20
+.. nonce: j_vJQl
+.. section: IDLE
+
+IDLE -- Document settings dialog font tab sample.
+
+..
+
+.. bpo: 35833
+.. date: 2019-02-08-22-14-24
+.. nonce: XKFRvF
+.. section: IDLE
+
+Revise IDLE doc for control codes sent to Shell. Add a code example block.
+
+..
+
+.. bpo: 35689
+.. date: 2019-01-08-17-51-44
+.. nonce: LlaqR8
+.. section: IDLE
+
+Add docstrings and unittests for colorizer.py.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-08-08-20-52-55.bpo-33989.TkLBui.rst b/Misc/NEWS.d/next/Core and Builtins/2018-08-08-20-52-55.bpo-33989.TkLBui.rst
deleted file mode 100644
index 056a71c480ad..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2018-08-08-20-52-55.bpo-33989.TkLBui.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix a possible crash in :meth:`list.sort` when sorting objects with
-``ob_type->tp_richcompare == NULL``. Patch by Zackery Spytz.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-09-15-12-13-46.bpo-33608.avmvVP.rst b/Misc/NEWS.d/next/Core and Builtins/2018-09-15-12-13-46.bpo-33608.avmvVP.rst
deleted file mode 100644
index 73a01a1f46bd..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2018-09-15-12-13-46.bpo-33608.avmvVP.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-We added a new internal _Py_AddPendingCall() that operates relative to the
-provided interpreter. This allows us to use the existing implementation to
-ask another interpreter to do work that cannot be done in the current
-interpreter, like decref an object the other interpreter owns. The existing
-Py_AddPendingCall() only operates relative to the main interpreter.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-01-11-14-46-08.bpo-35724.Wv79MG.rst b/Misc/NEWS.d/next/Core and Builtins/2019-01-11-14-46-08.bpo-35724.Wv79MG.rst
deleted file mode 100644
index d2d74e56cb21..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-01-11-14-46-08.bpo-35724.Wv79MG.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Signal-handling is now guaranteed to happen relative to the main
-interpreter.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-01-22-02-06-39.bpo-31506.eJ5FpV.rst b/Misc/NEWS.d/next/Core and Builtins/2019-01-22-02-06-39.bpo-31506.eJ5FpV.rst
deleted file mode 100644
index 9ebcab7e2a71..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-01-22-02-06-39.bpo-31506.eJ5FpV.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Clarify the errors reported when ``object.__new__`` and ``object.__init__``
-receive more than one argument.
-Contributed by Sanyam Khurana.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-01-18-12-14.bpo-35886.0Z-C0V.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-01-18-12-14.bpo-35886.0Z-C0V.rst
deleted file mode 100644
index 362a7a61d46f..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-01-18-12-14.bpo-35886.0Z-C0V.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-The implementation of PyInterpreterState has been moved into the internal
-header files (guarded by Py_BUILD_CORE).
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-04-21-10-17.bpo-15248.2sXSZZ.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-04-21-10-17.bpo-15248.2sXSZZ.rst
deleted file mode 100644
index e938aaa21a9d..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-04-21-10-17.bpo-15248.2sXSZZ.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-The compiler emits now syntax warnings in the case when a comma is likely
-missed before tuple or list.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-05-12-48-23.bpo-12822.0x2NDx.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-05-12-48-23.bpo-12822.0x2NDx.rst
deleted file mode 100644
index a3de435f527e..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-05-12-48-23.bpo-12822.0x2NDx.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Use monotonic clock for ``pthread_cond_timedwait`` when
-``pthread_condattr_setclock`` and ``CLOCK_MONOTONIC`` are available.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-06-17-50-59.bpo-35911.oiWE8.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-06-17-50-59.bpo-35911.oiWE8.rst
deleted file mode 100644
index 458ccb49fa41..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-06-17-50-59.bpo-35911.oiWE8.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Enable the creation of cell objects by adding a ``cell.__new__`` method, and
-expose the type ``cell`` in ``Lib/types.py`` under the name CellType. Patch by
-Pierre Glaser.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-12-20-16-34.bpo-35961.7f7Sne.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-12-20-16-34.bpo-35961.7f7Sne.rst
deleted file mode 100644
index 943aaa2f3c80..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-12-20-16-34.bpo-35961.7f7Sne.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix a crash in slice_richcompare(): use strong references rather than stolen
-references for the two temporary internal tuples.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-14-00-00-30.bpo-35991.xlbfSk.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-14-00-00-30.bpo-35991.xlbfSk.rst
deleted file mode 100644
index 4bd55208dada..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-14-00-00-30.bpo-35991.xlbfSk.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fix a potential double free in Modules/_randommodule.c.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-14-09-17-54.bpo-35993.Bvm3fP.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-14-09-17-54.bpo-35993.Bvm3fP.rst
deleted file mode 100644
index 3966f292ea8e..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-14-09-17-54.bpo-35993.Bvm3fP.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fix a crash on fork when using subinterpreters. Contributed by Stéphane Wirtel
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-14-12-01-44.bpo-35992.nG9e2L.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-14-12-01-44.bpo-35992.nG9e2L.rst
deleted file mode 100644
index 3d8dcd48cd0f..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-14-12-01-44.bpo-35992.nG9e2L.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix ``__class_getitem__()`` not being called on a class with a custom
-non-subscriptable metaclass.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-16-00-42-32.bpo-1054041.BL-WLd.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-16-00-42-32.bpo-1054041.BL-WLd.rst
deleted file mode 100644
index e61fc0bd6127..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-16-00-42-32.bpo-1054041.BL-WLd.rst
+++ /dev/null
@@ -1 +0,0 @@
-When the main interpreter exits due to an uncaught KeyboardInterrupt, the process now exits in the appropriate manner for its parent process to detect that a SIGINT or ^C terminated the process. This allows shells and batch scripts to understand that the user has asked them to stop.
\ No newline at end of file
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-17-20-23-54.bpo-36016.5Hns-f.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-17-20-23-54.bpo-36016.5Hns-f.rst
deleted file mode 100644
index 078be94a9d81..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-17-20-23-54.bpo-36016.5Hns-f.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-``gc.get_objects`` can now receive an optional parameter indicating a
-generation to get objects from. Patch by Pablo Galindo.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-18-09-30-55.bpo-35942.oLhL2v.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-18-09-30-55.bpo-35942.oLhL2v.rst
deleted file mode 100644
index 6ad4c0df2a81..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-18-09-30-55.bpo-35942.oLhL2v.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-The error message emmited when returning invalid types from ``__fspath__``
-in interfaces that allow passing :class:`~os.PathLike` objects has been
-improved and now it does explain the origin of the error.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-19-10-47-51.bpo-36012.xq7C9E.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-19-10-47-51.bpo-36012.xq7C9E.rst
deleted file mode 100644
index ff3fdbf79c6e..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-19-10-47-51.bpo-36012.xq7C9E.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Doubled the speed of class variable writes. When a non-dunder attribute was
-updated, there was an unnecessary call to update slots.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-02-20-17-57-31.bpo-36052.l8lJSi.rst b/Misc/NEWS.d/next/Core and Builtins/2019-02-20-17-57-31.bpo-36052.l8lJSi.rst
deleted file mode 100644
index 1d2094895d57..000000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2019-02-20-17-57-31.bpo-36052.l8lJSi.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Raise a :exc:`SyntaxError` when assigning a value to `__debug__` with the
-Assignment Operator. Contributed by Stéphane Wirtel and Pablo Galindo.
diff --git a/Misc/NEWS.d/next/Documentation/2018-07-28-12-41-01.bpo-22062.TaN2hn.rst b/Misc/NEWS.d/next/Documentation/2018-07-28-12-41-01.bpo-22062.TaN2hn.rst
deleted file mode 100644
index cb47fe136e6b..000000000000
--- a/Misc/NEWS.d/next/Documentation/2018-07-28-12-41-01.bpo-22062.TaN2hn.rst
+++ /dev/null
@@ -1 +0,0 @@
-Update documentation and docstrings for pathlib. Original patch by Mike Short.
diff --git a/Misc/NEWS.d/next/Documentation/2019-02-15-15-33-41.bpo-36007.OTFrza.rst b/Misc/NEWS.d/next/Documentation/2019-02-15-15-33-41.bpo-36007.OTFrza.rst
deleted file mode 100644
index e8061b3d09a2..000000000000
--- a/Misc/NEWS.d/next/Documentation/2019-02-15-15-33-41.bpo-36007.OTFrza.rst
+++ /dev/null
@@ -1 +0,0 @@
-Bump minimum sphinx version to 1.8. Patch by Anthony Sottile.
diff --git a/Misc/NEWS.d/next/Documentation/2019-02-24-12-40-13.bpo-36083.JX7zbv.rst b/Misc/NEWS.d/next/Documentation/2019-02-24-12-40-13.bpo-36083.JX7zbv.rst
deleted file mode 100644
index 950dc6e141e1..000000000000
--- a/Misc/NEWS.d/next/Documentation/2019-02-24-12-40-13.bpo-36083.JX7zbv.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fix formatting of --check-hash-based-pycs options in the manpage Synopsis.
diff --git a/Misc/NEWS.d/next/IDLE/2019-01-08-17-51-44.bpo-35689.LlaqR8.rst b/Misc/NEWS.d/next/IDLE/2019-01-08-17-51-44.bpo-35689.LlaqR8.rst
deleted file mode 100644
index 9628a6a13afc..000000000000
--- a/Misc/NEWS.d/next/IDLE/2019-01-08-17-51-44.bpo-35689.LlaqR8.rst
+++ /dev/null
@@ -1 +0,0 @@
-Add docstrings and unittests for colorizer.py.
diff --git a/Misc/NEWS.d/next/IDLE/2019-02-08-22-14-24.bpo-35833.XKFRvF.rst b/Misc/NEWS.d/next/IDLE/2019-02-08-22-14-24.bpo-35833.XKFRvF.rst
deleted file mode 100644
index abc92e9442a3..000000000000
--- a/Misc/NEWS.d/next/IDLE/2019-02-08-22-14-24.bpo-35833.XKFRvF.rst
+++ /dev/null
@@ -1 +0,0 @@
-Revise IDLE doc for control codes sent to Shell. Add a code example block.
diff --git a/Misc/NEWS.d/next/IDLE/2019-02-23-22-31-20.bpo-24310.j_vJQl.rst b/Misc/NEWS.d/next/IDLE/2019-02-23-22-31-20.bpo-24310.j_vJQl.rst
deleted file mode 100644
index 12ac99022aeb..000000000000
--- a/Misc/NEWS.d/next/IDLE/2019-02-23-22-31-20.bpo-24310.j_vJQl.rst
+++ /dev/null
@@ -1 +0,0 @@
-IDLE -- Document settings dialog font tab sample.
diff --git a/Misc/NEWS.d/next/Library/2018-09-05-03-02-32.bpo-34572.ayisd2.rst b/Misc/NEWS.d/next/Library/2018-09-05-03-02-32.bpo-34572.ayisd2.rst
deleted file mode 100644
index 0468d96420f3..000000000000
--- a/Misc/NEWS.d/next/Library/2018-09-05-03-02-32.bpo-34572.ayisd2.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Fix C implementation of pickle.loads to use importlib's locking
-mechanisms, and thereby avoid using partially-loaded modules.
-Patch by Tim Burgess.
diff --git a/Misc/NEWS.d/next/Library/2018-11-03-12-38-03.bpo-35153.009pdF.rst b/Misc/NEWS.d/next/Library/2018-11-03-12-38-03.bpo-35153.009pdF.rst
deleted file mode 100644
index 7926024a67bb..000000000000
--- a/Misc/NEWS.d/next/Library/2018-11-03-12-38-03.bpo-35153.009pdF.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Add *headers* optional keyword-only parameter to
-:class:`xmlrpc.client.ServerProxy`, :class:`xmlrpc.client.Transport` and
-:class:`xmlrpc.client.SafeTransport`. Patch by Cédric Krier.
diff --git a/Misc/NEWS.d/next/Library/2018-12-04-13-35-36.bpo-32417._Y9SKM.rst b/Misc/NEWS.d/next/Library/2018-12-04-13-35-36.bpo-32417._Y9SKM.rst
deleted file mode 100644
index cfc4fbe2e686..000000000000
--- a/Misc/NEWS.d/next/Library/2018-12-04-13-35-36.bpo-32417._Y9SKM.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-Performing arithmetic between :class:`datetime.datetime` subclasses and
-:class:`datetime.timedelta` now returns an object of the same type as the
-:class:`datetime.datetime` subclass. As a result,
-:meth:`datetime.datetime.astimezone` and alternate constructors like
-:meth:`datetime.datetime.now` and :meth:`datetime.fromtimestamp` called with
-a ``tz`` argument now *also* retain their subclass.
diff --git a/Misc/NEWS.d/next/Library/2018-12-29-21-59-03.bpo-35606.NjGjou.rst b/Misc/NEWS.d/next/Library/2018-12-29-21-59-03.bpo-35606.NjGjou.rst
deleted file mode 100644
index d70b0bcb5d48..000000000000
--- a/Misc/NEWS.d/next/Library/2018-12-29-21-59-03.bpo-35606.NjGjou.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Implement :func:`math.prod` as analogous function to :func:`sum` that
-returns the product of a 'start' value (default: 1) times an iterable of
-numbers. Patch by Pablo Galindo.
diff --git a/Misc/NEWS.d/next/Library/2018-12-30-20-00-05.bpo-35615.Uz1SVh.rst b/Misc/NEWS.d/next/Library/2018-12-30-20-00-05.bpo-35615.Uz1SVh.rst
deleted file mode 100644
index 4aff8f7f30c8..000000000000
--- a/Misc/NEWS.d/next/Library/2018-12-30-20-00-05.bpo-35615.Uz1SVh.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-:mod:`weakref`: Fix a RuntimeError when copying a WeakKeyDictionary or a
-WeakValueDictionary, due to some keys or values disappearing while
-iterating.
diff --git a/Misc/NEWS.d/next/Library/2019-01-14-11-53-10.bpo-34294.3JFdg2.rst b/Misc/NEWS.d/next/Library/2019-01-14-11-53-10.bpo-34294.3JFdg2.rst
deleted file mode 100644
index e1ae2ea6a337..000000000000
--- a/Misc/NEWS.d/next/Library/2019-01-14-11-53-10.bpo-34294.3JFdg2.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-re module, fix wrong capturing groups in rare cases. :func:`re.search`,
-:func:`re.findall`, :func:`re.sub` and other functions that scan through
-string looking for a match, should reset capturing groups between two match
-attempts. Patch by Ma Lin.
\ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2019-01-21-02-15-20.bpo-35378.4oF03i.rst b/Misc/NEWS.d/next/Library/2019-01-21-02-15-20.bpo-35378.4oF03i.rst
deleted file mode 100644
index bb57f7115991..000000000000
--- a/Misc/NEWS.d/next/Library/2019-01-21-02-15-20.bpo-35378.4oF03i.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-Fix a reference issue inside :class:`multiprocessing.Pool` that caused
-the pool to remain alive if it was deleted without being closed or
-terminated explicitly. A new strong reference is added to the pool
-iterators to link the lifetime of the pool to the lifetime of its
-iterators so the pool does not get destroyed if a pool iterator is
-still alive.
diff --git a/Misc/NEWS.d/next/Library/2019-02-02-01-53-36.bpo-35321.1Y4DU4.rst b/Misc/NEWS.d/next/Library/2019-02-02-01-53-36.bpo-35321.1Y4DU4.rst
deleted file mode 100644
index aa22384d1025..000000000000
--- a/Misc/NEWS.d/next/Library/2019-02-02-01-53-36.bpo-35321.1Y4DU4.rst
+++ /dev/null
@@ -1 +0,0 @@
-Set ``__spec__.origin`` of ``_frozen_importlib`` to frozen so that it matches the behavior of ``_frozen_importlib_external``. Patch by Nina Zakharenko.
\ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2019-02-06-01-40-55.bpo-24209.awtwPD.rst b/Misc/NEWS.d/next/Library/2019-02-06-01-40-55.bpo-24209.awtwPD.rst
deleted file mode 100644
index 4d555fd4125a..000000000000
--- a/Misc/NEWS.d/next/Library/2019-02-06-01-40-55.bpo-24209.awtwPD.rst
+++ /dev/null
@@ -1 +0,0 @@
-In http.server script, rely on getaddrinfo to bind to preferred address based on the bind parameter. Now default bind or binding to a name may bind to IPv6 or dual-stack, depending on the environment.
\ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2019-02-07-16-22-50.bpo-35931._63i7B.rst b/Misc/NEWS.d/next/Library/2019-02-07-16-22-50.bpo-35931._63i7B.rst
deleted file mode 100644
index a229968583d1..000000000000
--- a/Misc/NEWS.d/next/Library/2019-02-07-16-22-50.bpo-35931._63i7B.rst
+++ /dev/null
@@ -1 +0,0 @@
-The :mod:`pdb` ``debug`` command now gracefully handles syntax errors.
diff --git a/Misc/NEWS.d/next/Library/2019-02-10-00-00-13.bpo-35500.1HOMmo.rst b/Misc/NEWS.d/next/Library/2019-02-10-00-00-13.bpo-35500.1HOMmo.rst
deleted file mode 100644
index 16b0fbf743b0..000000000000
--- a/Misc/NEWS.d/next/Library/2019-02-10-00-00-13.bpo-35500.1HOMmo.rst
+++ /dev/null
@@ -1 +0,0 @@
-Write expected and actual call parameters on separate lines in :meth:`unittest.mock.Mock.assert_called_with` assertion errors. Contributed by Susan Su.
diff --git a/Misc/NEWS.d/next/Library/2019-02-10-20-57-12.bpo-35960.bh-6Ja.rst b/Misc/NEWS.d/next/Library/2019-02-10-20-57-12.bpo-35960.bh-6Ja.rst
deleted file mode 100644
index 67135843877f..000000000000
--- a/Misc/NEWS.d/next/Library/2019-02-10-20-57-12.bpo-35960.bh-6Ja.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix :func:`dataclasses.field` throwing away empty mapping objects passed as
-metadata.
diff --git a/Misc/NEWS.d/next/Library/2019-02-11-09-24-08.bpo-18283.BT3Jhc.rst b/Misc/NEWS.d/next/Library/2019-02-11-09-24-08.bpo-18283.BT3Jhc.rst
deleted file mode 100644
index 85704a37d307..000000000000
--- a/Misc/NEWS.d/next/Library/2019-02-11-09-24-08.bpo-18283.BT3Jhc.rst
+++ /dev/null
@@ -1 +0,0 @@
-Add support for bytes to :func:`shutil.which`.
diff --git a/Misc/NEWS.d/next/Library/2019-02-11-16-23-10.bpo-35918.oGDlpT.rst b/Misc/NEWS.d/next/Library/2019-02-11-16-23-10.bpo-35918.oGDlpT.rst
deleted file mode 100644
index 0fcce3e25085..000000000000
--- a/Misc/NEWS.d/next/Library/2019-02-11-16-23-10.bpo-35918.oGDlpT.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Removed broken ``has_key`` method from
-multiprocessing.managers.SyncManager.dict. Contributed by Rémi Lapeyre.
diff --git a/Misc/NEWS.d/next/Library/2019-02-16-00-55-52.bpo-35904.V88MCD.rst b/Misc/NEWS.d/next/Library/2019-02-16-00-55-52.bpo-35904.V88MCD.rst
deleted file mode 100644
index c40c86103056..000000000000
--- a/Misc/NEWS.d/next/Library/2019-02-16-00-55-52.bpo-35904.V88MCD.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Added statistics.fmean() as a faster, floating point variant of the existing
-mean() function.
diff --git a/Misc/NEWS.d/next/Library/2019-02-21-15-47-00.bpo-36018.qt7QUe.rst b/Misc/NEWS.d/next/Library/2019-02-21-15-47-00.bpo-36018.qt7QUe.rst
deleted file mode 100644
index bba47f4ea91e..000000000000
--- a/Misc/NEWS.d/next/Library/2019-02-21-15-47-00.bpo-36018.qt7QUe.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Add statistics.NormalDist, a tool for creating and manipulating normal
-distributions of random variable. Features a composite class that treats
-the mean and standard deviation of measurement data as single entity.
diff --git a/Misc/NEWS.d/next/Library/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst b/Misc/NEWS.d/next/Library/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst
deleted file mode 100644
index 8281b1b2c49a..000000000000
--- a/Misc/NEWS.d/next/Library/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-:func:`unittest.mock.patch.dict` used as a decorator with string target
-resolves the target during function call instead of during decorator
-construction. Patch by Karthikeyan Singaravelan.
diff --git a/Misc/NEWS.d/next/Tests/2018-12-26-12-31-16.bpo-34720.T268vz.rst b/Misc/NEWS.d/next/Tests/2018-12-26-12-31-16.bpo-34720.T268vz.rst
deleted file mode 100644
index fc490285db3c..000000000000
--- a/Misc/NEWS.d/next/Tests/2018-12-26-12-31-16.bpo-34720.T268vz.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Assert m_state != NULL to mimic GC traversal functions that do not correctly
-handle module creation when the module state has not been created.
diff --git a/Misc/NEWS.d/next/Tests/2019-01-10-09-14-58.bpo-35704.FLglYo.rst b/Misc/NEWS.d/next/Tests/2019-01-10-09-14-58.bpo-35704.FLglYo.rst
deleted file mode 100644
index e36fa4ab2884..000000000000
--- a/Misc/NEWS.d/next/Tests/2019-01-10-09-14-58.bpo-35704.FLglYo.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-Skip ``test_shutil.test_unpack_archive_xztar`` to prevent a MemoryError
-on 32-bit AIX when MAXDATA setting is less than 0x20000000.
-
-Patch by Michael Felt (aixtools)
diff --git a/Misc/NEWS.d/next/Tests/2019-02-06-18-06-16.bpo-35917.-Clv1L.rst b/Misc/NEWS.d/next/Tests/2019-02-06-18-06-16.bpo-35917.-Clv1L.rst
deleted file mode 100644
index 546d47e39d87..000000000000
--- a/Misc/NEWS.d/next/Tests/2019-02-06-18-06-16.bpo-35917.-Clv1L.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-multiprocessing: provide unit tests for SyncManager and SharedMemoryManager
-classes + all the shareable types which are supposed to be supported by
-them. (patch by Giampaolo Rodola)
diff --git a/Misc/NEWS.d/next/Tests/2019-02-12-01-33-08.bpo-35505.N9ba_K.rst b/Misc/NEWS.d/next/Tests/2019-02-12-01-33-08.bpo-35505.N9ba_K.rst
deleted file mode 100644
index f1d48d612073..000000000000
--- a/Misc/NEWS.d/next/Tests/2019-02-12-01-33-08.bpo-35505.N9ba_K.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Make test_imap4_host_default_value independent on whether the
-local IMAP server is running.
diff --git a/Misc/NEWS.d/next/Tests/2019-02-16-15-19-31.bpo-35798.JF16MP.rst b/Misc/NEWS.d/next/Tests/2019-02-16-15-19-31.bpo-35798.JF16MP.rst
deleted file mode 100644
index e3204666cba5..000000000000
--- a/Misc/NEWS.d/next/Tests/2019-02-16-15-19-31.bpo-35798.JF16MP.rst
+++ /dev/null
@@ -1 +0,0 @@
-Added :func:`test.support.check_syntax_warning`.
diff --git a/Misc/NEWS.d/next/Tests/2019-02-19-15-21-14.bpo-36037.75wG9_.rst b/Misc/NEWS.d/next/Tests/2019-02-19-15-21-14.bpo-36037.75wG9_.rst
deleted file mode 100644
index dbc0fa256e02..000000000000
--- a/Misc/NEWS.d/next/Tests/2019-02-19-15-21-14.bpo-36037.75wG9_.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Fix test_ssl for strict OpenSSL configuration like RHEL8 strict crypto policy.
-Use older TLS version for minimum TLS version of the server SSL context if
-needed, to test TLS version older than default minimum TLS version.
diff --git a/Misc/NEWS.d/next/Tests/2019-02-21-14-23-51.bpo-36019.zS_OUi.rst b/Misc/NEWS.d/next/Tests/2019-02-21-14-23-51.bpo-36019.zS_OUi.rst
deleted file mode 100644
index b14d157ff492..000000000000
--- a/Misc/NEWS.d/next/Tests/2019-02-21-14-23-51.bpo-36019.zS_OUi.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Add test.support.TEST_HTTP_URL and replace references of http://www.example.com
-by this new constant. Contributed by Stéphane Wirtel.
diff --git a/Misc/NEWS.d/next/Tests/2019-02-24-01-58-38.bpo-27313.Sj9veH.rst b/Misc/NEWS.d/next/Tests/2019-02-24-01-58-38.bpo-27313.Sj9veH.rst
deleted file mode 100644
index 189b9cf69f07..000000000000
--- a/Misc/NEWS.d/next/Tests/2019-02-24-01-58-38.bpo-27313.Sj9veH.rst
+++ /dev/null
@@ -1 +0,0 @@
-Avoid test_ttk_guionly ComboboxTest failure with macOS Cocoa Tk.
diff --git a/Misc/NEWS.d/next/Windows/2019-02-02-14-47-12.bpo-35299.1rgEzd.rst b/Misc/NEWS.d/next/Windows/2019-02-02-14-47-12.bpo-35299.1rgEzd.rst
deleted file mode 100644
index 19fba619b5ab..000000000000
--- a/Misc/NEWS.d/next/Windows/2019-02-02-14-47-12.bpo-35299.1rgEzd.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix sysconfig detection of the source directory and distutils handling of
-pyconfig.h during PGO profiling
diff --git a/Misc/NEWS.d/next/Windows/2019-02-02-15-56-50.bpo-35873.UW-qS9.rst b/Misc/NEWS.d/next/Windows/2019-02-02-15-56-50.bpo-35873.UW-qS9.rst
deleted file mode 100644
index a9ce777a4bd3..000000000000
--- a/Misc/NEWS.d/next/Windows/2019-02-02-15-56-50.bpo-35873.UW-qS9.rst
+++ /dev/null
@@ -1 +0,0 @@
-Prevents venv paths being inherited by child processes
diff --git a/Misc/NEWS.d/next/Windows/2019-02-02-15-57-19.bpo-35872.Bba2n7.rst b/Misc/NEWS.d/next/Windows/2019-02-02-15-57-19.bpo-35872.Bba2n7.rst
deleted file mode 100644
index be293c5b5255..000000000000
--- a/Misc/NEWS.d/next/Windows/2019-02-02-15-57-19.bpo-35872.Bba2n7.rst
+++ /dev/null
@@ -1 +0,0 @@
-Uses the base Python executable when invoking venv in a virtual environment
diff --git a/Misc/NEWS.d/next/Windows/2019-02-02-16-23-57.bpo-35692.cIiiE9.rst b/Misc/NEWS.d/next/Windows/2019-02-02-16-23-57.bpo-35692.cIiiE9.rst
deleted file mode 100644
index f3715739d4df..000000000000
--- a/Misc/NEWS.d/next/Windows/2019-02-02-16-23-57.bpo-35692.cIiiE9.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-``pathlib`` no longer raises when checking file and directory existence on
-drives that are not ready
diff --git a/Misc/NEWS.d/next/Windows/2019-02-11-20-07-43.bpo-35976.toap7O.rst b/Misc/NEWS.d/next/Windows/2019-02-11-20-07-43.bpo-35976.toap7O.rst
deleted file mode 100644
index 36a0132ce37a..000000000000
--- a/Misc/NEWS.d/next/Windows/2019-02-11-20-07-43.bpo-35976.toap7O.rst
+++ /dev/null
@@ -1 +0,0 @@
-Added ARM build support to Windows build files in PCBuild.
diff --git a/README.rst b/README.rst
index ed8c8fb20381..11f5d0b5d3ca 100644
--- a/README.rst
+++ b/README.rst
@@ -1,4 +1,4 @@
-This is Python version 3.8.0 alpha 1
+This is Python version 3.8.0 alpha 2
====================================
.. image:: https://travis-ci.org/python/cpython.svg?branch=master
1
0

Feb. 25, 2019
https://github.com/python/cpython/commit/234531b4462b20d668762bd78406fd2eba…
commit: 234531b4462b20d668762bd78406fd2ebab129c9
branch: master
author: Sergey Fedoseev <fedoseev.sergey(a)gmail.com>
committer: Victor Stinner <vstinner(a)redhat.com>
date: 2019-02-25T17:59:12+01:00
summary:
bpo-36030: Add _PyTuple_FromArray() function (GH-11954)
files:
M Include/internal/pycore_tupleobject.h
M Modules/itertoolsmodule.c
M Objects/call.c
M Objects/listobject.c
M Objects/structseq.c
M Objects/tupleobject.c
M Python/ceval.c
diff --git a/Include/internal/pycore_tupleobject.h b/Include/internal/pycore_tupleobject.h
index fdd741467665..d0c5b620d356 100644
--- a/Include/internal/pycore_tupleobject.h
+++ b/Include/internal/pycore_tupleobject.h
@@ -11,6 +11,7 @@ extern "C" {
#include "tupleobject.h"
#define _PyTuple_ITEMS(op) (_PyTuple_CAST(op)->ob_item)
+PyAPI_FUNC(PyObject *) _PyTuple_FromArray(PyObject *const *, Py_ssize_t);
#ifdef __cplusplus
}
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index c589dd10d497..536f7fa6253a 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1,6 +1,7 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
+#include "pycore_tupleobject.h"
#include "structmember.h"
/* Itertools module written and maintained
@@ -2239,15 +2240,10 @@ product_next(productobject *lz)
/* Copy the previous result tuple or re-use it if available */
if (Py_REFCNT(result) > 1) {
PyObject *old_result = result;
- result = PyTuple_New(npools);
+ result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), npools);
if (result == NULL)
goto empty;
lz->result = result;
- for (i=0; i < npools; i++) {
- elem = PyTuple_GET_ITEM(old_result, i);
- Py_INCREF(elem);
- PyTuple_SET_ITEM(result, i, elem);
- }
Py_DECREF(old_result);
}
/* Now, we've got the only copy so we can update it in-place */
@@ -2569,15 +2565,10 @@ combinations_next(combinationsobject *co)
/* Copy the previous result tuple or re-use it if available */
if (Py_REFCNT(result) > 1) {
PyObject *old_result = result;
- result = PyTuple_New(r);
+ result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r);
if (result == NULL)
goto empty;
co->result = result;
- for (i=0; i<r ; i++) {
- elem = PyTuple_GET_ITEM(old_result, i);
- Py_INCREF(elem);
- PyTuple_SET_ITEM(result, i, elem);
- }
Py_DECREF(old_result);
}
/* Now, we've got the only copy so we can update it in-place
@@ -2910,15 +2901,10 @@ cwr_next(cwrobject *co)
/* Copy the previous result tuple or re-use it if available */
if (Py_REFCNT(result) > 1) {
PyObject *old_result = result;
- result = PyTuple_New(r);
+ result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r);
if (result == NULL)
goto empty;
co->result = result;
- for (i=0; i<r ; i++) {
- elem = PyTuple_GET_ITEM(old_result, i);
- Py_INCREF(elem);
- PyTuple_SET_ITEM(result, i, elem);
- }
Py_DECREF(old_result);
}
/* Now, we've got the only copy so we can update it in-place CPython's
@@ -3258,15 +3244,10 @@ permutations_next(permutationsobject *po)
/* Copy the previous result tuple or re-use it if available */
if (Py_REFCNT(result) > 1) {
PyObject *old_result = result;
- result = PyTuple_New(r);
+ result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r);
if (result == NULL)
goto empty;
po->result = result;
- for (i=0; i<r ; i++) {
- elem = PyTuple_GET_ITEM(old_result, i);
- Py_INCREF(elem);
- PyTuple_SET_ITEM(result, i, elem);
- }
Py_DECREF(old_result);
}
/* Now, we've got the only copy so we can update it in-place */
diff --git a/Objects/call.c b/Objects/call.c
index be8e90d03d66..3250f8a10dff 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -1276,20 +1276,7 @@ PyObject_CallFunctionObjArgs(PyObject *callable, ...)
_Py_NO_INLINE PyObject *
_PyStack_AsTuple(PyObject *const *stack, Py_ssize_t nargs)
{
- PyObject *args;
- Py_ssize_t i;
-
- args = PyTuple_New(nargs);
- if (args == NULL) {
- return NULL;
- }
-
- for (i=0; i < nargs; i++) {
- PyObject *item = stack[i];
- Py_INCREF(item);
- PyTuple_SET_ITEM(args, i, item);
- }
- return args;
+ return _PyTuple_FromArray(stack, nargs);
}
@@ -1297,24 +1284,11 @@ PyObject*
_PyStack_AsTupleSlice(PyObject *const *stack, Py_ssize_t nargs,
Py_ssize_t start, Py_ssize_t end)
{
- PyObject *args;
- Py_ssize_t i;
-
assert(0 <= start);
assert(end <= nargs);
assert(start <= end);
- args = PyTuple_New(end - start);
- if (args == NULL) {
- return NULL;
- }
-
- for (i=start; i < end; i++) {
- PyObject *item = stack[i];
- Py_INCREF(item);
- PyTuple_SET_ITEM(args, i - start, item);
- }
- return args;
+ return _PyTuple_FromArray(stack + start, end - start);
}
diff --git a/Objects/listobject.c b/Objects/listobject.c
index cbd6e81ea472..b6524e8bd7fc 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -3,6 +3,7 @@
#include "Python.h"
#include "pycore_object.h"
#include "pycore_pystate.h"
+#include "pycore_tupleobject.h"
#include "pycore_accu.h"
#ifdef STDC_HEADERS
@@ -2501,26 +2502,11 @@ PyList_Reverse(PyObject *v)
PyObject *
PyList_AsTuple(PyObject *v)
{
- PyObject *w;
- PyObject **p, **q;
- Py_ssize_t n;
if (v == NULL || !PyList_Check(v)) {
PyErr_BadInternalCall();
return NULL;
}
- n = Py_SIZE(v);
- w = PyTuple_New(n);
- if (w == NULL)
- return NULL;
- p = ((PyTupleObject *)w)->ob_item;
- q = ((PyListObject *)v)->ob_item;
- while (--n >= 0) {
- Py_INCREF(*q);
- *p = *q;
- p++;
- q++;
- }
- return w;
+ return _PyTuple_FromArray(((PyListObject *)v)->ob_item, Py_SIZE(v));
}
/*[clinic input]
diff --git a/Objects/structseq.c b/Objects/structseq.c
index cf94155f18f8..56b06c707f89 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -2,6 +2,7 @@
and posixmodule for example uses. */
#include "Python.h"
+#include "pycore_tupleobject.h"
#include "structmember.h"
static const char visible_length_key[] = "n_sequence_fields";
@@ -250,7 +251,7 @@ structseq_reduce(PyStructSequence* self, PyObject *Py_UNUSED(ignored))
n_fields = REAL_SIZE(self);
n_visible_fields = VISIBLE_SIZE(self);
n_unnamed_fields = UNNAMED_FIELDS(self);
- tup = PyTuple_New(n_visible_fields);
+ tup = _PyTuple_FromArray(self->ob_item, n_visible_fields);
if (!tup)
goto error;
@@ -258,12 +259,7 @@ structseq_reduce(PyStructSequence* self, PyObject *Py_UNUSED(ignored))
if (!dict)
goto error;
- for (i = 0; i < n_visible_fields; i++) {
- Py_INCREF(self->ob_item[i]);
- PyTuple_SET_ITEM(tup, i, self->ob_item[i]);
- }
-
- for (; i < n_fields; i++) {
+ for (i = n_visible_fields; i < n_fields; i++) {
const char *n = Py_TYPE(self)->tp_members[i-n_unnamed_fields].name;
if (PyDict_SetItemString(dict, n, self->ob_item[i]) < 0)
goto error;
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 9cf3f3dd66ee..75d2bf95e668 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -419,14 +419,26 @@ tupleitem(PyTupleObject *a, Py_ssize_t i)
return a->ob_item[i];
}
+PyObject *
+_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
+{
+ PyTupleObject *tuple = (PyTupleObject *)PyTuple_New(n);
+ if (tuple == NULL) {
+ return NULL;
+ }
+ PyObject **dst = tuple->ob_item;
+ for (Py_ssize_t i = 0; i < n; i++) {
+ PyObject *item = src[i];
+ Py_INCREF(item);
+ dst[i] = item;
+ }
+ return (PyObject *)tuple;
+}
+
static PyObject *
tupleslice(PyTupleObject *a, Py_ssize_t ilow,
Py_ssize_t ihigh)
{
- PyTupleObject *np;
- PyObject **src, **dest;
- Py_ssize_t i;
- Py_ssize_t len;
if (ilow < 0)
ilow = 0;
if (ihigh > Py_SIZE(a))
@@ -437,18 +449,7 @@ tupleslice(PyTupleObject *a, Py_ssize_t ilow,
Py_INCREF(a);
return (PyObject *)a;
}
- len = ihigh - ilow;
- np = (PyTupleObject *)PyTuple_New(len);
- if (np == NULL)
- return NULL;
- src = a->ob_item + ilow;
- dest = np->ob_item;
- for (i = 0; i < len; i++) {
- PyObject *v = src[i];
- Py_INCREF(v);
- dest[i] = v;
- }
- return (PyObject *)np;
+ return _PyTuple_FromArray(a->ob_item + ilow, ihigh - ilow);
}
PyObject *
diff --git a/Python/ceval.c b/Python/ceval.c
index ff8386352ba6..68c1617c78f2 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3831,16 +3831,11 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
/* Pack other positional arguments into the *args argument */
if (co->co_flags & CO_VARARGS) {
- u = PyTuple_New(argcount - n);
+ u = _PyTuple_FromArray(args + n, argcount - n);
if (u == NULL) {
goto fail;
}
SETLOCAL(total_args, u);
- for (i = n; i < argcount; i++) {
- x = args[i];
- Py_INCREF(x);
- PyTuple_SET_ITEM(u, i-n, x);
- }
}
/* Handle keyword arguments passed as two strided arrays */
1
0

[3.7] bpo-28450: Fix and improve the documentation for unknown escapes in RE. (GH-11920). (GH-12029)
by Serhiy Storchaka Feb. 25, 2019
by Serhiy Storchaka Feb. 25, 2019
Feb. 25, 2019
https://github.com/python/cpython/commit/95fc8e687c487ecf97f4b1b98dfc0c05e3…
commit: 95fc8e687c487ecf97f4b1b98dfc0c05e3c9cbff
branch: 3.7
author: Serhiy Storchaka <storchaka(a)gmail.com>
committer: GitHub <noreply(a)github.com>
date: 2019-02-25T18:28:53+02:00
summary:
[3.7] bpo-28450: Fix and improve the documentation for unknown escapes in RE. (GH-11920). (GH-12029)
(cherry picked from commit a180b007d96fe68b32f11dec720fbd0cd5b6758a)
files:
M Doc/library/re.rst
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index 39ba44eba1c1..dc3f428b8a19 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -570,7 +570,8 @@ accepted by the regular expression parser::
only inside character classes.)
``'\u'`` and ``'\U'`` escape sequences are only recognized in Unicode
-patterns. In bytes patterns they are errors.
+patterns. In bytes patterns they are errors. Unknown escapes of ASCII
+letters are reserved for future use and treated as errors.
Octal escapes are included in a limited form. If the first digit is a 0, or if
there are three octal digits, it is considered an octal escape. Otherwise, it is
@@ -844,7 +845,9 @@ form.
*string* is returned unchanged. *repl* can be a string or a function; if it is
a string, any backslash escapes in it are processed. That is, ``\n`` is
converted to a single newline character, ``\r`` is converted to a carriage return, and
- so forth. Unknown escapes such as ``\&`` are left alone. Backreferences, such
+ so forth. Unknown escapes of ASCII letters are reserved for future use and
+ treated as errors. Other unknown escapes such as ``\&`` are left alone.
+ Backreferences, such
as ``\6``, are replaced with the substring matched by group 6 in the pattern.
For example::
1
0

Remove empty Dictionaries section from programming FAQ (GH-12026)
by Miss Islington (bot) Feb. 25, 2019
by Miss Islington (bot) Feb. 25, 2019
Feb. 25, 2019
https://github.com/python/cpython/commit/a1caf65d5ef5c1b5aaf505a2a075ec15b6…
commit: a1caf65d5ef5c1b5aaf505a2a075ec15b6f7dc39
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: GitHub <noreply(a)github.com>
date: 2019-02-25T08:27:54-08:00
summary:
Remove empty Dictionaries section from programming FAQ (GH-12026)
(cherry picked from commit 55e335d7d59be44819c6b672d258e2d5feb1e633)
Co-authored-by: Andre Delfino <adelfino(a)gmail.com>
files:
M Doc/faq/programming.rst
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
index 047812e6e036..7bc00ff7e69d 100644
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -1317,9 +1317,6 @@ The ``__iadd__`` succeeds, and thus the list is extended, but even though
that final assignment still results in an error, because tuples are immutable.
-Dictionaries
-============
-
I want to do a complicated sort: can you do a Schwartzian Transform in Python?
------------------------------------------------------------------------------
1
0

Feb. 25, 2019
https://github.com/python/cpython/commit/55e335d7d59be44819c6b672d258e2d5fe…
commit: 55e335d7d59be44819c6b672d258e2d5feb1e633
branch: master
author: Andre Delfino <adelfino(a)gmail.com>
committer: Cheryl Sabella <cheryl.sabella(a)gmail.com>
date: 2019-02-25T11:22:07-05:00
summary:
Remove empty Dictionaries section from programming FAQ (GH-12026)
files:
M Doc/faq/programming.rst
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
index 047812e6e036..7bc00ff7e69d 100644
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -1317,9 +1317,6 @@ The ``__iadd__`` succeeds, and thus the list is extended, but even though
that final assignment still results in an error, because tuples are immutable.
-Dictionaries
-============
-
I want to do a complicated sort: can you do a Schwartzian Transform in Python?
------------------------------------------------------------------------------
1
0