Rebased to Python 3.8.0rc1
Rebased patches: 102 Removed patches already merged upstream: 331
This commit is contained in:
parent
06c7812898
commit
8e2dbb0fbf
@ -1,4 +1,4 @@
|
|||||||
From 06e1abca862a731ab42dd4f04c232511a2ade166 Mon Sep 17 00:00:00 2001
|
From f999fcbeb2274c750728808a0dbd7b8653e73d0a Mon Sep 17 00:00:00 2001
|
||||||
From: David Malcolm <dmalcolm@redhat.com>
|
From: David Malcolm <dmalcolm@redhat.com>
|
||||||
Date: Wed, 13 Jan 2010 21:25:18 +0000
|
Date: Wed, 13 Jan 2010 21:25:18 +0000
|
||||||
Subject: [PATCH] 00001: Fixup distutils/unixccompiler.py to remove standard
|
Subject: [PATCH] 00001: Fixup distutils/unixccompiler.py to remove standard
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From 331d11692ff564f152157bffbcaaf97e4c2676d2 Mon Sep 17 00:00:00 2001
|
From 81904771db8b112c8617a111e989b68e55af7a9c Mon Sep 17 00:00:00 2001
|
||||||
From: David Malcolm <dmalcolm@redhat.com>
|
From: David Malcolm <dmalcolm@redhat.com>
|
||||||
Date: Wed, 13 Jan 2010 21:25:18 +0000
|
Date: Wed, 13 Jan 2010 21:25:18 +0000
|
||||||
Subject: [PATCH] 00102: Change the various install paths to use /usr/lib64/
|
Subject: [PATCH] 00102: Change the various install paths to use /usr/lib64/
|
||||||
@ -107,7 +107,7 @@ index a065ab0b5d..22d53fa562 100644
|
|||||||
return sitepackages
|
return sitepackages
|
||||||
|
|
||||||
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
|
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
|
||||||
index e76e6927cb..0cfbea54b9 100644
|
index b9e2fafbc0..0ae6d35b69 100644
|
||||||
--- a/Lib/sysconfig.py
|
--- a/Lib/sysconfig.py
|
||||||
+++ b/Lib/sysconfig.py
|
+++ b/Lib/sysconfig.py
|
||||||
@@ -20,10 +20,10 @@ __all__ = [
|
@@ -20,10 +20,10 @@ __all__ = [
|
||||||
@ -154,7 +154,7 @@ index 41c4229919..543c88432a 100644
|
|||||||
'site-packages')
|
'site-packages')
|
||||||
self.assertEqual(dirs[0], wanted)
|
self.assertEqual(dirs[0], wanted)
|
||||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||||
index 6a9f4b5270..61d650882f 100644
|
index 502317aa0c..4ad3df1122 100644
|
||||||
--- a/Makefile.pre.in
|
--- a/Makefile.pre.in
|
||||||
+++ b/Makefile.pre.in
|
+++ b/Makefile.pre.in
|
||||||
@@ -143,7 +143,7 @@ LIBDIR= @libdir@
|
@@ -143,7 +143,7 @@ LIBDIR= @libdir@
|
||||||
@ -167,10 +167,10 @@ index 6a9f4b5270..61d650882f 100644
|
|||||||
|
|
||||||
# Detailed destination directories
|
# Detailed destination directories
|
||||||
diff --git a/Modules/getpath.c b/Modules/getpath.c
|
diff --git a/Modules/getpath.c b/Modules/getpath.c
|
||||||
index 5f80738188..73d7913441 100644
|
index b727f66953..a0c5fb6139 100644
|
||||||
--- a/Modules/getpath.c
|
--- a/Modules/getpath.c
|
||||||
+++ b/Modules/getpath.c
|
+++ b/Modules/getpath.c
|
||||||
@@ -689,7 +689,7 @@ calculate_exec_prefix(const PyConfig *config,
|
@@ -730,7 +730,7 @@ calculate_exec_prefix(PyCalculatePath *calculate, _PyPathConfig *pathconfig,
|
||||||
if (safe_wcscpy(exec_prefix, calculate->exec_prefix, exec_prefix_len) < 0) {
|
if (safe_wcscpy(exec_prefix, calculate->exec_prefix, exec_prefix_len) < 0) {
|
||||||
return PATHLEN_ERR();
|
return PATHLEN_ERR();
|
||||||
}
|
}
|
||||||
@ -179,17 +179,17 @@ index 5f80738188..73d7913441 100644
|
|||||||
if (_PyStatus_EXCEPTION(status)) {
|
if (_PyStatus_EXCEPTION(status)) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -1016,7 +1016,7 @@ calculate_zip_path(PyCalculatePath *calculate, const wchar_t *prefix)
|
@@ -1067,7 +1067,7 @@ calculate_zip_path(PyCalculatePath *calculate, const wchar_t *prefix,
|
||||||
return PATHLEN_ERR();
|
return PATHLEN_ERR();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
- status = joinpath(calculate->zip_path, L"lib/python00.zip", zip_path_len);
|
- status = joinpath(zip_path, L"lib/python00.zip", zip_path_len);
|
||||||
+ status = joinpath(calculate->zip_path, L"lib64/python00.zip", zip_path_len);
|
+ status = joinpath(zip_path, L"lib64/python00.zip", zip_path_len);
|
||||||
if (_PyStatus_EXCEPTION(status)) {
|
if (_PyStatus_EXCEPTION(status)) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -1145,7 +1145,7 @@ calculate_init(PyCalculatePath *calculate,
|
@@ -1197,7 +1197,7 @@ calculate_init(PyCalculatePath *calculate, const PyConfig *config)
|
||||||
if (!calculate->prefix) {
|
if (!calculate->exec_prefix) {
|
||||||
return DECODE_LOCALE_ERR("EXEC_PREFIX define", len);
|
return DECODE_LOCALE_ERR("EXEC_PREFIX define", len);
|
||||||
}
|
}
|
||||||
- calculate->lib_python = Py_DecodeLocale("lib/python" VERSION, &len);
|
- calculate->lib_python = Py_DecodeLocale("lib/python" VERSION, &len);
|
||||||
@ -198,10 +198,10 @@ index 5f80738188..73d7913441 100644
|
|||||||
return DECODE_LOCALE_ERR("EXEC_PREFIX define", len);
|
return DECODE_LOCALE_ERR("EXEC_PREFIX define", len);
|
||||||
}
|
}
|
||||||
diff --git a/configure b/configure
|
diff --git a/configure b/configure
|
||||||
index 3cd9b8866c..7d4cbab2c0 100755
|
index 2a933cdbeb..bec365124e 100755
|
||||||
--- a/configure
|
--- a/configure
|
||||||
+++ b/configure
|
+++ b/configure
|
||||||
@@ -15197,9 +15197,9 @@ fi
|
@@ -15182,9 +15182,9 @@ fi
|
||||||
|
|
||||||
|
|
||||||
if test x$PLATFORM_TRIPLET = x; then
|
if test x$PLATFORM_TRIPLET = x; then
|
||||||
@ -214,10 +214,10 @@ index 3cd9b8866c..7d4cbab2c0 100755
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/configure.ac b/configure.ac
|
diff --git a/configure.ac b/configure.ac
|
||||||
index 033a93cd3f..5c8a04f61e 100644
|
index a189d42c2c..154a0aa5cc 100644
|
||||||
--- a/configure.ac
|
--- a/configure.ac
|
||||||
+++ b/configure.ac
|
+++ b/configure.ac
|
||||||
@@ -4665,9 +4665,9 @@ fi
|
@@ -4668,9 +4668,9 @@ fi
|
||||||
dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
|
dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
|
||||||
AC_SUBST(PY_ENABLE_SHARED)
|
AC_SUBST(PY_ENABLE_SHARED)
|
||||||
if test x$PLATFORM_TRIPLET = x; then
|
if test x$PLATFORM_TRIPLET = x; then
|
||||||
@ -230,10 +230,10 @@ index 033a93cd3f..5c8a04f61e 100644
|
|||||||
AC_SUBST(LIBPL)
|
AC_SUBST(LIBPL)
|
||||||
|
|
||||||
diff --git a/setup.py b/setup.py
|
diff --git a/setup.py b/setup.py
|
||||||
index be2ac0b01d..624274a75b 100644
|
index 20d7f35652..024a1035c0 100644
|
||||||
--- a/setup.py
|
--- a/setup.py
|
||||||
+++ b/setup.py
|
+++ b/setup.py
|
||||||
@@ -648,7 +648,7 @@ class PyBuildExt(build_ext):
|
@@ -649,7 +649,7 @@ class PyBuildExt(build_ext):
|
||||||
# directories (i.e. '.' and 'Include') must be first. See issue
|
# directories (i.e. '.' and 'Include') must be first. See issue
|
||||||
# 10520.
|
# 10520.
|
||||||
if not CROSS_COMPILING:
|
if not CROSS_COMPILING:
|
||||||
@ -242,7 +242,7 @@ index be2ac0b01d..624274a75b 100644
|
|||||||
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
||||||
# only change this for cross builds for 3.3, issues on Mageia
|
# only change this for cross builds for 3.3, issues on Mageia
|
||||||
if CROSS_COMPILING:
|
if CROSS_COMPILING:
|
||||||
@@ -946,11 +946,11 @@ class PyBuildExt(build_ext):
|
@@ -953,11 +953,11 @@ class PyBuildExt(build_ext):
|
||||||
elif curses_library:
|
elif curses_library:
|
||||||
readline_libs.append(curses_library)
|
readline_libs.append(curses_library)
|
||||||
elif self.compiler.find_library_file(self.lib_dirs +
|
elif self.compiler.find_library_file(self.lib_dirs +
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From 9b7b6251f0fa17d6ab9eff945b3fe43cce549f13 Mon Sep 17 00:00:00 2001
|
From 5b9fcc86532051bea5d0e9fa856b014f229f4794 Mon Sep 17 00:00:00 2001
|
||||||
From: David Malcolm <dmalcolm@redhat.com>
|
From: David Malcolm <dmalcolm@redhat.com>
|
||||||
Date: Mon, 18 Jan 2010 17:59:07 +0000
|
Date: Mon, 18 Jan 2010 17:59:07 +0000
|
||||||
Subject: [PATCH] 00111: Don't try to build a libpythonMAJOR.MINOR.a
|
Subject: [PATCH] 00111: Don't try to build a libpythonMAJOR.MINOR.a
|
||||||
@ -21,10 +21,10 @@ Co-authored-by: Miro Hrončok <miro@hroncok.cz>
|
|||||||
1 file changed, 2 insertions(+), 19 deletions(-)
|
1 file changed, 2 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||||
index 61d650882f..3f5be819c4 100644
|
index 4ad3df1122..72d202d71b 100644
|
||||||
--- a/Makefile.pre.in
|
--- a/Makefile.pre.in
|
||||||
+++ b/Makefile.pre.in
|
+++ b/Makefile.pre.in
|
||||||
@@ -561,7 +561,7 @@ clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
|
@@ -562,7 +562,7 @@ clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
|
||||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
|
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
|
||||||
|
|
||||||
# Build the interpreter
|
# Build the interpreter
|
||||||
@ -33,7 +33,7 @@ index 61d650882f..3f5be819c4 100644
|
|||||||
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
|
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
|
||||||
|
|
||||||
platform: $(BUILDPYTHON) pybuilddir.txt
|
platform: $(BUILDPYTHON) pybuilddir.txt
|
||||||
@@ -609,12 +609,6 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
|
@@ -610,12 +610,6 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
|
||||||
_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
|
_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
|
||||||
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
|
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ index 61d650882f..3f5be819c4 100644
|
|||||||
libpython$(LDVERSION).so: $(LIBRARY_OBJS) $(DTRACE_OBJS)
|
libpython$(LDVERSION).so: $(LIBRARY_OBJS) $(DTRACE_OBJS)
|
||||||
if test $(INSTSONAME) != $(LDLIBRARY); then \
|
if test $(INSTSONAME) != $(LDLIBRARY); then \
|
||||||
$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \
|
$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \
|
||||||
@@ -692,7 +686,7 @@ Makefile Modules/config.c: Makefile.pre \
|
@@ -693,7 +687,7 @@ Makefile Modules/config.c: Makefile.pre \
|
||||||
@echo "The Makefile was updated, you may need to re-run make."
|
@echo "The Makefile was updated, you may need to re-run make."
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ index 61d650882f..3f5be819c4 100644
|
|||||||
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
|
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
@@ -1552,17 +1546,6 @@ libainstall: @DEF_MAKE_RULE@ python-config
|
@@ -1557,17 +1551,6 @@ libainstall: @DEF_MAKE_RULE@ python-config
|
||||||
else true; \
|
else true; \
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From b377643b13abe774c95350c4b2534eb7aa001de4 Mon Sep 17 00:00:00 2001
|
From 6d3c9e128d693f5f211f94d2977ee990b3cfb69d Mon Sep 17 00:00:00 2001
|
||||||
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||||
Date: Wed, 15 Aug 2018 15:36:29 +0200
|
Date: Wed, 15 Aug 2018 15:36:29 +0200
|
||||||
Subject: [PATCH] 00189: Instead of bundled wheels, use our RPM packaged wheels
|
Subject: [PATCH] 00189: Instead of bundled wheels, use our RPM packaged wheels
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From b610ba33332054763d46a43af205e3b9e6724bac Mon Sep 17 00:00:00 2001
|
From 910f38d9768d39d4d31426743ae4081ed1ab66b6 Mon Sep 17 00:00:00 2001
|
||||||
From: Michal Cyprian <m.cyprian@gmail.com>
|
From: Michal Cyprian <m.cyprian@gmail.com>
|
||||||
Date: Mon, 26 Jun 2017 16:32:56 +0200
|
Date: Mon, 26 Jun 2017 16:32:56 +0200
|
||||||
Subject: [PATCH] 00251: Change user install location
|
Subject: [PATCH] 00251: Change user install location
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From c79add9be412d3e42e3b623e04e7071dfadf75d1 Mon Sep 17 00:00:00 2001
|
From 02443c3177bd15ddc48e7c3fc1dd2b6a3c095888 Mon Sep 17 00:00:00 2001
|
||||||
From: Petr Viktorin <pviktori@redhat.com>
|
From: Petr Viktorin <pviktori@redhat.com>
|
||||||
Date: Mon, 28 Aug 2017 17:16:46 +0200
|
Date: Mon, 28 Aug 2017 17:16:46 +0200
|
||||||
Subject: [PATCH] 00274: Upstream uses Debian-style architecture naming, change
|
Subject: [PATCH] 00274: Upstream uses Debian-style architecture naming, change
|
||||||
@ -29,7 +29,7 @@ index ba37cf99e2..52a9ec6662 100755
|
|||||||
ppc64le | powerpc64little)
|
ppc64le | powerpc64little)
|
||||||
basic_machine=powerpc64le-unknown
|
basic_machine=powerpc64le-unknown
|
||||||
diff --git a/configure.ac b/configure.ac
|
diff --git a/configure.ac b/configure.ac
|
||||||
index 5c8a04f61e..807e379537 100644
|
index 154a0aa5cc..273954f461 100644
|
||||||
--- a/configure.ac
|
--- a/configure.ac
|
||||||
+++ b/configure.ac
|
+++ b/configure.ac
|
||||||
@@ -741,9 +741,9 @@ cat >> conftest.c <<EOF
|
@@ -741,9 +741,9 @@ cat >> conftest.c <<EOF
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From 616cc366d97f4402cc50e0338954d1c82b843027 Mon Sep 17 00:00:00 2001
|
From 62c2cdc7a459328e8792f9a029c74f12c4a0abf0 Mon Sep 17 00:00:00 2001
|
||||||
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||||
Date: Thu, 11 Jul 2019 13:44:13 +0200
|
Date: Thu, 11 Jul 2019 13:44:13 +0200
|
||||||
Subject: [PATCH] 00328: Restore pyc to TIMESTAMP invalidation mode as default
|
Subject: [PATCH] 00328: Restore pyc to TIMESTAMP invalidation mode as default
|
||||||
|
@ -1,246 +0,0 @@
|
|||||||
From 091ae930cd8bac805a083ea68e4f886200f57de0 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Miss Islington (bot)"
|
|
||||||
<31488909+miss-islington@users.noreply.github.com>
|
|
||||||
Date: Fri, 30 Aug 2019 05:50:44 -0700
|
|
||||||
Subject: [PATCH] 00331: Fix StructUnionType_paramfunc()
|
|
||||||
|
|
||||||
Fix a ctypes regression of Python 3.8. When a ctypes.Structure is
|
|
||||||
passed by copy to a function, ctypes internals created a temporary
|
|
||||||
object which had the side effect of calling the structure finalizer
|
|
||||||
(__del__) twice. The Python semantics requires a finalizer to be
|
|
||||||
called exactly once. Fix ctypes internals to no longer call the
|
|
||||||
finalizer twice.
|
|
||||||
|
|
||||||
Create a new internal StructParam_Type which is only used by
|
|
||||||
_ctypes_callproc() to call PyMem_Free(ptr) on Py_DECREF(argument).
|
|
||||||
StructUnionType_paramfunc() creates such object.
|
|
||||||
(cherry picked from commit 96b4087ce784ee7434dffdf69c475f5b40543982)
|
|
||||||
|
|
||||||
Co-authored-by: Victor Stinner <vstinner@redhat.com>
|
|
||||||
---
|
|
||||||
Lib/ctypes/test/test_structures.py | 51 +++++++++++--
|
|
||||||
.../2019-08-30-11-21-10.bpo-37140.cFAX-a.rst | 5 ++
|
|
||||||
Modules/_ctypes/_ctypes.c | 73 +++++++++++++++----
|
|
||||||
3 files changed, 109 insertions(+), 20 deletions(-)
|
|
||||||
create mode 100644 Misc/NEWS.d/next/Library/2019-08-30-11-21-10.bpo-37140.cFAX-a.rst
|
|
||||||
|
|
||||||
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
|
|
||||||
index d1ea43bc7e..fda104563d 100644
|
|
||||||
--- a/Lib/ctypes/test/test_structures.py
|
|
||||||
+++ b/Lib/ctypes/test/test_structures.py
|
|
||||||
@@ -3,7 +3,7 @@ from ctypes import *
|
|
||||||
from ctypes.test import need_symbol
|
|
||||||
from struct import calcsize
|
|
||||||
import _ctypes_test
|
|
||||||
-import test.support
|
|
||||||
+from test import support
|
|
||||||
|
|
||||||
class SubclassesTest(unittest.TestCase):
|
|
||||||
def test_subclass(self):
|
|
||||||
@@ -202,7 +202,7 @@ class StructureTestCase(unittest.TestCase):
|
|
||||||
"_pack_": -1}
|
|
||||||
self.assertRaises(ValueError, type(Structure), "X", (Structure,), d)
|
|
||||||
|
|
||||||
- @test.support.cpython_only
|
|
||||||
+ @support.cpython_only
|
|
||||||
def test_packed_c_limits(self):
|
|
||||||
# Issue 15989
|
|
||||||
import _testcapi
|
|
||||||
@@ -396,27 +396,66 @@ class StructureTestCase(unittest.TestCase):
|
|
||||||
self.assertRaises(TypeError, lambda: Z(1, 2, 3, 4, 5, 6, 7))
|
|
||||||
|
|
||||||
def test_pass_by_value(self):
|
|
||||||
- # This should mirror the structure in Modules/_ctypes/_ctypes_test.c
|
|
||||||
- class X(Structure):
|
|
||||||
+ # This should mirror the Test structure
|
|
||||||
+ # in Modules/_ctypes/_ctypes_test.c
|
|
||||||
+ class Test(Structure):
|
|
||||||
_fields_ = [
|
|
||||||
('first', c_ulong),
|
|
||||||
('second', c_ulong),
|
|
||||||
('third', c_ulong),
|
|
||||||
]
|
|
||||||
|
|
||||||
- s = X()
|
|
||||||
+ s = Test()
|
|
||||||
s.first = 0xdeadbeef
|
|
||||||
s.second = 0xcafebabe
|
|
||||||
s.third = 0x0bad1dea
|
|
||||||
dll = CDLL(_ctypes_test.__file__)
|
|
||||||
func = dll._testfunc_large_struct_update_value
|
|
||||||
- func.argtypes = (X,)
|
|
||||||
+ func.argtypes = (Test,)
|
|
||||||
func.restype = None
|
|
||||||
func(s)
|
|
||||||
self.assertEqual(s.first, 0xdeadbeef)
|
|
||||||
self.assertEqual(s.second, 0xcafebabe)
|
|
||||||
self.assertEqual(s.third, 0x0bad1dea)
|
|
||||||
|
|
||||||
+ def test_pass_by_value_finalizer(self):
|
|
||||||
+ # bpo-37140: Similar to test_pass_by_value(), but the Python structure
|
|
||||||
+ # has a finalizer (__del__() method): the finalizer must only be called
|
|
||||||
+ # once.
|
|
||||||
+
|
|
||||||
+ finalizer_calls = []
|
|
||||||
+
|
|
||||||
+ class Test(Structure):
|
|
||||||
+ _fields_ = [
|
|
||||||
+ ('first', c_ulong),
|
|
||||||
+ ('second', c_ulong),
|
|
||||||
+ ('third', c_ulong),
|
|
||||||
+ ]
|
|
||||||
+ def __del__(self):
|
|
||||||
+ finalizer_calls.append("called")
|
|
||||||
+
|
|
||||||
+ s = Test(1, 2, 3)
|
|
||||||
+ # Test the StructUnionType_paramfunc() code path which copies the
|
|
||||||
+ # structure: if the stucture is larger than sizeof(void*).
|
|
||||||
+ self.assertGreater(sizeof(s), sizeof(c_void_p))
|
|
||||||
+
|
|
||||||
+ dll = CDLL(_ctypes_test.__file__)
|
|
||||||
+ func = dll._testfunc_large_struct_update_value
|
|
||||||
+ func.argtypes = (Test,)
|
|
||||||
+ func.restype = None
|
|
||||||
+ func(s)
|
|
||||||
+ # bpo-37140: Passing the structure by refrence must not call
|
|
||||||
+ # its finalizer!
|
|
||||||
+ self.assertEqual(finalizer_calls, [])
|
|
||||||
+ self.assertEqual(s.first, 1)
|
|
||||||
+ self.assertEqual(s.second, 2)
|
|
||||||
+ self.assertEqual(s.third, 3)
|
|
||||||
+
|
|
||||||
+ # The finalizer must be called exactly once
|
|
||||||
+ s = None
|
|
||||||
+ support.gc_collect()
|
|
||||||
+ self.assertEqual(finalizer_calls, ["called"])
|
|
||||||
+
|
|
||||||
def test_pass_by_value_in_register(self):
|
|
||||||
class X(Structure):
|
|
||||||
_fields_ = [
|
|
||||||
diff --git a/Misc/NEWS.d/next/Library/2019-08-30-11-21-10.bpo-37140.cFAX-a.rst b/Misc/NEWS.d/next/Library/2019-08-30-11-21-10.bpo-37140.cFAX-a.rst
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..4eaa226147
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/Misc/NEWS.d/next/Library/2019-08-30-11-21-10.bpo-37140.cFAX-a.rst
|
|
||||||
@@ -0,0 +1,5 @@
|
|
||||||
+Fix a ctypes regression of Python 3.8. When a ctypes.Structure is passed by
|
|
||||||
+copy to a function, ctypes internals created a temporary object which had
|
|
||||||
+the side effect of calling the structure finalizer (__del__) twice. The
|
|
||||||
+Python semantics requires a finalizer to be called exactly once. Fix ctypes
|
|
||||||
+internals to no longer call the finalizer twice.
|
|
||||||
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
|
|
||||||
index 2201c4520a..4728874006 100644
|
|
||||||
--- a/Modules/_ctypes/_ctypes.c
|
|
||||||
+++ b/Modules/_ctypes/_ctypes.c
|
|
||||||
@@ -392,6 +392,35 @@ _ctypes_alloc_format_string_with_shape(int ndim, const Py_ssize_t *shape,
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
+/* StructParamObject and StructParam_Type are used in _ctypes_callproc()
|
|
||||||
+ for argument.keep to call PyMem_Free(ptr) on Py_DECREF(argument).
|
|
||||||
+
|
|
||||||
+ StructUnionType_paramfunc() creates such object when a ctypes Structure is
|
|
||||||
+ passed by copy to a C function. */
|
|
||||||
+typedef struct {
|
|
||||||
+ PyObject_HEAD
|
|
||||||
+ void *ptr;
|
|
||||||
+} StructParamObject;
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static void
|
|
||||||
+StructParam_dealloc(PyObject *myself)
|
|
||||||
+{
|
|
||||||
+ StructParamObject *self = (StructParamObject *)myself;
|
|
||||||
+ PyMem_Free(self->ptr);
|
|
||||||
+ Py_TYPE(self)->tp_free(myself);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static PyTypeObject StructParam_Type = {
|
|
||||||
+ PyVarObject_HEAD_INIT(NULL, 0)
|
|
||||||
+ .tp_name = "_ctypes.StructParam_Type",
|
|
||||||
+ .tp_basicsize = sizeof(StructParamObject),
|
|
||||||
+ .tp_dealloc = StructParam_dealloc,
|
|
||||||
+ .tp_flags = Py_TPFLAGS_DEFAULT,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+
|
|
||||||
/*
|
|
||||||
PyCStructType_Type - a meta type/class. Creating a new class using this one as
|
|
||||||
__metaclass__ will call the constructor StructUnionType_new. It replaces the
|
|
||||||
@@ -403,35 +432,47 @@ static PyCArgObject *
|
|
||||||
StructUnionType_paramfunc(CDataObject *self)
|
|
||||||
{
|
|
||||||
PyCArgObject *parg;
|
|
||||||
- CDataObject *copied_self;
|
|
||||||
+ PyObject *obj;
|
|
||||||
StgDictObject *stgdict;
|
|
||||||
+ void *ptr;
|
|
||||||
|
|
||||||
if ((size_t)self->b_size > sizeof(void*)) {
|
|
||||||
- void *new_ptr = PyMem_Malloc(self->b_size);
|
|
||||||
- if (new_ptr == NULL)
|
|
||||||
+ ptr = PyMem_Malloc(self->b_size);
|
|
||||||
+ if (ptr == NULL) {
|
|
||||||
return NULL;
|
|
||||||
- memcpy(new_ptr, self->b_ptr, self->b_size);
|
|
||||||
- copied_self = (CDataObject *)PyCData_AtAddress(
|
|
||||||
- (PyObject *)Py_TYPE(self), new_ptr);
|
|
||||||
- copied_self->b_needsfree = 1;
|
|
||||||
+ }
|
|
||||||
+ memcpy(ptr, self->b_ptr, self->b_size);
|
|
||||||
+
|
|
||||||
+ /* Create a Python object which calls PyMem_Free(ptr) in
|
|
||||||
+ its deallocator. The object will be destroyed
|
|
||||||
+ at _ctypes_callproc() cleanup. */
|
|
||||||
+ obj = (&StructParam_Type)->tp_alloc(&StructParam_Type, 0);
|
|
||||||
+ if (obj == NULL) {
|
|
||||||
+ PyMem_Free(ptr);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ StructParamObject *struct_param = (StructParamObject *)obj;
|
|
||||||
+ struct_param->ptr = ptr;
|
|
||||||
} else {
|
|
||||||
- copied_self = self;
|
|
||||||
- Py_INCREF(copied_self);
|
|
||||||
+ ptr = self->b_ptr;
|
|
||||||
+ obj = (PyObject *)self;
|
|
||||||
+ Py_INCREF(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
parg = PyCArgObject_new();
|
|
||||||
if (parg == NULL) {
|
|
||||||
- Py_DECREF(copied_self);
|
|
||||||
+ Py_DECREF(obj);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
parg->tag = 'V';
|
|
||||||
- stgdict = PyObject_stgdict((PyObject *)copied_self);
|
|
||||||
+ stgdict = PyObject_stgdict((PyObject *)self);
|
|
||||||
assert(stgdict); /* Cannot be NULL for structure/union instances */
|
|
||||||
parg->pffi_type = &stgdict->ffi_type_pointer;
|
|
||||||
- parg->value.p = copied_self->b_ptr;
|
|
||||||
- parg->size = copied_self->b_size;
|
|
||||||
- parg->obj = (PyObject *)copied_self;
|
|
||||||
+ parg->value.p = ptr;
|
|
||||||
+ parg->size = self->b_size;
|
|
||||||
+ parg->obj = obj;
|
|
||||||
return parg;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -5700,6 +5741,10 @@ PyInit__ctypes(void)
|
|
||||||
if (PyType_Ready(&DictRemover_Type) < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
+ if (PyType_Ready(&StructParam_Type) < 0) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
#ifdef MS_WIN32
|
|
||||||
if (create_comerror() < 0)
|
|
||||||
return NULL;
|
|
||||||
--
|
|
||||||
2.21.0
|
|
||||||
|
|
@ -14,7 +14,7 @@ URL: https://www.python.org/
|
|||||||
# WARNING When rebasing to a new Python version,
|
# WARNING When rebasing to a new Python version,
|
||||||
# remember to update the python3-docs package as well
|
# remember to update the python3-docs package as well
|
||||||
%global general_version %{pybasever}.0
|
%global general_version %{pybasever}.0
|
||||||
%global prerel b4
|
%global prerel rc1
|
||||||
%global upstream_version %{general_version}%{?prerel}
|
%global upstream_version %{general_version}%{?prerel}
|
||||||
Version: %{general_version}%{?prerel:~%{prerel}}
|
Version: %{general_version}%{?prerel:~%{prerel}}
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
@ -261,13 +261,6 @@ Patch274: 00274-fix-arch-names.patch
|
|||||||
# See https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/57#comment-27426
|
# See https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/57#comment-27426
|
||||||
Patch328: 00328-pyc-timestamp-invalidation-mode.patch
|
Patch328: 00328-pyc-timestamp-invalidation-mode.patch
|
||||||
|
|
||||||
# 00331 #
|
|
||||||
# Fix StructUnionType_paramfunc()
|
|
||||||
# Fix a ctypes regression of Python 3.8
|
|
||||||
# Merged upstream https://bugs.python.org/issue37140
|
|
||||||
# Fixes clang FTBFS https://bugzilla.redhat.com/show_bug.cgi?id=1715016
|
|
||||||
Patch331: 00331-fix-structuniontype_paramfunc.patch
|
|
||||||
|
|
||||||
# (New patches go here ^^^)
|
# (New patches go here ^^^)
|
||||||
#
|
#
|
||||||
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
|
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
|
||||||
@ -604,7 +597,6 @@ rm Lib/ensurepip/_bundled/*.whl
|
|||||||
%patch251 -p1
|
%patch251 -p1
|
||||||
%patch274 -p1
|
%patch274 -p1
|
||||||
%patch328 -p1
|
%patch328 -p1
|
||||||
%patch331 -p1
|
|
||||||
|
|
||||||
|
|
||||||
# Remove files that should be generated by the build
|
# Remove files that should be generated by the build
|
||||||
@ -1527,6 +1519,9 @@ CheckPython optimized
|
|||||||
# ======================================================
|
# ======================================================
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Oct 01 2019 Miro Hrončok <mhroncok@redhat.com> - 3.8.0~rc1-1
|
||||||
|
- Rebased to Python 3.8.0rc1
|
||||||
|
|
||||||
* Sat Aug 31 2019 Miro Hrončok <mhroncok@redhat.com> - 3.8.0~b4-1
|
* Sat Aug 31 2019 Miro Hrončok <mhroncok@redhat.com> - 3.8.0~b4-1
|
||||||
- Rebased to Python 3.8.0b4
|
- Rebased to Python 3.8.0b4
|
||||||
- Enable Profile-guided optimization for all arches, not just x86 (#1741015)
|
- Enable Profile-guided optimization for all arches, not just x86 (#1741015)
|
||||||
|
2
sources
2
sources
@ -1 +1 @@
|
|||||||
SHA512 (Python-3.8.0b4.tar.xz) = 91cf7a6988a52edbffa544f4154219864c09f0726b617c79078fe6d00f4c85255cf302a087f80a0a1697ef6d7c9547c20fe9d8901ce8d6ef553e3b36bf87dbde
|
SHA512 (Python-3.8.0rc1.tar.xz) = 9a4055c210e65157265aee262eefb776dece59290b04935beb08354825bfe7049f51bb8ba545d85c369df6e853003455965a6435129f4c4660b2786f26d4c66e
|
||||||
|
Loading…
Reference in New Issue
Block a user