Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bd2f148

Browse filesBrowse files
authored
gh-112026: Restore removed _PyDict_GetItemStringWithError() (#112119)
Restore the removed _PyDict_GetItemStringWithError() function. It is used by numpy.
1 parent ec05507 commit bd2f148
Copy full SHA for bd2f148

File tree

Expand file treeCollapse file tree

3 files changed

+17
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+17
-1
lines changed

‎Include/cpython/dictobject.h

Copy file name to clipboardExpand all lines: Include/cpython/dictobject.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef struct {
3434

3535
PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
3636
Py_hash_t hash);
37-
37+
PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *);
3838
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
3939
PyObject *mp, PyObject *key, PyObject *defaultobj);
4040

+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Restore the removed ``_PyDict_GetItemStringWithError()`` function. It is
2+
used by numpy. Patch by Victor Stinner.

‎Objects/dictobject.c

Copy file name to clipboardExpand all lines: Objects/dictobject.c
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,20 @@ _PyDict_GetItemIdWithError(PyObject *dp, _Py_Identifier *key)
18421842
return _PyDict_GetItem_KnownHash(dp, kv, hash); // borrowed reference
18431843
}
18441844

1845+
PyObject *
1846+
_PyDict_GetItemStringWithError(PyObject *v, const char *key)
1847+
{
1848+
PyObject *kv, *rv;
1849+
kv = PyUnicode_FromString(key);
1850+
if (kv == NULL) {
1851+
return NULL;
1852+
}
1853+
rv = PyDict_GetItemWithError(v, kv);
1854+
Py_DECREF(kv);
1855+
return rv;
1856+
}
1857+
1858+
18451859
/* Fast version of global value lookup (LOAD_GLOBAL).
18461860
* Lookup in globals, then builtins.
18471861
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.