I sometimes get a KeyError when doing something with References
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Storm |
New
|
Undecided
|
Unassigned |
Bug Description
I sometimes get this error:
Traceback (most recent call last):
File "test_failer.py", line 134, in <module>
runtest(store)
File "test_failer.py", line 107, in runtest
c.addQuesti
File "/vagrant/
if self.currentQue
File "/vagrant/
Coalesce(
File "/vagrant/
self.
File "/vagrant/
self.
File "/vagrant/
obj_
File "/vagrant/
self.
File "/vagrant/
local_
File "/vagrant/
raise e
KeyError: ({<storm.
And "sometimes" really means "sometimes." I have a piece of production code (that I'm whittling down) that I can repeatedly run and frequently get that traceback. I suspect it has something to do with weakrefs.
It seems like the problem is that a pair is added to the Store with Store.add_
The following change to store.py prevents the error, but I'm not sure if that's the spot to prevent it:
diff --git a/storm/store.py b/storm/store.py
index 0213073..fa37633 100644
--- a/storm/store.py
+++ b/storm/store.py
@@ -484,6 +484,11 @@ class Store(object):
+ for key, value in self._order.
+ for obj in key:
+ for k, v in obj.items():
+ if type(v) == dict and 'flush_order' in v:
+ v.pop('
# That's not stricly necessary, but prevents getting into bigints.
FWIW the (sqlite) tests all pass with this change in place.