Skip to content

Clean up compiler warnings #60674

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions pandas/_libs/byteswap.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ from libc.string cimport memcpy

def read_float_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
cdef uint32_t value
assert offset + sizeof(value) < len(data)
assert offset + <Py_ssize_t>sizeof(value) < len(data)
cdef const void *ptr = <unsigned char*>(data) + offset
memcpy(&value, ptr, sizeof(value))
if byteswap:
Expand All @@ -28,7 +28,7 @@ def read_float_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):

def read_double_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
cdef uint64_t value
assert offset + sizeof(value) < len(data)
assert offset + <Py_ssize_t>sizeof(value) < len(data)
cdef const void *ptr = <unsigned char*>(data) + offset
memcpy(&value, ptr, sizeof(value))
if byteswap:
Expand All @@ -41,7 +41,7 @@ def read_double_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):

def read_uint16_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
cdef uint16_t res
assert offset + sizeof(res) < len(data)
assert offset + <Py_ssize_t>sizeof(res) < len(data)
memcpy(&res, <const unsigned char*>(data) + offset, sizeof(res))
if byteswap:
res = _byteswap2(res)
Expand All @@ -50,7 +50,7 @@ def read_uint16_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):

def read_uint32_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
cdef uint32_t res
assert offset + sizeof(res) < len(data)
assert offset + <Py_ssize_t>sizeof(res) < len(data)
memcpy(&res, <const unsigned char*>(data) + offset, sizeof(res))
if byteswap:
res = _byteswap4(res)
Expand All @@ -59,7 +59,7 @@ def read_uint32_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):

def read_uint64_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
cdef uint64_t res
assert offset + sizeof(res) < len(data)
assert offset + <Py_ssize_t>sizeof(res) < len(data)
memcpy(&res, <const unsigned char*>(data) + offset, sizeof(res))
if byteswap:
res = _byteswap8(res)
Expand Down
4 changes: 1 addition & 3 deletions pandas/_libs/include/pandas/vendored/klib/khash_python.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ static void *traced_calloc(size_t num, size_t size) {
}

static void *traced_realloc(void *old_ptr, size_t size) {
PyTraceMalloc_Untrack(KHASH_TRACE_DOMAIN, (uintptr_t)old_ptr);
void *ptr = realloc(old_ptr, size);
if (ptr != NULL) {
if (old_ptr != ptr) {
PyTraceMalloc_Untrack(KHASH_TRACE_DOMAIN, (uintptr_t)old_ptr);
}
PyTraceMalloc_Track(KHASH_TRACE_DOMAIN, (uintptr_t)ptr, size);
}
return ptr;
Expand Down
16 changes: 8 additions & 8 deletions pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,18 @@ def cast_from_unit_vectorized(
if p:
frac = np.round(frac, p)

try:
for i in range(len(values)):
for i in range(len(values)):
try:
if base[i] == NPY_NAT:
out[i] = NPY_NAT
else:
out[i] = <int64_t>(base[i] * m) + <int64_t>(frac[i] * m)
except (OverflowError, FloatingPointError) as err:
# FloatingPointError can be issued if we have float dtype and have
# set np.errstate(over="raise")
raise OutOfBoundsDatetime(
f"cannot convert input {values[i]} with the unit '{unit}'"
) from err
except (OverflowError, FloatingPointError) as err:
# FloatingPointError can be issued if we have float dtype and have
# set np.errstate(over="raise")
raise OutOfBoundsDatetime(
f"cannot convert input {values[i]} with the unit '{unit}'"
) from err
return out


Expand Down
Loading