- python 3 string and file compatibility fixes
This commit is contained in:
parent
944d93e504
commit
7bc2daa0cc
59
rpm-4.11.1-py3-fixes.patch
Normal file
59
rpm-4.11.1-py3-fixes.patch
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
commit 62bdcc0a32d07a7423876b3ae17900da04eb8a97
|
||||||
|
Author: Jan Silhan <jsilhan@redhat.com>
|
||||||
|
Date: Fri Oct 18 18:30:52 2013 +0200
|
||||||
|
|
||||||
|
Python 3 compatibility fixes
|
||||||
|
|
||||||
|
- Use open() instead of calling file constructor
|
||||||
|
- Borrow python-six trick of dealing with difference in string types
|
||||||
|
|
||||||
|
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
|
||||||
|
|
||||||
|
diff --git a/python/rpm/transaction.py b/python/rpm/transaction.py
|
||||||
|
index 756e893..df72ce9 100644
|
||||||
|
--- a/python/rpm/transaction.py
|
||||||
|
+++ b/python/rpm/transaction.py
|
||||||
|
@@ -1,8 +1,14 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
+import sys
|
||||||
|
import rpm
|
||||||
|
from rpm._rpm import ts as TransactionSetCore
|
||||||
|
|
||||||
|
+if sys.version_info[0] == 3:
|
||||||
|
+ _string_types = str,
|
||||||
|
+else:
|
||||||
|
+ _string_types = basestring,
|
||||||
|
+
|
||||||
|
# TODO: migrate relevant documentation from C-side
|
||||||
|
class TransactionSet(TransactionSetCore):
|
||||||
|
_probFilter = 0
|
||||||
|
@@ -45,14 +51,14 @@ class TransactionSet(TransactionSetCore):
|
||||||
|
return tuple(keys)
|
||||||
|
|
||||||
|
def addInstall(self, item, key, how="u"):
|
||||||
|
- if isinstance(item, basestring):
|
||||||
|
- f = file(item)
|
||||||
|
+ if isinstance(item, _string_types):
|
||||||
|
+ f = open(item)
|
||||||
|
header = self.hdrFromFdno(f)
|
||||||
|
f.close()
|
||||||
|
- elif isinstance(item, file):
|
||||||
|
- header = self.hdrFromFdno(item)
|
||||||
|
- else:
|
||||||
|
+ elif isinstance(item, rpm.hdr):
|
||||||
|
header = item
|
||||||
|
+ else:
|
||||||
|
+ header = self.hdrFromFdno(item)
|
||||||
|
|
||||||
|
if not how in ['u', 'i']:
|
||||||
|
raise ValueError('how argument must be "u" or "i"')
|
||||||
|
@@ -69,7 +75,7 @@ class TransactionSet(TransactionSetCore):
|
||||||
|
hdrs = item
|
||||||
|
elif isinstance(item, int):
|
||||||
|
hdrs = self.dbMatch(rpm.RPMDBI_PACKAGES, item)
|
||||||
|
- elif isinstance(item, basestring):
|
||||||
|
+ elif isinstance(item, _string_types):
|
||||||
|
hdrs = self.dbMatch(rpm.RPMDBI_LABEL, item)
|
||||||
|
else:
|
||||||
|
raise TypeError("invalid type %s" % type(item))
|
7
rpm.spec
7
rpm.spec
@ -21,7 +21,7 @@
|
|||||||
Summary: The RPM package management system
|
Summary: The RPM package management system
|
||||||
Name: rpm
|
Name: rpm
|
||||||
Version: %{rpmver}
|
Version: %{rpmver}
|
||||||
Release: %{?snapver:0.%{snapver}.}9%{?dist}
|
Release: %{?snapver:0.%{snapver}.}10%{?dist}
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
Url: http://www.rpm.org/
|
Url: http://www.rpm.org/
|
||||||
Source0: http://rpm.org/releases/rpm-4.11.x/%{name}-%{srcver}.tar.bz2
|
Source0: http://rpm.org/releases/rpm-4.11.x/%{name}-%{srcver}.tar.bz2
|
||||||
@ -55,6 +55,7 @@ Patch104: rpm-4.11.1-caps-double-free.patch
|
|||||||
Patch105: rpm-4.11.1-empty-lua-script.patch
|
Patch105: rpm-4.11.1-empty-lua-script.patch
|
||||||
Patch106: rpm-4.11.1-ppc64le.patch
|
Patch106: rpm-4.11.1-ppc64le.patch
|
||||||
Patch107: rpm-4.11.1-application-provides.patch
|
Patch107: rpm-4.11.1-application-provides.patch
|
||||||
|
Patch108: rpm-4.11.1-py3-fixes.patch
|
||||||
|
|
||||||
# These are not yet upstream
|
# These are not yet upstream
|
||||||
Patch301: rpm-4.6.0-niagara.patch
|
Patch301: rpm-4.6.0-niagara.patch
|
||||||
@ -261,6 +262,7 @@ packages on a system.
|
|||||||
%patch105 -p1 -b .empty-lua-script
|
%patch105 -p1 -b .empty-lua-script
|
||||||
%patch106 -p1 -b .ppc64le
|
%patch106 -p1 -b .ppc64le
|
||||||
%patch107 -p1 -b .application-provides
|
%patch107 -p1 -b .application-provides
|
||||||
|
%patch108 -p1 -b .py3-fixes
|
||||||
|
|
||||||
%patch301 -p1 -b .niagara
|
%patch301 -p1 -b .niagara
|
||||||
%patch302 -p1 -b .geode
|
%patch302 -p1 -b .geode
|
||||||
@ -517,6 +519,9 @@ exit 0
|
|||||||
%doc COPYING doc/librpm/html/*
|
%doc COPYING doc/librpm/html/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Nov 18 2013 Panu Matilainen <pmatilai@redhat.com> - 4.11.1-10
|
||||||
|
- python 3 string and file compatibility fixes
|
||||||
|
|
||||||
* Mon Oct 14 2013 Panu Matilainen <pmatilai@redhat.com> - 4.11.1-9
|
* Mon Oct 14 2013 Panu Matilainen <pmatilai@redhat.com> - 4.11.1-9
|
||||||
- generate application() provides for gnome-software
|
- generate application() provides for gnome-software
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user