summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-12-17 14:43:14 (GMT)
committerGitHub <noreply@github.com>2018-12-17 14:43:14 (GMT)
commite2af34fcf84b41189b54e1f2912faded5daabaca (patch)
tree14ddbfbc1b3ba0cac52df2889140f81adf98758c /Objects
parentfae95874b729dfe62a7a40625f8717aed20b0fca (diff)
downloadcpython-e2af34fcf84b41189b54e1f2912faded5daabaca.zip
cpython-e2af34fcf84b41189b54e1f2912faded5daabaca.tar.gz
cpython-e2af34fcf84b41189b54e1f2912faded5daabaca.tar.bz2
bpo-35504: Fix a SystemError when delete the characters_written attribute of an OSError. (GH-11172)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 05578d4..002a602 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -1196,6 +1196,14 @@ OSError_written_get(PyOSErrorObject *self, void *context)
static int
OSError_written_set(PyOSErrorObject *self, PyObject *arg, void *context)
{
+ if (arg == NULL) {
+ if (self->written == -1) {
+ PyErr_SetString(PyExc_AttributeError, "characters_written");
+ return -1;
+ }
+ self->written = -1;
+ return 0;
+ }
Py_ssize_t n;
n = PyNumber_AsSsize_t(arg, PyExc_ValueError);
if (n == -1 && PyErr_Occurred())