8000 make MismatchCAPIWarnining into MismatchCAPIError · rjeb/numpy@54a7b0b · GitHub
[go: up one dir, main page]

Skip to content

Commit 54a7b0b

Browse files
committed
make MismatchCAPIWarnining into MismatchCAPIError
1 parent 6014a39 commit 54a7b0b

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

numpy/core/setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,8 @@ def configuration(parent_package='',top_path=None):
476476
local_dir = config.local_path
477477
codegen_dir = join(local_dir, 'code_generators')
478478

479-
if is_released:
480-
warnings.simplefilter('error', MismatchCAPIWarning)
481-
482479
# Check whether we have a mismatch between the set C API VERSION and the
483-
# actual C API VERSION
480+
# actual C API VERSION. Will raise a MismatchCAPIError if so.
484481
check_api_version(C_API_VERSION, codegen_dir)
485482

486483
generate_umath_py = join(codegen_dir, 'generate_umath.py')

numpy/core/setup_common.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
# 0x00000010 - 1.24.x
5252
C_API_VERSION = 0x00000010
5353

54-
class MismatchCAPIWarning(Warning):
54+
class MismatchCAPIError(ValueError):
5555
pass
5656

5757

@@ -87,14 +87,13 @@ def check_api_version(apiversion, codegen_dir):
8787
# To compute the checksum of the current API, use numpy/core/cversions.py
8888
if not curapi_hash == api_hash:
8989
msg = ("API mismatch detected, the C API version "
90-
"numbers have to be updated. Current C api version is %d, "
91-
"with checksum %s, but recorded checksum for C API version %d "
92-
"in core/codegen_dir/cversions.txt is %s. If functions were "
93-
"added in the C API, you have to update C_API_VERSION in %s."
90+
"numbers have to be updated. Current C api version is "
91+
f"{apiversion}, with checksum {curapi_hash}, but recorded "
92+
f"checksum in core/codegen_dir/cversions.txt is {api_hash}. If "
93+
"functions were added in the C API, you have to update "
94+
f"C_API_VERSION in {__file__}."
9495
)
95-
warnings.warn(msg % (apiversion, curapi_hash, apiversion, api_hash,
96-
__file__),
97-
MismatchCAPIWarning, stacklevel=2)
96+
raise MismatchCAPIError(msg)
9897

9998

10099
FUNC_CALL_ARGS = {}

0 commit comments

Comments
 (0)
0