118 :rtype: Package object
119 """
120
121 for d in pkg_resources.working_set:122 if d.key == _id.split('==')[0]:
123 return self.__make_package_pipdist(d)
124
56 p.description = dist['summary']
57 p.created = dist['created']
58 importlib.reload(pkg_resources)
59 for d in pkg_resources.working_set: 60 if d.key == p.name:
61 p.is_installed = True
62 p.installed_version = d.version
A non-iterable value is being used in an iterating context, For example, a non-iterable value being passed into a for
loop. This will raise a TypeError
.
Using a non-iterable as object in a loop.
def fx(val=None):
return val
seq = fx()
for val in seq:
print(val)
Because seq
would be None
which is not an iterable, this code snippet will raise an error.
Make sure only an iterable is passed to the iterator.
In our example, tweaking fx
to always return an iterable will fix the problem:
def fx(val=None):
val = val or []
return val
seq = fx()
for val in seq:
print(val)