Hello community, here is the log from the commit of package python3 for openSUSE:Factory checked in at 2018-02-25 12:20:20 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3 (Old) and /work/SRC/openSUSE:Factory/.python3.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3" Sun Feb 25 12:20:20 2018 rev:85 rq:578394 version:3.6.4 Changes: -------- --- /work/SRC/openSUSE:Factory/python3/python3-base.changes 2018-02-14 09:18:29.212042108 +0100 +++ /work/SRC/openSUSE:Factory/.python3.new/python3-base.changes 2018-02-25 12:20:27.911671558 +0100 @@ -1,0 +2,10 @@ +Tue Feb 20 15:04:56 UTC 2018 - [email protected] + +- ctypes-pass-by-value.patch: Fix pass by value for structs on aarch64 + +------------------------------------------------------------------- +Tue Feb 20 14:28:00 UTC 2018 - [email protected] + +- Add python3-sorted_tar.patch (boo#1081750) + +------------------------------------------------------------------- --- /work/SRC/openSUSE:Factory/python3/python3.changes 2018-02-14 09:18:31.407962511 +0100 +++ /work/SRC/openSUSE:Factory/.python3.new/python3.changes 2018-02-25 12:20:31.707534075 +0100 @@ -1,0 +2,6 @@ +Tue Feb 20 14:08:57 UTC 2018 - [email protected] + +- Drop python3-tk and python3-idle recommends to reduce python3 + always pulling X stack bsc#1081751 + +------------------------------------------------------------------- New: ---- ctypes-pass-by-value.patch python3-sorted_tar.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-base.spec ++++++ --- /var/tmp/diff_new_pack.A6nrmA/_old 2018-02-25 12:20:33.179480763 +0100 +++ /var/tmp/diff_new_pack.A6nrmA/_new 2018-02-25 12:20:33.191480328 +0100 @@ -171,6 +171,10 @@ Patch23: skip_random_failing_tests.patch # Fix glibc-2.27 fail Patch24: fix-localeconv-encoding-for-LC_NUMERIC.patch +# PATCH-FIX-UPSTREAM sorted tar https://github.com/python/cpython/pull/2263 +Patch25: python3-sorted_tar.patch +# bpo-30353 +Patch26: ctypes-pass-by-value.patch ### COMMON-PATCH-END ### %description @@ -267,6 +271,8 @@ %patch23 -p1 %endif %patch24 -p1 +%patch25 -p1 +%patch26 -p1 # drop Autoconf version requirement sed -i 's/^AC_PREREQ/dnl AC_PREREQ/' configure.ac python3-doc.spec: same change ++++++ python3.spec ++++++ --- /var/tmp/diff_new_pack.A6nrmA/_old 2018-02-25 12:20:33.295476562 +0100 +++ /var/tmp/diff_new_pack.A6nrmA/_new 2018-02-25 12:20:33.299476417 +0100 @@ -91,9 +91,7 @@ Requires: python3-base = %{version} Recommends: python3-curses Recommends: python3-dbm -Recommends: python3-idle Recommends: python3-pip -Recommends: python3-tk Provides: python = %{python_version} # # do not add patches here, please edit python3-base.spec instead @@ -126,6 +124,10 @@ Patch23: skip_random_failing_tests.patch # Fix glibc-2.27 fail Patch24: fix-localeconv-encoding-for-LC_NUMERIC.patch +# PATCH-FIX-UPSTREAM sorted tar https://github.com/python/cpython/pull/2263 +Patch25: python3-sorted_tar.patch +# bpo-30353 +Patch26: ctypes-pass-by-value.patch ### COMMON-PATCH-END ### %description @@ -186,6 +188,8 @@ %patch23 -p1 %endif %patch24 -p1 +%patch25 -p1 +%patch26 -p1 # drop Autoconf version requirement sed -i 's/^AC_PREREQ/dnl AC_PREREQ/' configure.ac ++++++ ctypes-pass-by-value.patch ++++++ >From 9ba3aa4d02a110d1a1ea464a8aff3be7dd9c63c3 Mon Sep 17 00:00:00 2001 From: Erik Bray <[email protected]> Date: Wed, 7 Jun 2017 18:42:24 +0100 Subject: [PATCH] bpo-30353: Fix pass by value for structs on 64-bit Cygwin/MinGW (GH-1559) --- Lib/ctypes/test/test_as_parameter.py | 4 ++++ Lib/ctypes/test/test_structures.py | 22 ++++++++++++++++++++++ Modules/_ctypes/_ctypes_test.c | 18 ++++++++++++++++++ Modules/_ctypes/callproc.c | 23 +++++++++++++++++++++-- 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/Lib/ctypes/test/test_as_parameter.py b/Lib/ctypes/test/test_as_parameter.py index 2a3484bec0..a2640575a0 100644 --- a/Lib/ctypes/test/test_as_parameter.py +++ b/Lib/ctypes/test/test_as_parameter.py @@ -169,6 +169,10 @@ class BasicWrapTestCase(unittest.TestCase): s2h = dll.ret_2h_func(self.wrap(inp)) self.assertEqual((s2h.x, s2h.y), (99*2, 88*3)) + # Test also that the original struct was unmodified (i.e. was passed by + # value) + self.assertEqual((inp.x, inp.y), (99, 88)) + def test_struct_return_8H(self): class S8I(Structure): _fields_ = [("a", c_int), diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py index 2e778fb1b4..d90c71144c 100644 --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -417,6 +417,28 @@ class StructureTestCase(unittest.TestCase): self.assertEqual(s.second, 0xcafebabe) self.assertEqual(s.third, 0x0bad1dea) + def test_pass_by_value_in_register(self): + class X(Structure): + _fields_ = [ + ('first', c_uint), + ('second', c_uint) + ] + + s = X() + s.first = 0xdeadbeef + s.second = 0xcafebabe + dll = CDLL(_ctypes_test.__file__) + func = dll._testfunc_reg_struct_update_value + func.argtypes = (X,) + func.restype = None + func(s) + self.assertEqual(s.first, 0xdeadbeef) + self.assertEqual(s.second, 0xcafebabe) + got = X.in_dll(dll, "last_tfrsuv_arg") + self.assertEqual(s.first, got.first) + self.assertEqual(s.second, got.second) + + class PointerMemberTestCase(unittest.TestCase): def test(self): diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c index fe0015c801..2255e57339 100644 --- a/Modules/_ctypes/_ctypes_test.c +++ b/Modules/_ctypes/_ctypes_test.c @@ -57,6 +57,24 @@ _testfunc_large_struct_update_value(Test in) ((volatile Test *)&in)->third = 0x0badf00d; } +typedef struct { + unsigned int first; + unsigned int second; +} TestReg; + + +EXPORT(TestReg) last_tfrsuv_arg; + + +EXPORT(void) +_testfunc_reg_struct_update_value(TestReg in) +{ + last_tfrsuv_arg = in; + ((volatile TestReg *)&in)->first = 0x0badf00d; + ((volatile TestReg *)&in)->second = 0x0badf00d; +} + + EXPORT(void)testfunc_array(int values[4]) { printf("testfunc_array %d %d %d %d\n", diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 0b6faf96c6..5439b939dc 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1039,6 +1039,13 @@ GetComError(HRESULT errcode, GUID *riid, IUnknown *pIunk) } #endif +#if (defined(__x86_64__) && (defined(__MINGW64__) || defined(__CYGWIN__))) || \ + defined(__aarch64__) +#define CTYPES_PASS_BY_REF_HACK +#define POW2(x) (((x & ~(x - 1)) == x) ? x : 0) +#define IS_PASS_BY_REF(x) (x > 8 || !POW2(x)) +#endif + /* * Requirements, must be ensured by the caller: * - argtuple is tuple of arguments @@ -1136,8 +1143,20 @@ PyObject *_ctypes_callproc(PPROC pProc, } for (i = 0; i < argcount; ++i) { atypes[i] = args[i].ffi_type; - if (atypes[i]->type == FFI_TYPE_STRUCT - ) +#ifdef CTYPES_PASS_BY_REF_HACK + size_t size = atypes[i]->size; + if (IS_PASS_BY_REF(size)) { + void *tmp = alloca(size); + if (atypes[i]->type == FFI_TYPE_STRUCT) + memcpy(tmp, args[i].value.p, size); + else + memcpy(tmp, (void*)&args[i].value, size); + + avalues[i] = tmp; + } + else +#endif + if (atypes[i]->type == FFI_TYPE_STRUCT) avalues[i] = (void *)args[i].value.p; else avalues[i] = (void *)&args[i].value; -- 2.16.2 ++++++ python3-sorted_tar.patch ++++++ commit c11b93fd5e04c2541954ba7bc7b17027742edad1 Author: Bernhard M. Wiedemann <[email protected]> Date: Wed Jan 31 11:17:10 2018 +0100 bpo-30693: zip+tarfile: sort directory listing (#2263) tarfile and zipfile now sort directory listing to generate tar and zip archives in a more reproducible way. See also https://reproducible-builds.org/docs/stable-inputs/ on that topic. diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index 337c061107..1425b47e4e 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -467,6 +467,9 @@ be finalized; only the internally used file object will be closed. See the The *exclude* parameter is deprecated, please use the *filter* parameter instead. + .. versionchanged:: 3.6.4 + Recursion adds entries in sorted order. + .. method:: TarFile.addfile(tarinfo, fileobj=None) diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst index a5d42118ba..74f14c5ba7 100644 --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -471,7 +471,7 @@ The :class:`PyZipFile` constructor takes the same parameters as the :file:`\*.pyc` are added at the top level. If the directory is a package directory, then all :file:`\*.pyc` are added under the package name as a file path, and if any subdirectories are package directories, - all of these are added recursively. + all of these are added recursively in sorted order. *basename* is intended for internal use only. @@ -504,6 +504,9 @@ The :class:`PyZipFile` constructor takes the same parameters as the .. versionchanged:: 3.6.2 The *pathname* parameter accepts a :term:`path-like object`. + .. versionchanged:: 3.6.4 + Recursion sorts directory entries. + .. _zipinfo-objects: diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 631b69dcba..32e4ac0abe 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1951,7 +1951,7 @@ class TarFile(object): elif tarinfo.isdir(): self.addfile(tarinfo) if recursive: - for f in os.listdir(name): + for f in sorted(os.listdir(name)): self.add(os.path.join(name, f), os.path.join(arcname, f), recursive, exclude, filter=filter) diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index fc79055421..7351e92b30 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -1129,6 +1129,30 @@ class WriteTest(WriteTestBase, unittest.TestCase): finally: support.rmdir(path) + # mock the following: + # os.listdir: so we know that files are in the wrong order + @unittest.mock.patch('os.listdir') + def test_ordered_recursion(self, mock_listdir): + path = os.path.join(TEMPDIR, "directory") + os.mkdir(path) + open(os.path.join(path, "1"), "a").close() + open(os.path.join(path, "2"), "a").close() + mock_listdir.return_value = ["2", "1"] + try: + tar = tarfile.open(tmpname, self.mode) + try: + tar.add(path) + paths = [] + for m in tar.getmembers(): + paths.append(os.path.split(m.name)[-1]) + self.assertEqual(paths, ["directory", "1", "2"]); + finally: + tar.close() + finally: + support.unlink(os.path.join(path, "1")) + support.unlink(os.path.join(path, "2")) + support.rmdir(path) + def test_gettarinfo_pathlike_name(self): with tarfile.open(tmpname, self.mode) as tar: path = pathlib.Path(TEMPDIR) / "file" diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 9164f8ab08..d6d649d418 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1836,7 +1836,7 @@ class PyZipFile(ZipFile): if self.debug: print("Adding", arcname) self.write(fname, arcname) - dirlist = os.listdir(pathname) + dirlist = sorted(os.listdir(pathname)) dirlist.remove("__init__.py") # Add all *.py files and package subdirectories for filename in dirlist: @@ -1861,7 +1861,7 @@ class PyZipFile(ZipFile): # This is NOT a package directory, add its files at top level if self.debug: print("Adding files from directory", pathname) - for filename in os.listdir(pathname): + for filename in sorted(os.listdir(pathname)): path = os.path.join(pathname, filename) root, ext = os.path.splitext(filename) if ext == ".py": @@ -2018,7 +2018,7 @@ def main(args = None): elif os.path.isdir(path): if zippath: zf.write(path, zippath) - for nm in os.listdir(path): + for nm in sorted(os.listdir(path)): addToZip(zf, os.path.join(path, nm), os.path.join(zippath, nm)) # else: ignore diff --git a/Misc/NEWS.d/next/Library/2017-11-27-15-09-49.bpo-30693.yC4mJ7.rst b/Misc/NEWS.d/next/Library/2017-11-27-15-09-49.bpo-30693.yC4mJ7.rst new file mode 100644 index 0000000000..9c895c53de --- /dev/null +++ b/Misc/NEWS.d/next/Library/2017-11-27-15-09-49.bpo-30693.yC4mJ7.rst @@ -0,0 +1 @@ +The ZipFile class now recurses directories in a reproducible way. diff --git a/Misc/NEWS.d/next/Library/2017-11-27-15-09-49.bpo-30693.yC4mJ8.rst b/Misc/NEWS.d/next/Library/2017-11-27-15-09-49.bpo-30693.yC4mJ8.rst new file mode 100644 index 0000000000..a622e7ed6e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2017-11-27-15-09-49.bpo-30693.yC4mJ8.rst @@ -0,0 +1 @@ +The TarFile class now recurses directories in a reproducible way.
