Skip to content

IndexError: list index out of range when used with jaraco.modb and unpickling an object with references to multiple Queue objects #74

@dichotomy

Description

@dichotomy

I receive the following error when trying to Unpickle an object that contains references to multiple Queue objects:

Traceback (most recent call last):
File "./jtest.py", line 24, in
tobj2= jaraco.modb.decode(result)
File "/usr/local/lib/python2.7/dist-packages/jaraco.modb-3.1-py2.7.egg/jaraco/modb/init.py", line 66, in decode
return Unpickler().restore(value)
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 76, in restore
File "/usr/local/lib/python2.7/dist-packages/jaraco.modb-3.1-py2.7.egg/jaraco/modb/init.py", line 39, in _restore
restored = super(Unpickler, self)._restore(obj)
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 99, in _restore
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 129, in _restore_object
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 155, in _restore_object_instance
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 164, in _restore_object_instance_variables
File "/usr/local/lib/python2.7/dist-packages/jaraco.modb-3.1-py2.7.egg/jaraco/modb/init.py", line 39, in _restore
restored = super(Unpickler, self)._restore(obj)
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 99, in _restore
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 129, in _restore_object
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 155, in _restore_object_instance
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 164, in _restore_object_instance_variables
File "/usr/local/lib/python2.7/dist-packages/jaraco.modb-3.1-py2.7.egg/jaraco/modb/init.py", line 39, in _restore
restored = super(Unpickler, self)._restore(obj)
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 99, in _restore
File "build/bdist.linux-x86_64/egg/jsonpickle/unpickler.py", line 102, in _restore_id
IndexError: list index out of range

Test code to reproduce:
import Queue

class MyTest(object):

   def __init__(self):
       self.queue_obj1 = Queue.Queue()
       self.queue_obj2 = Queue.Queue()

if name == "main":
import Queue
from pymongo import MongoClient
import jaraco.modb
database = "testing"
client = MongoClient()
db = client[database]
col = db["test"]
tobj = MyTest()
json_obj = jaraco.modb.encode(tobj)
obj_id = col.save(json_obj)
result = col.find_one(obj_id)
tobj2= jaraco.modb.decode(result)
print type(tobj)
print type(tobj2)

The error does not occur when only one Queue object is referenced in the MyTest() class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions