#439 srpm_import: be compatible with rhbz#1693751
Merged by onosek. Opened by praiskup.
praiskup/rpkg compat-for-rhbz-1693751  into  master

Download 439.patch
    srpm_import: be compatible with rhbz#1693751
    Older RPMs returned 'bytes' objects, newer return 'str'.
    If 'str' object is returned on Python 3 - it doesn't need to be
    decoded, and it actually raises error [1]:
        >>> str('', encoding='utf-8')
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        TypeError: decoding str is not supported
    This change also OK for Python 2 where str() has decode method
    (str is alternative for bytes).
    [1] https://pagure.io/copr/copr/issue/677
    Signed-off-by: Pavel Raiskup <praiskup@redhat.com>

rebased onto c8e458adf8ea450734c4a650a74bbd4f2e0600b9

rebased onto 3f4ed25c5ef5fb9c05c3b420114889c37bdf6bbb

rebased onto 3d9523be1ae64a84ce849fa199b3c1e01b3d805b

Looks good to me.

With this change, rpkg has 3 ways to handle the conversion from bytes to str at least:

  • checking if object has method decode
  • if six.PY3
  • if isinstance(s, six.text_type)

It would be good to refactor all of them into one function to make the conversion and reuse it in future. This could be done in another separate patch.

Looks OK, thanks.

Pull-Request has been merged by onosek

Metadata