Skip to content

Commit 4502660

Browse files
committed
Clean up compiler warnings
1 parent 5e6a949 commit 4502660

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

pandas/_libs/byteswap.pyx

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ from libc.string cimport memcpy
1515

1616
def read_float_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
1717
cdef uint32_t value
18-
assert offset + sizeof(value) < len(data)
18+
assert offset + <Py_ssize_t>sizeof(value) < len(data)
1919
cdef const void *ptr = <unsigned char*>(data) + offset
2020
memcpy(&value, ptr, sizeof(value))
2121
if byteswap:
@@ -28,7 +28,7 @@ def read_float_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
2828

2929
def read_double_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
3030
cdef uint64_t value
31-
assert offset + sizeof(value) < len(data)
31+
assert offset + <Py_ssize_t>sizeof(value) < len(data)
3232
cdef const void *ptr = <unsigned char*>(data) + offset
3333
memcpy(&value, ptr, sizeof(value))
3434
if byteswap:
@@ -41,7 +41,7 @@ def read_double_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
4141

4242
def read_uint16_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
4343
cdef uint16_t res
44-
assert offset + sizeof(res) < len(data)
44+
assert offset + <Py_ssize_t>sizeof(res) < len(data)
4545
memcpy(&res, <const unsigned char*>(data) + offset, sizeof(res))
4646
if byteswap:
4747
res = _byteswap2(res)
@@ -50,7 +50,7 @@ def read_uint16_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
5050

5151
def read_uint32_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
5252
cdef uint32_t res
53-
assert offset + sizeof(res) < len(data)
53+
assert offset + <Py_ssize_t>sizeof(res) < len(data)
5454
memcpy(&res, <const unsigned char*>(data) + offset, sizeof(res))
5555
if byteswap:
5656
res = _byteswap4(res)
@@ -59,7 +59,7 @@ def read_uint32_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
5959

6060
def read_uint64_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap):
6161
cdef uint64_t res
62-
assert offset + sizeof(res) < len(data)
62+
assert offset + <Py_ssize_t>sizeof(res) < len(data)
6363
memcpy(&res, <const unsigned char*>(data) + offset, sizeof(res))
6464
if byteswap:
6565
res = _byteswap8(res)

pandas/_libs/include/pandas/vendored/klib/khash_python.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ static void *traced_calloc(size_t num, size_t size) {
3434
}
3535

3636
static void *traced_realloc(void *old_ptr, size_t size) {
37+
PyTraceMalloc_Untrack(KHASH_TRACE_DOMAIN, (uintptr_t)old_ptr);
3738
void *ptr = realloc(old_ptr, size);
3839
if (ptr != NULL) {
39-
if (old_ptr != ptr) {
40-
PyTraceMalloc_Untrack(KHASH_TRACE_DOMAIN, (uintptr_t)old_ptr);
41-
}
4240
PyTraceMalloc_Track(KHASH_TRACE_DOMAIN, (uintptr_t)ptr, size);
4341
}
4442
return ptr;

pandas/_libs/tslibs/conversion.pyx

+8-8
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,18 @@ def cast_from_unit_vectorized(
149149
if p:
150150
frac = np.round(frac, p)
151151

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

166166

0 commit comments

Comments
 (0)