#2 Fix python3 bytes and str compatibility
Merged 5 years ago by kevin. Opened 5 years ago by wsato.
rpms/ wsato/python-cpio python3_bytes_str  into  f29

@@ -0,0 +1,20 @@ 

+ --- python-cpio-0.1/cpioarchive.py	2018-11-12 17:32:04.568654580 +0100

+ +++ cpioarchive.py	2018-11-12 17:33:03.378570874 +0100

+ @@ -26,7 +26,7 @@

+      """Create a new CpioEntry instance. Internal use only."""

+      if len(hdr)<110:

+        raise CpioError('cpio header too short')

+ -    if not hdr.startswith('070701'):

+ +    if not hdr.startswith(b'070701'):

+        raise CpioError('cpio header invalid')

+      self.inode=int(hdr[6:14], 16)

+      self.mode=int(hdr[14:22], 16)

+ @@ -44,7 +44,7 @@

+      self.checksum=int(hdr[102:110], 16)

+      if len(hdr)<110+namesize:

+        raise CpioError('cpio header too short')

+ -    self.name=hdr[110:110+namesize-1]

+ +    self.name=hdr[110:110+namesize-1].decode("utf-8")

+      """Name of the file stored in the entry."""

+      self.datastart=offset+110+namesize

+      self.datastart+=(4-(self.datastart%4))%4

file modified
+7 -2
@@ -1,12 +1,13 @@ 

  Name:           python-cpio

  Version:        0.1

- Release:        29%{?dist}

+ Release:        30%{?dist}

  Summary:        A Python module for accessing cpio archives

  

  License:        LGPLv2+

  URL:            http://developer.berlios.de/projects/python-cpio/

  Source0:        http://download.berlios.de/python-cpio/python-cpio-0.1.tar.bz2

- Patch0:        	cpioarchive_supports_2_3.patch

+ Patch0:         cpioarchive_supports_2_3.patch

+ Patch1:         cpioarchive_bytes_str_compatibility.patch

  

  BuildArch:      noarch

  BuildRequires:  python2-devel
@@ -31,6 +32,7 @@ 

  %prep

  %setup -q

  %patch0

+ %patch1

  

  %build

  %py2_build
@@ -55,6 +57,9 @@ 

  

  

  %changelog

+ * Tue Nov 13 2018 Watson Yuuma Sato <wsato@redhat.com> - 0.1-30

+ - Fix python3 compatibility - bytes and str

+ 

  * Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.1-29

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

  

Compare the header to a bytes object and store entry name as a string.

This should fix https://bugzilla.redhat.com/show_bug.cgi?id=1240325.

Pull-Request has been merged by kevin

5 years ago