Skip to content

Commit 4e715b0

Browse files
Update function
1 parent f7c3c45 commit 4e715b0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Objects/unicodeobject.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13090,8 +13090,7 @@ unicode_maketrans_from_dict(PyObject *x, PyObject *newdict)
1309013090
PyObject *key, *value;
1309113091
Py_ssize_t i = 0;
1309213092
int res;
13093-
int ret = -1; /* assume failure */
13094-
13093+
int ret = -1;
1309513094
Py_BEGIN_CRITICAL_SECTION(x);
1309613095
while (PyDict_Next(x, &i, &key, &value)) {
1309713096
if (PyUnicode_Check(key)) {
@@ -13101,30 +13100,31 @@ unicode_maketrans_from_dict(PyObject *x, PyObject *newdict)
1310113100
if (PyUnicode_GET_LENGTH(key) != 1) {
1310213101
PyErr_SetString(PyExc_ValueError, "string keys in translate"
1310313102
"table must be of length 1");
13104-
goto done;
13103+
break;
1310513104
}
1310613105
kind = PyUnicode_KIND(key);
1310713106
data = PyUnicode_DATA(key);
1310813107
newkey = PyLong_FromLong(PyUnicode_READ(kind, data, 0));
1310913108
if (!newkey)
13110-
goto done;
13109+
break;
1311113110
res = PyDict_SetItem(newdict, newkey, value);
1311213111
Py_DECREF(newkey);
1311313112
if (res < 0)
13114-
goto done;
13113+
break;
1311513114
}
1311613115
else if (PyLong_Check(key)) {
1311713116
if (PyDict_SetItem(newdict, key, value) < 0)
13118-
goto done;
13117+
break;
1311913118
}
1312013119
else {
1312113120
PyErr_SetString(PyExc_TypeError, "keys in translate table must"
1312213121
"be strings or integers");
13123-
goto done;
13122+
break;
1312413123
}
1312513124
}
13126-
ret = 0;
13127-
done:
13125+
if (!PyErr_Occurred()) {
13126+
ret = 0;
13127+
}
1312813128
Py_END_CRITICAL_SECTION();
1312913129
return ret;
1313013130
}

0 commit comments

Comments
 (0)