Resolves: #1367144 - avoid double encoding with Python 3

This commit is contained in:
Kamil Dudka 2016-08-17 09:27:47 +02:00
parent e6a7d69fa1
commit c3d464c025
2 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,45 @@
From ca13da68883e74d287cfb44b596cd134a82c4b7e Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Tue, 28 Jun 2016 17:10:22 +0000
Subject: [PATCH] PR/562: Reiner Herrmann: Avoid double encoding with python3
Upstream-commit: 73e043d2a986234b187a00ed0c8d1f7bf83df372
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
python/magic.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/python/magic.py b/python/magic.py
index c48f7d5..b0f7a17 100644
--- a/python/magic.py
+++ b/python/magic.py
@@ -134,7 +134,7 @@ class Magic(object):
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 @@ class Magic(object):
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 @@ class Magic(object):
if isinstance(e, str):
return e
else:
- return str(e).encode('utf-8')
+ return str(e, 'utf-8')
def setflags(self, flags):
"""
--
2.5.5

View File

@ -5,7 +5,7 @@
Summary: A utility for determining file types
Name: file
Version: 5.28
Release: 3%{?dist}
Release: 4%{?dist}
License: BSD
Group: Applications/File
Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
@ -28,6 +28,9 @@ Patch17: file-5.24-varied.patch
# https://github.com/file/file/pull/8
Patch100: file-5.28-compress-sigsegv.patch
# avoid double encoding with Python 3 (#1367144)
Patch101: file-5.28-py3-double-enc.patch
URL: http://www.darwinsys.com/file/
Requires: file-libs = %{version}-%{release}
BuildRequires: zlib-devel
@ -101,6 +104,7 @@ file(1) command.
%patch17 -p1
%patch100 -p1
%patch101 -p1
# Patches can generate *.orig files, which can't stay in the magic dir,
# otherwise there will be problems with compiling magic file!
@ -208,6 +212,9 @@ cd %{py3dir}
%endif
%changelog
* Wed Aug 17 2016 Kamil Dudka <kdudka@redhat.com> - 5.28-4
- avoid double encoding with Python 3 (#1367144)
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.28-3
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages