From 3f931a65d810a1d74d20523b644f009fddb4105c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 22 Mar 2014 20:32:51 +0100 Subject: 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. --- python/tag.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'python/tag.cc') 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 -- cgit v1.2.3