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>
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
--- Comment #1 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- The reason for this is because Site objects are not pickle-able.
import pywikibot, pickle s=pywikibot.Site() f=pickle.dumps(s)
Traceback (most recent call last): [same traceback here] File "/home/km/python/lib64/python2.7/copy_reg.py", line 70, in _reduce_ex raise TypeError, "can't pickle %s objects" % base.__name__ TypeError: can't pickle lock objects
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
--- Comment #2 from Gerrit Notification Bot gerritadmin@wikimedia.org --- Change 131032 had a related patch set uploaded by Legoktm: Remove unused APISite.sitelock
https://gerrit.wikimedia.org/r/131032
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
Gerrit Notification Bot gerritadmin@wikimedia.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |PATCH_TO_REVIEW
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
--- Comment #3 from Gerrit Notification Bot gerritadmin@wikimedia.org --- Change 131033 had a related patch set uploaded by Legoktm: Make Site objects pickle-able
https://gerrit.wikimedia.org/r/131033
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
--- Comment #4 from Gerrit Notification Bot gerritadmin@wikimedia.org --- Change 131032 merged by jenkins-bot: Remove unused APISite.sitelock
https://gerrit.wikimedia.org/r/131032
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
--- Comment #5 from xqt info@gno.de --- That bug is still there after the patch.
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
Merlijn van Deen valhallasw@arctus.nl changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|PATCH_TO_REVIEW |NEW CC| |valhallasw@arctus.nl
--- Comment #6 from Merlijn van Deen valhallasw@arctus.nl --- Yes:
"There's still a lock in BaseSite, but this gets us closer to being able to pickle Pages."
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
--- Comment #7 from Gerrit Notification Bot gerritadmin@wikimedia.org --- Change 131033 merged by jenkins-bot: Make Site objects pickle-able
https://gerrit.wikimedia.org/r/131033
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
--- Comment #8 from Gerrit Notification Bot gerritadmin@wikimedia.org --- Change 144698 had a related patch set uploaded by Legoktm: Page pickling test
https://gerrit.wikimedia.org/r/144698
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
Gerrit Notification Bot gerritadmin@wikimedia.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |PATCH_TO_REVIEW
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
--- Comment #9 from Gerrit Notification Bot gerritadmin@wikimedia.org --- Change 144698 merged by jenkins-bot: Page pickling test
https://gerrit.wikimedia.org/r/144698
https://bugzilla.wikimedia.org/show_bug.cgi?id=62094
John Mark Vandenberg jayvdb@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|PATCH_TO_REVIEW |RESOLVED Resolution|--- |FIXED
--- Comment #10 from John Mark Vandenberg jayvdb@gmail.com --- Still waiting for review of the unit test, but the bugs were all solved days ago.
pywikipedia-bugs@lists.wikimedia.org