From cba8d599a2c1523078a22b75709c6a154ba83d21 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 29 Jun 2016 13:08:21 +0900 Subject: [PATCH] Bump to file 5.28 [Model] ALL [BinType] AP [Customer] OPEN [Issue#] N/A [Request] N/A [Occurrence Version] N/A [Problem] Bump to file 5.28 [Cause & Measure] Bump to file 5.28 [Checking Method] N/A [Team] Open Source Management and Setting Part [Developer] dh0128.kwak [Solution company] Samsung [Change Type] N/A Change-Id: I7dd77b07335b3544a509fb7359a0f3ce0cd9bc16 Signed-off-by: DongHun Kwak --- packaging/file.spec | 2 +- packaging/python-magic-rpmlintrc | 1 + packaging/python-magic.spec | 3 ++- python/magic.py | 17 ++++++++++++----- src/readcdf.c | 6 +++--- 5 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 packaging/python-magic-rpmlintrc diff --git a/packaging/file.spec b/packaging/file.spec index 8ddd7bc..90bca5b 100644 --- a/packaging/file.spec +++ b/packaging/file.spec @@ -5,7 +5,7 @@ BuildRequires: findutils BuildRequires: libtool BuildRequires: zlib-devel Url: http://www.darwinsys.com/file/ -Version: 5.18 +Version: 5.28 Release: 0 Summary: A Tool to Determine File Types License: BSD-2-Clause diff --git a/packaging/python-magic-rpmlintrc b/packaging/python-magic-rpmlintrc new file mode 100644 index 0000000..1b4d915 --- /dev/null +++ b/packaging/python-magic-rpmlintrc @@ -0,0 +1 @@ +addFilter("E: non-standard-group"); diff --git a/packaging/python-magic.spec b/packaging/python-magic.spec index 0f7c422..fe32d44 100644 --- a/packaging/python-magic.spec +++ b/packaging/python-magic.spec @@ -5,9 +5,10 @@ Name: python-magic BuildRequires: findutils BuildRequires: libtool BuildRequires: python-devel +BuildRequires: python-setuptools BuildRequires: zlib-devel Url: http://www.darwinsys.com/file/ -Version: 5.18 +Version: 5.28 Release: 0 Summary: Python module to use libmagic License: BSD-3-Clause and BSD-4-Clause diff --git a/python/magic.py b/python/magic.py index 3c7a1b2..c48f7d5 100644 --- a/python/magic.py +++ b/python/magic.py @@ -123,11 +123,18 @@ class Magic(object): 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 - bi = bytes(filename, 'utf-8') - return str(_file(self._magic_t, bi), 'utf-8') - except: - return _file(self._magic_t, filename) + if isinstance(filename, bytes): + bi = filename + else: + try: # keep Python 2 compatibility + bi = bytes(filename, 'utf-8') + except TypeError: + bi = bytes(filename) + r = _file(self._magic_t, bi) + if isinstance(r, str): + return r + else: + return str(r).encode('utf-8') def descriptor(self, fd): """ diff --git a/src/readcdf.c b/src/readcdf.c index 9883045..f62dad4 100644 --- a/src/readcdf.c +++ b/src/readcdf.c @@ -26,7 +26,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: readcdf.c,v 1.42 2014/05/07 10:13:12 christos Exp $") +FILE_RCSID("@(#)$File: readcdf.c,v 1.56 2016/03/03 22:20:03 christos Exp $") #endif #include @@ -80,7 +80,7 @@ static const struct cv { const char *mime; } clsid2mime[] = { { - { 0x00000000000c1084LLU, 0x46000000000000c0LLU }, + { 0x00000000000c1084ULL, 0x46000000000000c0ULL }, "x-msi", }, { { 0, 0 }, @@ -88,7 +88,7 @@ static const struct cv { }, }, clsid2desc[] = { { - { 0x00000000000c1084LLU, 0x46000000000000c0LLU }, + { 0x00000000000c1084ULL, 0x46000000000000c0ULL }, "MSI Installer", }, { { 0, 0 }, -- 2.7.4