We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 89f05a7 commit fd2ebb1Copy full SHA for fd2ebb1
Modules/_io/bufferedio.c
@@ -1786,7 +1786,7 @@ static void
1786
_bufferedwriter_set_append(buffered *self)
1787
{
1788
PyObject *mode = _PyObject_GetAttrId(self->raw, &PyId_mode);
1789
- if (mode != NULL) {
+ if (mode != NULL && PyUnicode_Check(mode)) {
1790
if (PyUnicode_FindChar(mode, 'a', 0,
1791
PyUnicode_GET_LENGTH(mode), 1) != -1) {
1792
self->appending = 1;
@@ -1797,6 +1797,9 @@ _bufferedwriter_set_append(buffered *self)
1797
Py_DECREF(mode);
1798
}
1799
else {
1800
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
1801
+ PyErr_Clear();
1802
+ }
1803
/* Raw fileobj has no mode string so as far as we can know it has
1804
normal write behavior */
1805
self->appending = 0;
0 commit comments