Skip to content

Commit 866fef1

Browse files
authored
MNT DNPY_NO_DEPRECATED_API=NPY_1_22_API_VERSION and security fixes (scikit-learn#31984)
1 parent b10b73a commit 866fef1

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

sklearn/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ inc_np = include_directories(incdir_numpy)
100100
# Don't use the deprecated NumPy C API. Define this to a fixed version instead of
101101
# NPY_API_VERSION in order not to break compilation for released SciPy versions
102102
# when NumPy introduces a new deprecation.
103-
numpy_no_deprecated_api = ['-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION']
103+
numpy_no_deprecated_api = ['-DNPY_NO_DEPRECATED_API=NPY_1_22_API_VERSION']
104104
np_dep = declare_dependency(include_directories: inc_np, compile_args: numpy_no_deprecated_api)
105105

106106
openmp_dep = dependency('OpenMP', language: 'c', required: false)

sklearn/metrics/_dist_metrics.pyx.tp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ cdef class DistanceMetric{{name_suffix}}(DistanceMetric):
846846

847847
intp_t i1, i2
848848
intp_t x1_start, x1_end
849-
{{INPUT_DTYPE_t}} * x2_data
849+
const {{INPUT_DTYPE_t}} * x2_data
850850

851851
with nogil:
852852
# Use the exact same adaptation for CSR than in SparseDenseDatasetsPair
@@ -910,7 +910,7 @@ cdef class DistanceMetric{{name_suffix}}(DistanceMetric):
910910
{{INPUT_DTYPE_t}}[:, ::1] Darr = np.empty((n_X, n_Y), dtype={{INPUT_DTYPE}}, order='C')
911911

912912
intp_t i1, i2
913-
{{INPUT_DTYPE_t}} * x1_data
913+
const {{INPUT_DTYPE_t}} * x1_data
914914

915915
intp_t x2_start, x2_end
916916

sklearn/neighbors/_ball_tree.pyx.tp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ cdef int init_node{{name_suffix}}(
9898
cdef float64_t radius
9999
cdef const {{INPUT_DTYPE_t}} *this_pt
100100

101-
cdef intp_t* idx_array = &tree.idx_array[0]
101+
cdef const intp_t* idx_array = &tree.idx_array[0]
102102
cdef const {{INPUT_DTYPE_t}}* data = &tree.data[0, 0]
103103
cdef {{INPUT_DTYPE_t}}* centroid = &tree.node_bounds[0, i_node, 0]
104104

sklearn/svm/src/liblinear/linear.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void info(const char *fmt,...)
7373
char buf[BUFSIZ];
7474
va_list ap;
7575
va_start(ap,fmt);
76-
vsprintf(buf,fmt,ap);
76+
vsnprintf(buf,sizeof buf,fmt,ap);
7777
va_end(ap);
7878
(*liblinear_print_string)(buf);
7979
}

sklearn/svm/src/liblinear/tron.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void TRON::info(const char *fmt,...)
2323
char buf[BUFSIZ];
2424
va_list ap;
2525
va_start(ap,fmt);
26-
vsprintf(buf,fmt,ap);
26+
vsnprintf(buf,sizeof buf,fmt,ap);
2727
va_end(ap);
2828
(*tron_print_string)(buf);
2929
}

sklearn/svm/src/libsvm/svm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static void info(const char *fmt,...)
117117
char buf[BUFSIZ];
118118
va_list ap;
119119
va_start(ap,fmt);
120-
vsprintf(buf,fmt,ap);
120+
vsnprintf(buf,sizeof buf,fmt,ap);
121121
va_end(ap);
122122
(*svm_print_string)(buf);
123123
}

0 commit comments

Comments
 (0)