Accepting request 355237 from Base:System
- add file-5.25-avoid-double-evaluation-in-python-bindings.dif (bsc#949905) - add file-5.25-avoid-double-evaluation-in-python-bindings.dif (bsc#949905) OBS-URL: https://build.opensuse.org/request/show/355237 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/file?expand=0&rev=92
This commit is contained in:
commit
6ce615f4b9
68
file-5.25-avoid-double-evaluation-in-python-bindings.dif
Normal file
68
file-5.25-avoid-double-evaluation-in-python-bindings.dif
Normal file
@ -0,0 +1,68 @@
|
||||
From f0adf3e6811aafde00dba8ba236609869a973769 Mon Sep 17 00:00:00 2001
|
||||
From: Christos Zoulas <christos@zoulas.com>
|
||||
Date: Thu, 29 Oct 2015 19:23:42 +0000
|
||||
Subject: [PATCH] PR/489: Avoid evaluating things twice.
|
||||
|
||||
---
|
||||
python/magic.py | 35 +++++++++++++++++++----------------
|
||||
1 file changed, 19 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/python/magic.py b/python/magic.py
|
||||
index a17e8da..2c1c012 100644
|
||||
--- a/python/magic.py
|
||||
+++ b/python/magic.py
|
||||
@@ -118,14 +118,15 @@ def file(self, filename):
|
||||
as a filename or None if an error occurred and the MAGIC_ERROR flag
|
||||
is set. A call to errno() will return the numeric error code.
|
||||
"""
|
||||
- try: # attempt python3 approach first
|
||||
- if isinstance(filename, bytes):
|
||||
- bi = filename
|
||||
- else:
|
||||
- bi = bytes(filename, 'utf-8')
|
||||
- return str(_file(self._magic_t, bi), 'utf-8')
|
||||
- except:
|
||||
- return _file(self._magic_t, filename.encode('utf-8'))
|
||||
+ if isinstance(filename, bytes):
|
||||
+ bi = filename
|
||||
+ else:
|
||||
+ bi = bytes(filename, 'utf-8')
|
||||
+ r = _file(self._magic_t, bi)
|
||||
+ if isinstance(r, str):
|
||||
+ return r
|
||||
+ else:
|
||||
+ return str(r, 'utf-8')
|
||||
|
||||
def descriptor(self, fd):
|
||||
"""
|
||||
@@ -139,20 +140,22 @@ def buffer(self, buf):
|
||||
as a buffer or None if an error occurred and the MAGIC_ERROR flag
|
||||
is set. A call to errno() will return the numeric error code.
|
||||
"""
|
||||
- try: # attempt python3 approach first
|
||||
- return str(_buffer(self._magic_t, buf, len(buf)), 'utf-8')
|
||||
- except:
|
||||
- return _buffer(self._magic_t, buf, len(buf))
|
||||
+ r = _buffer(self._magic_t, buf, len(buf))
|
||||
+ if isinstance(r, str):
|
||||
+ return r
|
||||
+ else:
|
||||
+ return str(r, 'utf-8')
|
||||
|
||||
def error(self):
|
||||
"""
|
||||
Returns a textual explanation of the last error or None
|
||||
if there was no error.
|
||||
"""
|
||||
- try: # attempt python3 approach first
|
||||
- return str(_error(self._magic_t), 'utf-8')
|
||||
- except:
|
||||
- return _error(self._magic_t)
|
||||
+ e = _error(self._magic_t)
|
||||
+ if isinstance(e, str):
|
||||
+ return e
|
||||
+ else:
|
||||
+ return str(e, 'utf-8')
|
||||
|
||||
def setflags(self, flags):
|
||||
"""
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Jan 21 11:32:14 UTC 2016 - dmueller@suse.com
|
||||
|
||||
- add file-5.25-avoid-double-evaluation-in-python-bindings.dif (bsc#949905)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Oct 4 15:55:51 UTC 2015 - astieger@suse.com
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package file
|
||||
#
|
||||
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -62,6 +62,7 @@ Patch34: file-5.23-endian.patch
|
||||
Patch35: file-5.24-nitpick.dif
|
||||
Patch36: file-5.15-clear-invalid.patch
|
||||
Patch37: file-secure_getenv.patch
|
||||
Patch38: file-5.25-avoid-double-evaluation-in-python-bindings.dif
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
%global _sysconfdir /etc
|
||||
%global _miscdir %{_datadir}/misc
|
||||
@ -127,6 +128,7 @@ to develop applications that require the magic "file" interface.
|
||||
%patch35 -p0 -b .nitpick
|
||||
%patch36 -p1 -b .clear
|
||||
%patch37 -p1 -b .getenv
|
||||
%patch38 -p1 -b .pythondouble
|
||||
%patch -b .0
|
||||
test -s src/magic.h.in || cp -p src/magic.h src/magic.h.in
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Jan 21 11:32:14 UTC 2016 - dmueller@suse.com
|
||||
|
||||
- add file-5.25-avoid-double-evaluation-in-python-bindings.dif (bsc#949905)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Oct 4 15:55:51 UTC 2015 - astieger@suse.com
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-magic
|
||||
#
|
||||
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
|
Loading…
Reference in New Issue
Block a user