Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix PyInterpreterState_GetID().
  • Loading branch information
ericsnowcurrently committed May 22, 2017
commit d8150d40e346d151e4217c15f9c541089d1cf84a
4 changes: 2 additions & 2 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -821,10 +821,10 @@ been created.
:c:func:`PyThreadState_Clear`.


.. c:function:: unsigned long PyInterpreterState_GetID(PyInterpreterState *interp)
.. c:function:: int_fast64_t PyInterpreterState_GetID(PyInterpreterState *interp)

Return the interpreter's unique ID. If there was any error in doing
so then 0 is returned and an error is set.
so then -1 is returned and an error is set.

.. versionadded:: 3.7

Expand Down
2 changes: 1 addition & 1 deletion Include/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ PyAPI_FUNC(void) _PyInterpreterState_Init(void);
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
PyAPI_FUNC(unsigned long) PyInterpreterState_GetID(PyInterpreterState *);
PyAPI_FUNC(int_fast64_t) PyInterpreterState_GetID(PyInterpreterState *);
#ifndef Py_LIMITED_API
PyAPI_FUNC(int) _PyState_AddModule(PyObject*, struct PyModuleDef*);
#endif /* !Py_LIMITED_API */
Expand Down
2 changes: 1 addition & 1 deletion Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void print_subinterp(void)
/* Output information about the interpreter in the format
expected in Lib/test/test_capi.py (test_subinterps). */
PyThreadState *ts = PyThreadState_Get();
unsigned long id = PyInterpreterState_GetID(ts->interp);
int_fast64_t id = PyInterpreterState_GetID(ts->interp);
printf("interp %lu <%p>, thread state <%p>: ",
id, ts->interp, ts);
fflush(stdout);
Expand Down
4 changes: 2 additions & 2 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ PyInterpreterState_Delete(PyInterpreterState *interp)
}


unsigned long
int_fast64_t
PyInterpreterState_GetID(PyInterpreterState *interp)
{
if (interp == NULL) {
PyErr_SetString(PyExc_RuntimeError, "no interpreter provided");
return 0;
return -1;
}
return interp->id;
}
Expand Down