diff options
author | Géry Ogam <gery.ogam@gmail.com> | 2022-01-18 20:46:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 20:46:26 (GMT) |
commit | 16bf9bd157c7bf5f9c60414fa8e0fe5047c55a9b (patch) | |
tree | b292c0e5249522ef373b9c0b93acb09430706864 /Python | |
parent | 60ceedbdd5b5fb22803039a59954798d931f659a (diff) | |
download | cpython-16bf9bd157c7bf5f9c60414fa8e0fe5047c55a9b.zip cpython-16bf9bd157c7bf5f9c60414fa8e0fe5047c55a9b.tar.gz cpython-16bf9bd157c7bf5f9c60414fa8e0fe5047c55a9b.tar.bz2 |
bpo-44024: Improve the TypeError message in getattr and hasattr (GH-25863)
Use common error message for non-string attribute name in the builtin
functions getattr and hasattr.
The special check no longer needed since Python 3.0.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 10 |
1 files changed, 0 insertions, 10 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 6763f99..ef1b2bb 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1091,11 +1091,6 @@ builtin_getattr(PyObject *self, PyObject *const *args, Py_ssize_t nargs) v = args[0]; name = args[1]; - if (!PyUnicode_Check(name)) { - PyErr_SetString(PyExc_TypeError, - "getattr(): attribute name must be string"); - return NULL; - } if (nargs > 2) { if (_PyObject_LookupAttr(v, name, &result) == 0) { PyObject *dflt = args[2]; @@ -1156,11 +1151,6 @@ builtin_hasattr_impl(PyObject *module, PyObject *obj, PyObject *name) { PyObject *v; - if (!PyUnicode_Check(name)) { - PyErr_SetString(PyExc_TypeError, - "hasattr(): attribute name must be string"); - return NULL; - } if (_PyObject_LookupAttr(obj, name, &v) < 0) { return NULL; } |