Skip to content

Commit

Permalink
Merge pull request numba#9331 from stuartarchibald/fix/syntax_depreca…
Browse files Browse the repository at this point in the history
…tion_warnings_312

Fix Syntax and Deprecation Warnings from 3.12.
  • Loading branch information
sklam authored Dec 6, 2023
2 parents 3ef2260 + b32b682 commit 7f984a0
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion numba/misc/gdb_print_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def to_string(self):
# NOTE: need to deal with "Alignment" else dtype size is wrong
arr_info = [x.strip() for x in matcher.match(ty_str).groups()]
dtype_str, ndim_str, order_str = arr_info
rstr = 'Record\\((.*\\[.*\\]);([0-9]+);(True|False)'
rstr = r'Record\((.*\[.*\]);([0-9]+);(True|False)'
rstr_match = re.match(rstr, dtype_str)
# balign is unused, it's the alignment
fields, balign, is_aligned_str = rstr_match.groups()
Expand Down
2 changes: 1 addition & 1 deletion numba/misc/llvm_pass_timings.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def parse(raw_data):
else:
attrs.append(f"{k}_time")
attrs.append(f"{k}_percent")
pat += f"\\s+(?:{n}\\s*\\({n}%\\)|-+)"
pat += rf"\s+(?:{n}\s*\({n}%\)|-+)"

# put default value 0.0 to all missing attributes
missing = {}
Expand Down
2 changes: 1 addition & 1 deletion numba/np/ufunc/array_exprs.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def _arr_expr_to_ast(expr):
lineno=expr.loc.line,
col_offset=expr.loc.col if expr.loc.col else 0), {}
elif isinstance(expr, ir.Const):
return ast.Num(expr.value), {}
return ast.Constant(expr.value), {}
raise NotImplementedError(
"Don't know how to translate array expression '%r'" % (expr,))

Expand Down
2 changes: 1 addition & 1 deletion numba/tests/test_dictobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ def test_exception_nargs(self):
Dict(1, 2)

def test_exception_mapping_ctor(self):
msg = '.*dict\(mapping\) is not supported.*' # noqa: W605
msg = r'.*dict\(mapping\) is not supported.*' # noqa: W605
with self.assertRaisesRegex(TypingError, msg):
Dict({1: 2})

Expand Down
6 changes: 3 additions & 3 deletions numba/tests/test_parfors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4169,9 +4169,9 @@ def test_impl():
cres = self.compile_parallel_fastmath(pfunc, ())
ir = self._get_gufunc_ir(cres)
_id = '%[A-Z_0-9]?(.[0-9]+)+[.]?[i]?'
recipr_str = '\s+%s = fmul fast double %s, 5.000000e-01'
recipr_str = r'\s+%s = fmul fast double %s, 5.000000e-01'
reciprocal_inst = re.compile(recipr_str % (_id, _id))
fadd_inst = re.compile('\s+%s = fadd fast double %s, %s'
fadd_inst = re.compile(r'\s+%s = fadd fast double %s, %s'
% (_id, _id, _id))
# check there is something like:
# %.329 = fmul fast double %.325, 5.000000e-01
Expand Down Expand Up @@ -4620,7 +4620,7 @@ def get_gufunc_asm(self, func, schedule_type, *args, **kwargs):
asm = self._get_gufunc_asm(cres)

if assertions:
schedty = re.compile('call\s+\w+\*\s+@do_scheduling_(\w+)\(')
schedty = re.compile(r'call\s+\w+\*\s+@do_scheduling_(\w+)\(')
matches = schedty.findall(cres.library.get_llvm_str())
self.assertGreaterEqual(len(matches), 1) # at least 1 parfor call
self.assertEqual(matches[0], schedule_type)
Expand Down
2 changes: 1 addition & 1 deletion numba/tests/test_svml.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class TestSVMLGeneration(TestCase):
# env mutating, must not run in parallel
_numba_parallel_test_ = False
# RE for a generic symbol reference and for each particular SVML function
asm_filter = re.compile('|'.join(['\$[a-z_]\w+,']+list(svml_funcs)))
asm_filter = re.compile('|'.join([r'\$[a-z_]\w+,']+list(svml_funcs)))

@classmethod
def mp_runner(cls, testname, outqueue):
Expand Down
2 changes: 1 addition & 1 deletion numba/tests/test_typingerror.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def test_unsupported_type(self):
cfunc(1, foo, 1)

expected=re.compile(("This error may have been caused by the following "
"argument\(s\):\\n- argument 1:.*Cannot determine "
r"argument\(s\):\n- argument 1:.*Cannot determine "
"Numba type of "
"<class \'numba.tests.test_typingerror.Foo\'>"))
self.assertTrue(expected.search(str(raises.exception)) is not None)
Expand Down
4 changes: 2 additions & 2 deletions numba/tests/test_withlifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def foo(x):
njit(foo)(123)
# Check that an error occurred in with-lifting in objmode
pat = ("During: resolving callee type: "
"type\(ObjModeLiftedWith\(<.*>\)\)")
r"type\(ObjModeLiftedWith\(<.*>\)\)")
self.assertRegex(str(raises.exception), pat)

def test_case07_mystery_key_error(self):
Expand Down Expand Up @@ -822,7 +822,7 @@ def global_var():
with self.assertRaisesRegex(
errors.CompilerError,
("Error handling objmode argument 'val'. "
"Global 'gv_type2' is not defined\.")
r"Global 'gv_type2' is not defined.")
):
global_var()

Expand Down

0 comments on commit 7f984a0

Please sign in to comment.