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 e8a2d25 commit 176e4aeCopy full SHA for 176e4ae
Modules/_io/bufferedio.c
@@ -1945,7 +1945,7 @@ static void
1945
_bufferedwriter_set_append(buffered *self)
1946
{
1947
PyObject *mode = _PyObject_GetAttrId(self->raw, &PyId_mode);
1948
- if (mode != NULL) {
+ if (mode != NULL && PyUnicode_Check(mode)) {
1949
if (PyUnicode_FindChar(mode, 'a', 0,
1950
PyUnicode_GET_LENGTH(mode), 1) != -1) {
1951
self->appending = 1;
@@ -1956,6 +1956,9 @@ _bufferedwriter_set_append(buffered *self)
1956
Py_DECREF(mode);
1957
}
1958
else {
1959
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
1960
+ PyErr_Clear();
1961
+ }
1962
/* Raw fileobj has no mode string so as far as we can know it has
1963
normal write behavior */
1964
self->appending = 0;
0 commit comments