https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
Bug ID: 62094 Summary: Cannot pickle Page objects Product: Pywikibot Version: core (2.0) Hardware: All OS: All Status: NEW Severity: major Priority: Unprioritized Component: General Assignee: Pywikipedia-bugs@lists.wikimedia.org Reporter: info@gno.de Web browser: --- Mobile Platform: ---
import pickle import pywikibot
p = pywikibot.Page(pywikibot.Site('de'), 'user:Xqt/Test') laFile = open('la.data', 'wb') pickle.dump(p, laFile) laFile.close()
causes the following error in core whereas it works in compat:
c:\Pywikipedia\core>pwb.py la2 Traceback (most recent call last): File "C:\Pywikipedia\core\pwb.py", line 143, in <module> run_python_file(fn, argv, argvu) File "C:\Pywikipedia\core\pwb.py", line 67, in run_python_file exec(compile(source, filename, "exec"), main_mod.__dict__) File "C:\Pywikipedia\core\scripts\la2.py", line 9, in <module> pickle.dump(p, laFile) File "C:\Python27\lib\pickle.py", line 1370, in dump Pickler(file, protocol).dump(obj) File "C:\Python27\lib\pickle.py", line 224, in dump self.save(obj) File "C:\Python27\lib\pickle.py", line 331, in save self.save_reduce(obj=obj, *rv) File "C:\Python27\lib\pickle.py", line 419, in save_reduce save(state) File "C:\Python27\lib\pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "C:\Python27\lib\pickle.py", line 649, in save_dict self._batch_setitems(obj.iteritems()) File "C:\Python27\lib\pickle.py", line 663, in _batch_setitems save(v) File "C:\Python27\lib\pickle.py", line 331, in save self.save_reduce(obj=obj, *rv) File "C:\Python27\lib\pickle.py", line 419, in save_reduce save(state) File "C:\Python27\lib\pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "C:\Python27\lib\pickle.py", line 649, in save_dict self._batch_setitems(obj.iteritems()) File "C:\Python27\lib\pickle.py", line 663, in _batch_setitems save(v) File "C:\Python27\lib\pickle.py", line 331, in save self.save_reduce(obj=obj, *rv) File "C:\Python27\lib\pickle.py", line 419, in save_reduce save(state) File "C:\Python27\lib\pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "C:\Python27\lib\pickle.py", line 649, in save_dict self._batch_setitems(obj.iteritems()) File "C:\Python27\lib\pickle.py", line 663, in _batch_setitems save(v) File "C:\Python27\lib\pickle.py", line 306, in save rv = reduce(self.proto) File "C:\Python27\lib\copy_reg.py", line 70, in _reduce_ex raise TypeError, "can't pickle %s objects" % base.__name__ TypeError: can't pickle lock objects <type 'exceptions.TypeError'> CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c to abort
c:\Pywikipedia\core>