From 9e6538556abb616486f8b8155e71776ad1394029 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Thu, 16 May 2019 22:48:35 +0000 Subject: [PATCH] Dump also the deeper frames, not just the get_items one --- snscrape/cli.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/snscrape/cli.py b/snscrape/cli.py index e6c8a6a..80286f1 100644 --- a/snscrape/cli.py +++ b/snscrape/cli.py @@ -18,15 +18,17 @@ def _dump_locals_on_exception(): except Exception as e: trace = inspect.trace() if len(trace) >= 3: - frameRecord = inspect.trace()[2] - locals_ = frameRecord[0].f_locals with tempfile.NamedTemporaryFile('w', prefix = 'snscrape_locals_', delete = False) as fp: - fp.write(f'Locals from file "{frameRecord.filename}", line {frameRecord.lineno}, in {frameRecord.function}:\n') - fp.write(repr(locals_)) - fp.write('\n') - if 'self' in locals_ and hasattr(locals_['self'], '__dict__'): - fp.write(f'Object dict:\n') - fp.write(repr(locals_['self'].__dict__)) + for i in range(2, len(trace)): + frameRecord = trace[i] + locals_ = frameRecord[0].f_locals + fp.write(f'Locals from file "{frameRecord.filename}", line {frameRecord.lineno}, in {frameRecord.function}:\n') + fp.write(repr(locals_)) + fp.write('\n') + if 'self' in locals_ and hasattr(locals_['self'], '__dict__'): + fp.write(f'Object dict:\n') + fp.write(repr(locals_['self'].__dict__)) + fp.write('\n\n') logger.fatal(f'Local variables logged to {fp.name}') raise