"""Synthetic filename and benign value only; no private traceback paths exported."""
import traceback,json,platform
SOURCE='''def wrap(mode):
    try:
        int("authored-not-a-number")
    except ValueError as original:
        if mode == "implicit":
            raise RuntimeError("authored-domain-error")
        if mode == "explicit":
            raise RuntimeError("authored-domain-error") from original
        if mode == "hidden":
            raise RuntimeError("authored-domain-error") from None
'''
def demo():
 ns={};exec(compile(SOURCE,'authored_exception_fixture.py','exec'),ns);rows=[]
 for mode in ['implicit','explicit','hidden']:
  try:ns['wrap'](mode)
  except RuntimeError as e:
   tb=e.__traceback__.tb_next;formatted=''.join(traceback.format_exception(type(e),e,tb))
   row={'mode':mode,'type':type(e).__name__,'cause_type':type(e.__cause__).__name__ if e.__cause__ is not None else None,'context_type':type(e.__context__).__name__ if e.__context__ is not None else None,'suppress_context':e.__suppress_context__,'formatted':formatted};rows.append(row)
 assert [(r['cause_type'],r['context_type'],r['suppress_context'])for r in rows]==[(None,'ValueError',False),('ValueError','ValueError',True),(None,'ValueError',True)]
 assert 'ValueError:'in rows[0]['formatted']and 'direct cause'in rows[1]['formatted']and 'ValueError:'not in rows[2]['formatted']
 assert all('D:\\'not in r['formatted']and 'C:\\'not in r['formatted']for r in rows)
 return {'python':platform.python_version(),'synthetic_source':SOURCE,'rows':rows,'from_none_does_not_erase_context_object':True,'private_file_or_network_accessed':False,'all_assertions_passed':True}
if __name__=='__main__':print(json.dumps(demo(),indent=2))
