John Vandenberg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/144424

Change subject: Fix pickle-ability
......................................................................

Fix pickle-ability

- remove reference to 'sitelock' which was removed in
  I28435df24ef9faff929aceb2095e9fd97c66e33d
- keep _msgcache; it is not worth a separate set of methods just to remove it
- remove commented out code in tests

Change-Id: I689972e677118dec51d4d09e67eff422f75e2d87
---
M pywikibot/site.py
M tests/site_tests.py
2 files changed, 0 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/24/144424/1

diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5c28490..1791ca2 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -695,19 +695,6 @@
                         return APISite(site['code'], site['code'])
         raise ValueError("Cannot parse a site out of %s." % dbname)
 
-    def __getstate__(self):
-        """ Remove Lock based classes before pickling """
-        new = super(APISite, self).__getstate__()
-        del new['sitelock']
-        del new['_msgcache']
-        return new
-
-    def __setstate__(self, attrs):
-        """ Restore things removed in __getstate__ """
-        super(APISite, self).__setstate__(attrs)
-        self.sitelock = threading.Lock()
-        self._msgcache = {}
-
     def _generator(self, gen_class, type_arg=None, namespaces=None,
                    step=None, total=None, **args):
         """Convenience method that returns an API generator.
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 5e2cdc2..af13600 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -999,12 +999,7 @@
 
     def testPickleAbility(self):
         import pickle
-        #fam = pywikibot.site.Family('wikipedia')
-        #site = pywikibot.Site('en', fam)
-        #pywikibot.output(site.family.__dict__)
-        #pickle.dumps(site)
         site = pywikibot.Site('en', 'wikipedia')
-        #pywikibot.output(site.family.__dict__)
         pickle.dumps(site)
         self.assertTrue(True)  # No exception thrown!
 

-- 
To view, visit https://gerrit.wikimedia.org/r/144424
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I689972e677118dec51d4d09e67eff422f75e2d87
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to