Skip to content

Commit

Permalink
Fix compiler warnings on Py_SET_REFCNT() (#3236)
Browse files Browse the repository at this point in the history
Cast `size_t` to `Py_ssize_t` to avoid compiler warnings in `Py_SET_REFCNT()`.
  • Loading branch information
vstinner authored Feb 8, 2022
1 parent 3f5ea50 commit 753197c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/core/buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ class Mmap_BufferImpl : public BufferImpl, MemoryMapWorker {
for (size_t i = 0; i < n; ++i) {
data[i] = Py_None;
}
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + n);
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + static_cast<Py_ssize_t>(n));
}
impl_->contains_pyobjects_ = true;
return *this;
Expand All @@ -955,7 +955,7 @@ class Mmap_BufferImpl : public BufferImpl, MemoryMapWorker {
if (n_new > n_old) {
PyObject** data = static_cast<PyObject**>(xptr());
for (size_t i = n_old; i < n_new; ++i) data[i] = Py_None;
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + n_new - n_old);
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + static_cast<Py_ssize_t>(n_new - n_old));
}
} else {
impl_->resize(newsize);
Expand Down Expand Up @@ -1019,7 +1019,7 @@ class Mmap_BufferImpl : public BufferImpl, MemoryMapWorker {
size_t i = 0;
for (; i < n_copy; ++i) Py_INCREF(newdata[i]);
for (; i < n_new; ++i) newdata[i] = Py_None;
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + n_new - n_copy);
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + static_cast<Py_ssize_t>(n_new - n_copy));
}
impl_->release(); // noexcept
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/column/const_na.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static Column _fw_col(size_t nrows, SType stype) {
});

if (std::is_same<T, PyObject*>::value) {
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + nrows);
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + static_cast<Py_ssize_t>(nrows));
buf.set_pyobjects(/* clear_data= */ false);
}
return Column(new ColClass(nrows, stype, std::move(buf)));
Expand All @@ -102,7 +102,7 @@ static Column _special_col(size_t nrows) {
});

if (std::is_same<T, PyObject*>::value) {
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + nrows);
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + static_cast<Py_ssize_t>(nrows));
buf.set_pyobjects(/* clear_data= */ false);
}
return Column(new ColClass(nrows, std::move(buf)));
Expand Down

0 comments on commit 753197c

Please sign in to comment.