summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2021-04-14 01:36:07 (GMT)
committerGitHub <noreply@github.com>2021-04-14 01:36:07 (GMT)
commit37494b441aced0362d7edd2956ab3ea7801e60c8 (patch)
tree45d9355cde5f7c71924e8df0f16ea2e0ad63eea8 /Include
parent3bc694d5f3d4eb2e5d2f0b83e498b19662845d4e (diff)
downloadcpython-37494b441aced0362d7edd2956ab3ea7801e60c8.zip
cpython-37494b441aced0362d7edd2956ab3ea7801e60c8.tar.gz
cpython-37494b441aced0362d7edd2956ab3ea7801e60c8.tar.bz2
bpo-38530: Offer suggestions on AttributeError (#16856)
When printing AttributeError, PyErr_Display will offer suggestions of similar attribute names in the object that the exception was raised from: >>> collections.namedtoplo Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'collections' has no attribute 'namedtoplo'. Did you mean: namedtuple?
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/pyerrors.h6
-rw-r--r--Include/internal/pycore_pyerrors.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/Include/cpython/pyerrors.h b/Include/cpython/pyerrors.h
index 6711e8b..a15082e 100644
--- a/Include/cpython/pyerrors.h
+++ b/Include/cpython/pyerrors.h
@@ -62,6 +62,12 @@ typedef struct {
PyObject *value;
} PyStopIterationObject;
+typedef struct {
+ PyException_HEAD
+ PyObject *obj;
+ PyObject *name;
+} PyAttributeErrorObject;
+
/* Compatibility typedefs */
typedef PyOSErrorObject PyEnvironmentErrorObject;
#ifdef MS_WINDOWS
diff --git a/Include/internal/pycore_pyerrors.h b/Include/internal/pycore_pyerrors.h
index 9dd66ae..d1af8e9 100644
--- a/Include/internal/pycore_pyerrors.h
+++ b/Include/internal/pycore_pyerrors.h
@@ -86,6 +86,8 @@ PyAPI_FUNC(int) _PyErr_CheckSignalsTstate(PyThreadState *tstate);
PyAPI_FUNC(void) _Py_DumpExtensionModules(int fd, PyInterpreterState *interp);
+extern PyObject* _Py_Offer_Suggestions(PyObject* exception);
+
#ifdef __cplusplus
}
#endif