summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Include/cpython/dictobject.h1
-rw-r--r--Include/internal/pycore_dict.h1
-rw-r--r--Modules/_testcapi/code.c9
-rw-r--r--Objects/structseq.c1
-rw-r--r--Python/codecs.c1
-rw-r--r--Python/import.c3
-rw-r--r--Python/initconfig.c1
-rw-r--r--Python/pythonrun.c1
8 files changed, 12 insertions, 6 deletions
diff --git a/Include/cpython/dictobject.h b/Include/cpython/dictobject.h
index 2a42794..470f594 100644
--- a/Include/cpython/dictobject.h
+++ b/Include/cpython/dictobject.h
@@ -36,7 +36,6 @@ PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
Py_hash_t hash);
PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
_Py_Identifier *key);
-PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *);
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
PyObject *mp, PyObject *key, PyObject *defaultobj);
PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key,
diff --git a/Include/internal/pycore_dict.h b/Include/internal/pycore_dict.h
index df7bc7e..8e9c27e 100644
--- a/Include/internal/pycore_dict.h
+++ b/Include/internal/pycore_dict.h
@@ -13,6 +13,7 @@ extern "C" {
// Unsafe flavor of PyDict_GetItemWithError(): no error checking
extern PyObject* _PyDict_GetItemWithError(PyObject *dp, PyObject *key);
+extern PyObject* _PyDict_GetItemStringWithError(PyObject *, const char *);
extern int _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
diff --git a/Modules/_testcapi/code.c b/Modules/_testcapi/code.c
index cadaf5e..691dd5f 100644
--- a/Modules/_testcapi/code.c
+++ b/Modules/_testcapi/code.c
@@ -9,12 +9,12 @@ get_code_extra_index(PyInterpreterState* interp) {
PyObject *interp_dict = PyInterpreterState_GetDict(interp); // borrowed
assert(interp_dict); // real users would handle missing dict... somehow
- PyObject *index_obj = _PyDict_GetItemStringWithError(interp_dict, key); // borrowed
+ PyObject *index_obj;
+ if (PyDict_GetItemStringRef(interp_dict, key, &index_obj) < 0) {
+ goto finally;
+ }
Py_ssize_t index = 0;
if (!index_obj) {
- if (PyErr_Occurred()) {
- goto finally;
- }
index = PyUnstable_Eval_RequestCodeExtraIndex(NULL);
if (index < 0 || PyErr_Occurred()) {
goto finally;
@@ -31,6 +31,7 @@ get_code_extra_index(PyInterpreterState* interp) {
}
else {
index = PyLong_AsSsize_t(index_obj);
+ Py_DECREF(index_obj);
if (index == -1 && PyErr_Occurred()) {
goto finally;
}
diff --git a/Objects/structseq.c b/Objects/structseq.c
index 700f67c..95c4c15 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -8,6 +8,7 @@
*/
#include "Python.h"
+#include "pycore_dict.h" // _PyDict_GetItemStringWithError()
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "pycore_object.h" // _PyObject_GC_TRACK()
diff --git a/Python/codecs.c b/Python/codecs.c
index 4e47ff9..3c41851 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -10,6 +10,7 @@ Copyright (c) Corporation for National Research Initiatives.
#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
+#include "pycore_dict.h" // _PyDict_GetItemStringWithError()
#include "pycore_interp.h" // PyInterpreterState.codec_search_path
#include "pycore_pyerrors.h" // _PyErr_FormatNote()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
diff --git a/Python/import.c b/Python/import.c
index 56b2dc1..4abb2f6 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1,7 +1,7 @@
/* Module definition and import implementation */
#include "Python.h"
-
+#include "pycore_dict.h" // _PyDict_GetItemStringWithError()
#include "pycore_hashtable.h" // _Py_hashtable_new_full()
#include "pycore_import.h" // _PyImport_BootstrapImp()
#include "pycore_initconfig.h" // _PyStatus_OK()
@@ -15,6 +15,7 @@
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_sysmodule.h" // _PySys_Audit()
#include "pycore_weakref.h" // _PyWeakref_GET_REF()
+
#include "marshal.h" // PyMarshal_ReadObjectFromString()
#include "importdl.h" // _PyImport_DynLoadFiletab
#include "pydtrace.h" // PyDTrace_IMPORT_FIND_LOAD_START_ENABLED()
diff --git a/Python/initconfig.c b/Python/initconfig.c
index 787e583..c017abe 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -1,4 +1,5 @@
#include "Python.h"
+#include "pycore_dict.h" // _PyDict_GetItemStringWithError()
#include "pycore_fileutils.h" // _Py_HasFileSystemDefaultEncodeErrors
#include "pycore_getopt.h" // _PyOS_GetOpt()
#include "pycore_initconfig.h" // _PyStatus_OK()
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index b2e04cf..a3de779 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -15,6 +15,7 @@
#include "pycore_ast.h" // PyAST_mod2obj
#include "pycore_ceval.h" // _Py_EnterRecursiveCall
#include "pycore_compile.h" // _PyAST_Compile()
+#include "pycore_dict.h" // _PyDict_GetItemStringWithError()
#include "pycore_interp.h" // PyInterpreterState.importlib
#include "pycore_object.h" // _PyDebug_PrintTotalRefs()
#include "pycore_parser.h" // _PyParser_ASTFromString()