Revision: 6882 Author: nicdumz Date: 2009-05-14 02:59:18 +0000 (Thu, 14 May 2009)
Log Message: ----------- namespaces: Catching KeyError when _default is not defined (issue #2791509)
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2009-05-13 14:40:03 UTC (rev 6881) +++ trunk/pywikipedia/wikipedia.py 2009-05-14 02:59:18 UTC (rev 6882) @@ -3096,8 +3096,13 @@ if ns is None: ns = u'' if ns != nshdr: - dflt = self.site.family.namespace('_default', id) - if dflt == ns: + try: + dflt = self.site.family.namespace('_default', id) + except KeyError: + dflt = None + if dflt is None: + flag = u"is not set, but should be '%s'" % nshdr + elif dflt == ns: flag = u"is set to default ('%s'), but should be '%s'" % (ns, nshdr) elif dflt == nshdr: flag = u"is '%s', but should be removed (default value '%s')" % (ns, nshdr)
pywikipedia-svn@lists.wikimedia.org