Skip to content

Commit 33a38b3

Browse files
committed
Use common TypeError message for built-in functions getattr and hasattr
1 parent bb3e0c2 commit 33a38b3

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

Python/bltinmodule.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,11 +1099,6 @@ builtin_getattr(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
10991099

11001100
v = args[0];
11011101
name = args[1];
1102-
if (!PyUnicode_Check(name)) {
1103-
PyErr_SetString(PyExc_TypeError,
1104-
"getattr(): attribute name must be string");
1105-
return NULL;
1106-
}
11071102
if (nargs > 2) {
11081103
if (_PyObject_LookupAttr(v, name, &result) == 0) {
11091104
PyObject *dflt = args[2];
@@ -1164,11 +1159,6 @@ builtin_hasattr_impl(PyObject *module, PyObject *obj, PyObject *name)
11641159
{
11651160
PyObject *v;
11661161

1167-
if (!PyUnicode_Check(name)) {
1168-
PyErr_SetString(PyExc_TypeError,
1169-
"hasattr(): attribute name must be string");
1170-
return NULL;
1171-
}
11721162
if (_PyObject_LookupAttr(obj, name, &v) < 0) {
11731163
return NULL;
11741164
}

0 commit comments

Comments
 (0)