#1432 py2.6 compatibility fix
Merged 4 years ago by mikem. Opened 4 years ago by tkopecek.
tkopecek/koji issue1431  into  master

file modified
+12 -10
@@ -765,16 +765,18 @@ 

              #at this point we know there were external repos at the create event,

              #so there should be an origins file.

              origin_idx = {}

-             with GzipFile(fileobj=fo, mode='r') as fo2:

-                 if six.PY3:

-                     fo2 = io.TextIOWrapper(fo2, encoding='utf-8')

-                 for line in fo2:

-                     parts=line.split(None, 2)

-                     if len(parts) < 2:

-                         continue

-                     #first field is formated by yum as [e:]n-v-r.a

-                     nvra = "%(name)s-%(version)s-%(release)s.%(arch)s" %  koji.parse_NVRA(parts[0])

-                     origin_idx[nvra] = parts[1]

+             # dont' use 'with GzipFile' as it is not supported on py2.6

+             fo2 = GzipFile(fileobj=fo, mode='r')

+             if six.PY3:

+                 fo2 = io.TextIOWrapper(fo2, encoding='utf-8')

+             for line in fo2:

+                 parts=line.split(None, 2)

+                 if len(parts) < 2:

+                     continue

+                 #first field is formated by yum as [e:]n-v-r.a

+                 nvra = "%(name)s-%(version)s-%(release)s.%(arch)s" %  koji.parse_NVRA(parts[0])

+                 origin_idx[nvra] = parts[1]

+             fo2.close()

          # mergerepo starts from a local repo in the task workdir, so internal

          # rpms have an odd-looking origin that we need to look for

          localtail = '/repo_%s_premerge/' % self.repo_info['id']

Python 2.6 doesn't support context manager for GzipFile. Revert to
original behaviour.

Fixes: https://pagure.io/koji/issue/1431

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

4 years ago

Commit b42eabf fixes this pull-request

Pull-Request has been merged by mikem

4 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

4 years ago