Skip to content

Commit 1195c3e

Browse files
tests: fix for 3.14
1 parent 987776e commit 1195c3e

7 files changed

Lines changed: 446 additions & 191 deletions

File tree

tests/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,21 @@ def assertCodeObjectEqual(self, code1: types.CodeType, code2: types.CodeType):
181181
list(dis.findlinestarts(code1)), list(dis.findlinestarts(code2))
182182
)
183183

184-
# If names have been re-ordered compared the output of dis.instructions
184+
# If names or consts have been re-ordered compared the output of dis.instructions
185185
if sys.version_info >= (3, 12) and (
186-
code1.co_names != code2.co_names or code1.co_varnames != code2.co_varnames
186+
code1.co_consts != code2.co_consts
187+
or code1.co_names != code2.co_names
188+
or code1.co_varnames != code2.co_varnames
187189
):
188190
instrs1 = list(dis.get_instructions(code1))
189191
instrs2 = list(dis.get_instructions(code2))
190192
self.assertEqual(len(instrs1), len(instrs2))
191193
for i1, i2 in zip(instrs1, instrs2):
192194
self.assertEqual(i1.opcode, i2.opcode)
193-
self.assertEqual(i1.argval, i2.argval)
195+
if isinstance(i1.argval, types.CodeType):
196+
pass
197+
else:
198+
self.assertEqual(i1.argval, i2.argval)
194199
elif sys.version_info >= (3, 9):
195200
self.assertSequenceEqual(code1.co_code, code2.co_code)
196201
# On Python 3.8 it happens that fast storage index vary in a roundtrip

tests/exception_handling_cases.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,14 @@ def try_except_in_else():
215215

216216
def try_finally_in_else():
217217
try:
218-
a = 1
218+
a = "a"
219219
except ValueError as e:
220220
return
221221
else:
222222
try:
223223
pass
224224
finally:
225-
a = 1
225+
a = "a"
226226

227227

228228
def try_except_in_finally():
@@ -264,65 +264,65 @@ def try_except_group():
264264

265265

266266
def with_no_store():
267-
with contextlib.nullcontext(1):
268-
a = 1
267+
with contextlib.nullcontext("1"):
268+
a = "1"
269269
return a
270270

271271

272272
def with_store():
273-
with contextlib.nullcontext(1) as b:
274-
a = 1
273+
with contextlib.nullcontext("1") as b:
274+
a = "1"
275275
return a
276276

277277

278278
def try_with():
279279
try:
280-
with contextlib.nullcontext(1):
281-
a = 1
280+
with contextlib.nullcontext("1"):
281+
a = "1"
282282
except Exception:
283-
return min(1, 2)
283+
return min("1", "2")
284284

285285
return a
286286

287287

288288
def with_try():
289-
with contextlib.nullcontext(1):
289+
with contextlib.nullcontext("1"):
290290
try:
291-
b = 1
291+
b = "1"
292292
except Exception:
293-
return min(1, 2)
293+
return min("1", "2")
294294

295295
return b
296296

297297

298298
async def async_with_no_store():
299299
async with contextlib.nullcontext():
300-
a = 1
300+
a = "1"
301301
return a
302302

303303

304304
async def async_with_store():
305305
async with contextlib.nullcontext() as b:
306-
a = 1
306+
a = "1"
307307
return a
308308

309309

310310
async def try_async_with():
311311
try:
312312
async with contextlib.nullcontext(1):
313-
a = 1
313+
a = "1"
314314
except Exception:
315-
return min(1, 2)
315+
return min("1", "2")
316316

317317
return a
318318

319319

320320
async def async_with_try():
321321
async with contextlib.nullcontext(1):
322322
try:
323-
b = 1
323+
b = "1"
324324
except Exception:
325-
return min(1, 2)
325+
return min(1.0, 2.0)
326326

327327
return b
328328

0 commit comments

Comments
 (0)