Changeset 5046 for trunk/GSASIIpath.py


Ignore:
Timestamp:
Oct 9, 2021 11:54:26 AM (20 months ago)
Author:
toby
Message:

suppress breakpoint() unless inside spyder or debug mode is set; divert breakpoint to IPyBreak

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpath.py

    r4994 r5046  
    976976def InvokeDebugOpts():
    977977    'Called in GSASII.py to set up debug options'
    978     if GetConfigValue('debug'):
    979         print ('Debug on: IPython: Exceptions and G2path.IPyBreak(); pdb: G2path.pdbBreak()')
    980         import pdb
    981         global pdbBreak
    982         pdbBreak = pdb.set_trace
     978    if any('SPYDER' in name for name in os.environ):
     979        print('Running from Spyder, keeping breakpoint() active & skipping exception trapping')
     980    elif GetConfigValue('debug'):
    983981        try:
     982            import pdb
     983            global pdbBreak
     984            pdbBreak = pdb.set_trace
    984985            import IPython
    985986            global IPyBreak
    986987            IPyBreak = IPyBreak_base
    987             if any('SPYDER' in name for name in os.environ):
    988                 print('Running from Spyder, skipping exception trapping')
    989             else:
    990                 sys.excepthook = exceptHook
     988            sys.excepthook = exceptHook
     989            os.environ['PYTHONBREAKPOINT'] = 'GSASIIpath.IPyBreak_base'
     990            print ('Debug on: IPython: Exceptions and G2path.IPyBreak(); pdb: G2path.pdbBreak()')
    991991        except:
    992             pass
     992            print ('Debug on failed. IPython not installed?')
     993    else: # not in spyder or debug enabled, hide breakpoints
     994        os.environ['PYTHONBREAKPOINT'] = '0'
    993995
    994996def TestSPG(fpth):
Note: See TracChangeset for help on using the changeset viewer.