Skip to content

Commit 883e406

Browse files
committed
nicer printout for py2 and py3
1 parent b61dd5f commit 883e406

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎v3/pg_logger.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import traceback
3737
import types
3838

39+
# TODO: use the 'six' package to smooth out Py2 and Py3 differences
3940
is_python3 = (sys.version_info[0] == 3)
4041

4142
if is_python3:
@@ -294,7 +295,7 @@ def get_user_globals(frame, at_global_scope=False):
294295

295296
# print out list objects being built up in Python 2.x list comprehensions
296297
# (which don't have its own special <listcomp> frame, sadly)
297-
if hasattr(frame, 'f_valuestack'):
298+
if not is_python3 and hasattr(frame, 'f_valuestack'):
298299
for (i, e) in enumerate([e for e in frame.f_valuestack if type(e) is list]):
299300
d['_tmp' + str(i+1)] = e
300301

@@ -318,13 +319,15 @@ def get_user_locals(frame):
318319
if hasattr(frame, 'f_valuestack'):
319320
# print out list objects being built up in Python 2.x list comprehensions
320321
# (which don't have its own special <listcomp> frame, sadly)
321-
for (i, e) in enumerate([e for e in frame.f_valuestack if type(e) is list]):
322-
ret['_tmp' + str(i+1)] = e
322+
if not is_python3:
323+
for (i, e) in enumerate([e for e in frame.f_valuestack
324+
if type(e) is list]):
325+
ret['_tmp' + str(i+1)] = e
323326

324327
# for dict and set comprehensions, which have their own frames:
325328
if f_name.endswith('comp>'):
326329
for (i, e) in enumerate([e for e in frame.f_valuestack
327-
if type(e) in (set, dict)]):
330+
if type(e) in (list, set, dict)]):
328331
ret['_tmp' + str(i+1)] = e
329332

330333
return ret

0 commit comments

Comments
 (0)