Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Make PyUnstable_Unicode_GET_CACHED_HASH return -1 on PyPy#157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 2 commits intopython:mainfromencukou:uncached-hash-minus-one
Oct 15, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletiondocs/api.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,7 +68,7 @@ Python 3.15

See `PyUnstable_Unicode_GET_CACHED_HASH() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnstable_Unicode_GET_CACHED_HASH>`__.

Not available on PyPy.
On PyPy, always returns ``-1``.


Python 3.14
Expand Down
7 changes: 5 additions & 2 deletionspythoncapi_compat.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2572,11 +2572,14 @@ PyTuple_FromArray(PyObject *const *array, Py_ssize_t size)
#endif


#if PY_VERSION_HEX < 0x030F00A1 && !defined(PYPY_VERSION)
#if PY_VERSION_HEX < 0x030F00A1
static inline Py_hash_t
PyUnstable_Unicode_GET_CACHED_HASH(PyObject *op)
{
#if PY_VERSION_HEX >= 0x03000000
#ifdef PYPY_VERSION
(void)op; // unused argument
return -1;
#elif PY_VERSION_HEX >= 0x03000000
return ((PyASCIIObject*)op)->hash;
#else
return ((PyUnicodeObject*)op)->hash;
Expand Down
4 changes: 3 additions & 1 deletiontests/test_pythoncapi_compat_cext.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1611,8 +1611,10 @@ test_unicode(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
assert(PyErr_ExceptionMatches(PyExc_TypeError));
PyErr_Clear();

#ifndefPYPY_VERSION
// Test PyUnstable_Unicode_GET_CACHED_HASH()
#ifdefPYPY_VERSION
assert(PyUnstable_Unicode_GET_CACHED_HASH(abc)==-1);
#else
Py_hash_thash=PyObject_Hash(abc);
assert(hash!=-1);
assert(PyUnstable_Unicode_GET_CACHED_HASH(abc)==hash);
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp