@@ -185,6 +185,31 @@ def main():
185185 main()
186186 ''' )
187187
188+ pyerr_printex_code = textwrap .dedent ('''
189+ import sys
190+
191+ class Hook:
192+ def __call__(self, *args, **kwds):
193+ pass
194+
195+ def __repr__(self):
196+ h = sys.excepthook
197+ setattr(sys, 'excepthook', sys.__excepthook__)
198+ del h
199+ return 'Hook'
200+
201+ def audit(event, args):
202+ repr(args)
203+
204+ def main():
205+ sys.addaudithook(audit)
206+ setattr(sys, 'excepthook', Hook())
207+ raise
208+
209+ if __name__ == "__main__":
210+ main()
211+ ''' )
212+
188213
189214 def test_print_deleted_stdout (self ):
190215 # print should use strong reference to the stdout.
@@ -323,5 +348,12 @@ def test_py_finalize_flush_std_files_stderr(self):
323348 self .assertNotIn (b"Segmentation fault" , err )
324349 self .assertNotIn (b"access violation" , err )
325350
351+ def test_pyerr_printex_excepthook (self ):
352+ test_code = self .pyerr_printex_code
353+ rc , _ , err = assert_python_ok ('-c' , test_code )
354+ self .assertEqual (rc , 0 )
355+ self .assertNotIn (b"Segmentation fault" , err )
356+ self .assertNotIn (b"access violation" , err )
357+
326358if __name__ == "__main__" :
327359 unittest .main ()
0 commit comments