Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Commit 6ef3ab3

Browse files
committed
Modernize exec syntax in rpython/
1 parent 32be959 commit 6ef3ab3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+113
-113
lines changed

rpython/annotator/specialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def make_helper(firstarg, stmt, miniglobals):
148148
header = "def f(%s):" % (', '.join(argnames[firstarg:],))
149149
source = py.code.Source(stmt)
150150
source = source.putaround(header)
151-
exec source.compile() in miniglobals
151+
exec(source.compile(), miniglobals)
152152
f = miniglobals['f']
153153
return func_with_new_name(f, 'memo_%s_%d' % (name, firstarg))
154154

rpython/flowspace/operation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,22 +320,22 @@ def inplace_mul(x, y):
320320
x *= y
321321
return x
322322

323-
exec compile2("""
323+
exec(compile2("""
324324
def inplace_truediv(x, y):
325325
x /= y
326326
return x
327-
""", flags=__future__.CO_FUTURE_DIVISION, dont_inherit=1)
327+
""", flags=__future__.CO_FUTURE_DIVISION, dont_inherit=1))
328328
# makes an INPLACE_TRUE_DIVIDE
329329

330330
def inplace_floordiv(x, y):
331331
x //= y
332332
return x
333333

334-
exec compile2("""
334+
exec(compile2("""
335335
def inplace_div(x, y):
336336
x /= y
337337
return x
338-
""", flags=0, dont_inherit=1) # makes an INPLACE_DIVIDE
338+
""", flags=0, dont_inherit=1)) # makes an INPLACE_DIVIDE
339339

340340
def inplace_mod(x, y):
341341
x %= y

rpython/flowspace/test/test_objspace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ def test_locals_dict(self):
11561156
def f():
11571157
x = 5
11581158
return x
1159-
exec "None"
1159+
exec("None")
11601160
graph = self.codetest(f)
11611161
assert len(graph.startblock.exits) == 1
11621162
assert graph.startblock.exits[0].target == graph.returnblock

rpython/jit/backend/llgraph/runner.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -890,17 +890,17 @@ def bh_vec_{0}_{1}(self, vx, vy, count):
890890
assert len(vx) == len(vy) == count
891891
return [_vx {2} _vy for _vx,_vy in zip(vx,vy)]
892892
"""
893-
exec py.code.Source(vector_arith_code.format('int','add','+')).compile()
894-
exec py.code.Source(vector_arith_code.format('int','sub','-')).compile()
895-
exec py.code.Source(vector_arith_code.format('int','mul','*')).compile()
896-
exec py.code.Source(vector_arith_code.format('int','and','&')).compile()
897-
exec py.code.Source(vector_arith_code.format('int','or','|')).compile()
898-
899-
exec py.code.Source(vector_float_arith_code.format('float','add','+')).compile()
900-
exec py.code.Source(vector_float_arith_code.format('float','sub','-')).compile()
901-
exec py.code.Source(vector_float_arith_code.format('float','mul','*')).compile()
902-
exec py.code.Source(vector_float_arith_code.format('float','truediv','/')).compile()
903-
exec py.code.Source(vector_float_arith_code.format('float','eq','==')).compile()
893+
exec(py.code.Source(vector_arith_code.format('int','add','+')).compile())
894+
exec(py.code.Source(vector_arith_code.format('int','sub','-')).compile())
895+
exec(py.code.Source(vector_arith_code.format('int','mul','*')).compile())
896+
exec(py.code.Source(vector_arith_code.format('int','and','&')).compile())
897+
exec(py.code.Source(vector_arith_code.format('int','or','|')).compile())
898+
899+
exec(py.code.Source(vector_float_arith_code.format('float','add','+')).compile())
900+
exec(py.code.Source(vector_float_arith_code.format('float','sub','-')).compile())
901+
exec(py.code.Source(vector_float_arith_code.format('float','mul','*')).compile())
902+
exec(py.code.Source(vector_float_arith_code.format('float','truediv','/')).compile())
903+
exec(py.code.Source(vector_float_arith_code.format('float','eq','==')).compile())
904904

905905
def bh_vec_float_neg(self, vx, count):
906906
return [e * -1 for e in vx]

rpython/jit/backend/llsupport/descr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ def call_stub(func, args_i, args_r, args_f):
605605
FUNC = lltype.FuncType(ARGS, RESULT)
606606
d = globals().copy()
607607
d.update(locals())
608-
exec source.compile() in d
608+
exec(source.compile(), d)
609609
call_stub = d['call_stub']
610610
# store the function into one of three attributes, to preserve
611611
# type-correctness of the return value

rpython/jit/backend/ppc/rassemblermaker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def make_func(name, desc):
6666
src = 'def %s(self, %s):\n %s'%(name, ', '.join(sig), '\n '.join(body))
6767
d = {'r_uint':r_uint, 'desc': desc}
6868
#print src
69-
exec compile2(src) in d
69+
exec(compile2(src), d)
7070
return d[name]
7171

7272
def make_rassembler(cls):

rpython/jit/backend/test/support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def entry_point(argv):
5353
print res
5454
return 0
5555
""" % (arglist,))
56-
exec src.compile() in locals()
56+
exec(src.compile(), locals())
5757

5858
t.buildannotator().build_types(function, [int] * len(args),
5959
main_entry_point=True)

rpython/jit/backend/test/test_ll_random.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def f(%s):
569569
return %s
570570
""" % (funcargs, sum, result)).compile()
571571
d = {'intmask': intmask}
572-
exec code in d
572+
exec(code, d)
573573
return subset, d['f']
574574

575575
def raising_func_code(self, builder, r):
@@ -587,7 +587,7 @@ def f(%s):
587587
'vtable': vtableptr,
588588
'LLException': LLException,
589589
}
590-
exec code in d
590+
exec(code, d)
591591
return subset, d['f'], vtableptr
592592

593593
def getresulttype(self):

rpython/jit/backend/x86/vector_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def genop_vec_float_{type}(self, op, arglocs, resloc):
295295
_source = genop_vec_float_arith.format(type=op,
296296
p_op_s=OP+'PS',
297297
p_op_d=OP+'PD')
298-
exec py.code.Source(_source).compile()
298+
exec(py.code.Source(_source).compile())
299299
del genop_vec_float_arith
300300

301301
def genop_vec_float_truediv(self, op, arglocs, resloc):

rpython/jit/codewriter/jtransform.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ def rewrite_op_direct_ptradd(self, op):
14741474
('cast_longlong_to_float', 'TO_FLOAT'),
14751475
('cast_uint_to_longlong', 'FROM_UINT'),
14761476
]:
1477-
exec py.code.Source('''
1477+
exec(py.code.Source('''
14781478
def rewrite_op_%s(self, op):
14791479
args = op.args
14801480
op1 = self.prepare_builtin_call(op, "llong_%s", args)
@@ -1484,7 +1484,7 @@ def rewrite_op_%s(self, op):
14841484
if %r == "TO_INT":
14851485
assert op2.result.concretetype == lltype.Signed
14861486
return op2
1487-
''' % (_op, _oopspec.lower(), _oopspec, _oopspec)).compile()
1487+
''' % (_op, _oopspec.lower(), _oopspec, _oopspec)).compile())
14881488

14891489
for _op, _oopspec in [('cast_int_to_ulonglong', 'FROM_INT'),
14901490
('cast_uint_to_ulonglong', 'FROM_UINT'),
@@ -1506,15 +1506,15 @@ def rewrite_op_%s(self, op):
15061506
('ullong_lshift', 'LSHIFT'),
15071507
('ullong_rshift', 'URSHIFT'),
15081508
]:
1509-
exec py.code.Source('''
1509+
exec(py.code.Source('''
15101510
def rewrite_op_%s(self, op):
15111511
args = op.args
15121512
op1 = self.prepare_builtin_call(op, "ullong_%s", args)
15131513
op2 = self._handle_oopspec_call(op1, args,
15141514
EffectInfo.OS_LLONG_%s,
15151515
EffectInfo.EF_ELIDABLE_CANNOT_RAISE)
15161516
return op2
1517-
''' % (_op, _oopspec.lower(), _oopspec)).compile()
1517+
''' % (_op, _oopspec.lower(), _oopspec)).compile())
15181518

15191519
def _normalize(self, oplist):
15201520
if isinstance(oplist, SpaceOperation):
@@ -1581,11 +1581,11 @@ def rewrite_op_cast_primitive(self, op):
15811581
('adr_add', 'int_add'),
15821582
]:
15831583
assert _old not in locals()
1584-
exec py.code.Source('''
1584+
exec(py.code.Source('''
15851585
def rewrite_op_%s(self, op):
15861586
op1 = SpaceOperation(%r, op.args, op.result)
15871587
return self.rewrite_operation(op1)
1588-
''' % (_old, _new)).compile()
1588+
''' % (_old, _new)).compile())
15891589

15901590
def rewrite_op_float_is_true(self, op):
15911591
op1 = SpaceOperation('float_ne',

0 commit comments

Comments
 (0)