Skip to content

Missing static inline on PyObject_GenericHash #204

Closed

Description

@mattip

#195 added PyObject_GenericHash, but did not define it static inline. So if more than one compilation unit uses the header, the gcc 14 linker sees more than one definition for the function and complains.

diff --git a/pythoncapi_compat.h b/pythoncapi_compat.h
index e307119..c6fe172 100644
--- a/pythoncapi_compat.h
+++ b/pythoncapi_compat.h
@@ -1236,7 +1236,7 @@ static inline Py_hash_t Py_HashPointer(const void *ptr)
 
 
 #if PY_VERSION_HEX < _Py_PACK_VERSION(3, 13) || defined(Py_LIMITED_API)
-Py_hash_t
+static inline Py_hash_t
 PyObject_GenericHash(PyObject *obj)
 {
     return Py_HashPointer(obj);

Activity

  1. vstinner commented on Oct 16, 2026

    @vstinner
    Member

    Oops, thanks, I applied your patch: #205.

    It's not the first time that I make this mistake (forget static inline), so I wrote #206 test to detect it in the CI.

  2. mattip commented on Oct 16, 2026

    @mattip
    ContributorAuthor

    Thanks for the quick fix

  3. vstinner commented on Oct 16, 2026

    @vstinner
    Member

    Ok, with commit b8fe76f, the CI should catch such mistake if it occurs again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions