Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 1 | From 66d9b2ba3fbc7b04f2b5ad9d0e5371340c037b5f Mon Sep 17 00:00:00 2001 |
| 2 | From: Marek Blaha <mblaha@redhat.com> |
| 3 | Date: Wed, 10 Jul 2019 10:11:01 +0200 |
| 4 | Subject: [oe-core][PATCH 1/1] Fix Python 3.8 deprecation warning |
| 5 | (RhBug:1724244) |
| 6 | |
| 7 | This deprecation warning was introduced in Python 3.8 by |
| 8 | https://bugs.python.org/issue36381: |
| 9 | |
| 10 | /usr/lib/python3.8/site-packages/dnf/package.py:57: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats |
| 11 | return super(Package, self).chksum |
| 12 | |
| 13 | https://bugzilla.redhat.com/show_bug.cgi?id=1724244 |
| 14 | --- |
| 15 | python/hawkey/package-py.cpp | 3 ++- |
| 16 | python/hawkey/packagedelta-py.cpp | 3 ++- |
| 17 | 2 files changed, 4 insertions(+), 2 deletions(-) |
| 18 | --- |
| 19 | |
| 20 | Unchanged. Appears in version 0.35.2. |
| 21 | |
| 22 | Upstream-Status: Backport [git://github.com/rpm-software-management/libdnf.git] |
| 23 | |
| 24 | Signed-off-by: Joe Slater <joe.slater@windriver.com> |
| 25 | |
| 26 | |
| 27 | diff --git a/python/hawkey/package-py.cpp b/python/hawkey/package-py.cpp |
| 28 | index 5102bba..68e03cb 100644 |
| 29 | --- a/python/hawkey/package-py.cpp |
| 30 | +++ b/python/hawkey/package-py.cpp |
| 31 | @@ -18,6 +18,7 @@ |
| 32 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 33 | */ |
| 34 | |
| 35 | +#define PY_SSIZE_T_CLEAN |
| 36 | #include <Python.h> |
| 37 | #include <stdio.h> |
| 38 | |
| 39 | @@ -251,7 +252,7 @@ get_chksum(_PackageObject *self, void *closure) |
| 40 | #if PY_MAJOR_VERSION < 3 |
| 41 | res = Py_BuildValue("is#", type, cs, checksum_length); |
| 42 | #else |
| 43 | - res = Py_BuildValue("iy#", type, cs, checksum_length); |
| 44 | + res = Py_BuildValue("iy#", type, cs, (Py_ssize_t)checksum_length); |
| 45 | #endif |
| 46 | |
| 47 | return res; |
| 48 | diff --git a/python/hawkey/packagedelta-py.cpp b/python/hawkey/packagedelta-py.cpp |
| 49 | index ca1cb7d..1a64836 100644 |
| 50 | --- a/python/hawkey/packagedelta-py.cpp |
| 51 | +++ b/python/hawkey/packagedelta-py.cpp |
| 52 | @@ -18,6 +18,7 @@ |
| 53 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 54 | */ |
| 55 | |
| 56 | +#define PY_SSIZE_T_CLEAN |
| 57 | #include <Python.h> |
| 58 | |
| 59 | // hawkey |
| 60 | @@ -92,7 +93,7 @@ get_chksum(_PackageDeltaObject *self, void *closure) |
| 61 | #if PY_MAJOR_VERSION < 3 |
| 62 | res = Py_BuildValue("is#", type, cs, checksum_length); |
| 63 | #else |
| 64 | - res = Py_BuildValue("iy#", type, cs, checksum_length); |
| 65 | + res = Py_BuildValue("iy#", type, cs, (Py_ssize_t)checksum_length); |
| 66 | #endif |
| 67 | |
| 68 | return res; |
| 69 | -- |
| 70 | 2.7.4 |
| 71 | |