@@ -448,6 +448,21 @@ def check_traceback_entry(self, entry, filename, funcname):
448
448
self .assertEqual (os .path .basename (entry .filename ), filename )
449
449
self .assertEqual (entry .name , funcname )
450
450
451
+ @support .cpython_only
452
+ def test_exception (self ):
453
+ # gh-66652: test _PyTraceback_Add() used by pyexpat.c to inject frames
454
+
455
+ # Change the current directory to the Python source code directory
456
+ # if it is available.
457
+ src_dir = sysconfig .get_config_var ('abs_builddir' )
458
+ have_source = os .path .isdir (src_dir )
459
+ if have_source :
460
+ cm = os_helper .change_cwd (src_dir )
461
+ else :
462
+ cm = contextlib .nullcontext ()
463
+ with cm :
464
+ self ._test_exception (have_source )
465
+
451
466
def _test_exception (self , have_source ):
452
467
# Use path relative to the current directory which should be the Python
453
468
# source code directory (if it is available).
@@ -479,21 +494,6 @@ def _test_exception(self, have_source):
479
494
self .assertIn ('call_with_frame("StartElement"' ,
480
495
entries [1 ].line )
481
496
482
- @support .cpython_only
483
- def test_exception (self ):
484
- # gh-66652: test _PyTraceback_Add() used by pyexpat.c to inject frames
485
-
486
- # Change the current directory to the Python source code directory
487
- # if it is available.
488
- src_dir = sysconfig .get_config_var ('abs_builddir' )
489
- have_source = os .path .isdir (src_dir )
490
- if have_source :
491
- cm = os_helper .change_cwd (src_dir )
492
- else :
493
- cm = contextlib .nullcontext ()
494
- with cm :
495
- self ._test_exception (have_source )
496
-
497
497
498
498
# Test Current* members:
499
499
class PositionTest (unittest .TestCase ):
0 commit comments