Skip to content

Commit

Permalink
Tweak container contents viewing (Bug #55)
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Aug 12, 2015
1 parent 824393c commit a123105
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions pudb/var_view.py
Expand Up @@ -323,24 +323,29 @@ def walk_value(self, prefix, label, value, id_path=None, attr_prefix=None):

# containers --------------------------------------------------
key_it = None

try:
l = len(value)
if PY3:
key_it = value.keys()
else:
key_it = value.iterkeys()
except:
pass
else:

if key_it is None:
try:
value[0]
except IndexError:
key_it = []
l = len(value)
except:
pass
else:
key_it = xrange(l)

try:
key_it = value.iterkeys()
except:
pass
try:
value[0]
except IndexError:
key_it = []
except:
pass
else:
key_it = xrange(l)

if key_it is not None:
cnt = 0
Expand Down

2 comments on commit a123105

@asmeurer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't tell from the diff. Is the xrange thing Python 3 safe?

@inducer
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The xrange is imported for pudb's py3compat module, so yes.

Please sign in to comment.