I am getting this error while iterating my class:
ExternalError: TypeError: Sk.builtin.SuspensionError is not a constructor
at TruckDetails.ItemVersion, line 16
Here:
for truck in Trucks(): # this is line 16
[...]
My class is defined like this:
class Trucks:
[...]
def __iter__(self):
self._load_trucks() # the failure is in here
self._iter_index = -1
return self
def __next__(self):
self._iter_index += 1
if self._iter_index >= len(self._trucks):
raise StopIteration
return self._trucks[self._iter_index]
At first I thought the problem was on my iterator, but that seems to be working well. I can iterate my class in Python, and I kind of can iterate it also in Skulpt.
I traced it down to be at this line, called by self._load_trucks
:
print('this is printed')
shipping_date = datetime.strptime(shp_date, '%m-%d-%Y').date()
print('this is not printed')
I replaced the datetime.strptime(shp_date, '%m-%d-%Y').date()
with 'x'
, and the problem disappears from this line, goes through two cycles, then it appears again. Perhaps the self._load_trucks()
is hitting another line with the same problem.
So here are my two questions:
- What is causing this problem and how do I solve it?
- Why is the problem reported on the
for
loop line which uses my iterator which calls a function which callsdatetime.strptime
instead of being reported at thedatetime.strptime
line?