Fixes exception in django cause by long iter check (#443)

* Fixes exception in django cause by long iter check

* Fix linter error
This commit is contained in:
Karthik Nadig 2018-05-30 15:21:31 -07:00 committed by GitHub
parent 63130cd36e
commit 0866c0c830
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,11 +27,15 @@ class SafeRepr(object):
set_info = (set, '{', '}', False)
frozenset_info = (frozenset, 'frozenset({', '})', False)
int_types = (int,)
long_iter_types = (list, tuple, bytearray, range,
dict, set, frozenset)
else:
string_types = (str, unicode)
set_info = (set, 'set([', '])', False)
frozenset_info = (frozenset, 'frozenset([', '])', False)
int_types = (int, long) # noqa
long_iter_types = (list, tuple, bytearray, xrange,
dict, set, frozenset, buffer) # noqa
# Collection types are recursively iterated for each limit in
# maxcollection.
@ -125,6 +129,12 @@ class SafeRepr(object):
if not hasattr(obj, '__iter__'):
return False
# If it's not an instance of these collection types then it
# is fine. Note: this is a fix for
# https://github.com/Microsoft/ptvsd/issues/406
if not isinstance(obj, self.long_iter_types):
return False
# Iterable is its own iterator - this is a one-off iterable
# like generator or enumerate(). We can't really count that,
# but repr() for these should not include any elements anyway,