Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96849d1

Browse files
committed
Address compiler warnings
1 parent 420ece6 commit 96849d1

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Include/internal/pycore_pythread.h

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ typedef unsigned long long PyThread_ident_t;
110110
typedef Py_uintptr_t PyThread_handle_t;
111111

112112
#define PY_FORMAT_THREAD_IDENT_T "llu"
113+
#define Py_PARSE_THREAD_IDENT_T "K"
113114

114115
PyAPI_FUNC(PyThread_ident_t) PyThread_get_thread_ident_ex(void);
115116

Modules/_threadmodule.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ ThreadHandle_dealloc(ThreadHandleObject *self)
7979
static PyObject *
8080
ThreadHandle_repr(ThreadHandleObject *self)
8181
{
82-
return PyUnicode_FromFormat("<%s object: ident=" PY_FORMAT_THREAD_IDENT_T ">",
82+
return PyUnicode_FromFormat("<%s object: ident=%" PY_FORMAT_THREAD_IDENT_T ">",
8383
Py_TYPE(self)->tp_name, self->ident);
8484
}
8585

@@ -529,11 +529,12 @@ to be available for other threads.");
529529
static PyObject *
530530
rlock_acquire_restore(rlockobject *self, PyObject *args)
531531
{
532-
unsigned long owner;
532+
PyThread_ident_t owner;
533533
unsigned long count;
534534
int r = 1;
535535

536-
if (!PyArg_ParseTuple(args, "(kk):_acquire_restore", &count, &owner))
536+
if (!PyArg_ParseTuple(args, "(k" Py_PARSE_THREAD_IDENT_T "):_acquire_restore",
537+
&count, &owner))
537538
return NULL;
538539

539540
if (!PyThread_acquire_lock(self->rlock_lock, 0)) {
@@ -559,7 +560,7 @@ For internal use by `threading.Condition`.");
559560
static PyObject *
560561
rlock_release_save(rlockobject *self, PyObject *Py_UNUSED(ignored))
561562
{
562-
unsigned long owner;
563+
PyThread_ident_t owner;
563564
unsigned long count;
564565

565566
if (self->rlock_count == 0) {
@@ -573,7 +574,7 @@ rlock_release_save(rlockobject *self, PyObject *Py_UNUSED(ignored))
573574
self->rlock_count = 0;
574575
self->rlock_owner = 0;
575576
PyThread_release_lock(self->rlock_lock);
576-
return Py_BuildValue("kk", count, owner);
577+
return Py_BuildValue("k" Py_PARSE_THREAD_IDENT_T, count, owner);
577578
}
578579

579580
PyDoc_STRVAR(rlock_release_save_doc,
@@ -633,7 +634,8 @@ rlock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
633634
static PyObject *
634635
rlock_repr(rlockobject *self)
635636
{
636-
return PyUnicode_FromFormat("<%s %s object owner=%ld count=%lu at %p>",
637+
return PyUnicode_FromFormat(
638+
"<%s %s object owner=%" PY_FORMAT_THREAD_IDENT_T " count=%lu at %p>",
637639
self->rlock_count ? "locked" : "unlocked",
638640
Py_TYPE(self)->tp_name, self->rlock_owner,
639641
self->rlock_count, self);

0 commit comments

Comments
 (0)