summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2014-03-22 20:32:51 +0100
committerJulian Andres Klode <jak@debian.org>2014-03-22 20:32:51 +0100
commit3f931a65d810a1d74d20523b644f009fddb4105c (patch)
treeb302f1104f76dbf757ad9656f6531ec124292542 /python
parent9b4ed293fc9e903775bed8a237c4654f574b5f77 (diff)
downloadpython-apt-3f931a65d810a1d74d20523b644f009fddb4105c.tar.gz
python/tag.cc: Ignore missing 'encoding' attribute in file objects
In case the encoding attribute does not exist, Python sets an exception. We must thus clear the exception, otherwise it might be raised at some later point in the code.
Diffstat (limited to 'python')
-rw-r--r--python/tag.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/python/tag.cc b/python/tag.cc
index 9f175cc4..50786cee 100644
--- a/python/tag.cc
+++ b/python/tag.cc
@@ -474,6 +474,8 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
#if PY_MAJOR_VERSION >= 3
if (fileno != -1) {
New->Encoding = PyObject_GetAttr(File, PyUnicode_FromString("encoding"));
+ if (!New->Encoding)
+ PyErr_Clear();
if (New->Encoding && !PyUnicode_Check(New->Encoding))
New->Encoding = 0;
} else