gh-112026: Restore removed _PyDict_GetItemStringWithError() by vstinner · Pull Request #112119 · python/cpython · GitHub
Skip to content

gh-112026: Restore removed _PyDict_GetItemStringWithError() - #112119

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:restore_dict_geterror
Nov 15, 2023
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:restore_dict_geterror

Conversation

@vstinner

@vstinner vstinner commented Nov 15, 2023

Copy link
Copy Markdown
Member

Restore the removed _PyDict_GetItemStringWithError() function. It is used by numpy.

Restore the removed _PyDict_GetItemStringWithError() function. It is
used by numpy.
@vstinner

Copy link
Copy Markdown
Member Author

@vstinner
vstinner enabled auto-merge (squash) November 15, 2023 16:50
@vstinner
vstinner merged commit bd2f148 into python:main Nov 15, 2023
@vstinner
vstinner deleted the restore_dict_geterror branch November 15, 2023 17:10
@serhiy-storchaka

Copy link
Copy Markdown
Member

Is not PyDict_GetItemStringRef() the solution? It bhas different interface, but it is easy to write a wrapper.

PyObject *
_PyDict_GetItemStringWithError(PyObject *obj, const char *key)
{
    PyObject *value;
    (void)PyDict_GetItemStringRef(obj, key, &value);
    if (Py_REFCNT(value) == 1) {
        Py_DECREF(value);
        return NULL;
    }
    Py_DECREF(value);
    return value;
}

@vstinner

Copy link
Copy Markdown
Member Author

Is not PyDict_GetItemStringRef() the solution? It bhas different interface, but it is easy to write a wrapper.

Solution to which problem? numpy doesn't built if Python C API doesn't contain _PyDict_GetItemStringWithError(). I restored the function to unblock numpy.

I plan to update numpy, deprecate _PyDict_GetItemStringWithError(), and later remove it.

aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…thon#112119)

Restore the removed _PyDict_GetItemStringWithError() function. It is
used by numpy.
@ngoldbaum

Copy link
Copy Markdown
Contributor

I plan to update numpy

See numpy/numpy#26282, would also appreciate code review if you have time.

@vstinner

Copy link
Copy Markdown
Member Author

Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…thon#112119)

Restore the removed _PyDict_GetItemStringWithError() function. It is
used by numpy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants