Package: python3-magic Version: 1:5.28-1 Hi,
since python3-magic 1:5.28-1 the file type detection is broken. Instead of returning a string whih contains the magic, it returns double encoded bytes: >>> import magic >>> path = "/usr/share/doc/gdb/refcard.ps.gz" >>> x = magic.open(magic.NONE) >>> x.load() 0 >>> x.file(path) b"b'gzip compressed data, max compression, from Unix'" (Instead of just 'gzip compressed data, max compression, from Unix' like before.) The problem seems to be those lines: > r = _file(self._magic_t, bi) > ... > return str(r).encode('utf-8') r is already of type bytes, converting it to string results in the string "b'gzip compressed data, max compression, from Unix'", which is then encoded to utf-8: b"b'gzip compressed data, max compression, from Unix'" Converting it with str(r, 'utf-8') seems to be the correct way and has the same result as before. Kind regards, Reiner
diff --git a/debian/patches/fix_string_encoding.patch b/debian/patches/fix_string_encoding.patch new file mode 100644 index 0000000..7600a47 --- /dev/null +++ b/debian/patches/fix_string_encoding.patch @@ -0,0 +1,29 @@ +--- a/python/magic.py ++++ b/python/magic.py +@@ -134,7 +134,7 @@ + if isinstance(r, str): + return r + else: +- return str(r).encode('utf-8') ++ return str(r, 'utf-8') + + def descriptor(self, fd): + """ +@@ -152,7 +152,7 @@ + if isinstance(r, str): + return r + else: +- return str(r).encode('utf-8') ++ return str(r, 'utf-8') + + def error(self): + """ +@@ -163,7 +163,7 @@ + if isinstance(e, str): + return e + else: +- return str(e).encode('utf-8') ++ return str(e, 'utf-8') + + def setflags(self, flags): + """ diff --git a/debian/patches/series b/debian/patches/series index 23199ea..1cb450f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -7,3 +7,4 @@ local.mention-posixly-correct-dependent-behaviour-in-usage-message.patch local.report-gz-as-application-gzip.patch local.disable-detection-of-vax-coff-executables.patch local.avoid-line-break-warning-from-man.patch +fix_string_encoding.patch
signature.asc
Description: Digital signature