Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError on certain queries #5

Open
rblakemesser opened this issue Feb 3, 2014 · 1 comment
Open

TypeError on certain queries #5

rblakemesser opened this issue Feb 3, 2014 · 1 comment

Comments

@rblakemesser
Copy link

Greetings! I think I found a bug--

Try this:

import wikitools
file_query = {'action': 'query',
'titles': u'Image:MLK and Malcolm X USNWR cropped.jpg',
'prop': 'imageinfo',
'iiprop': 'extmetadata'}

file_request = wikitools.api.APIRequest(site, file_query)
query_result = file_request.query() # throws TypeError

It has something to do with api.py around line 289-- you use sets to quickly de-dupe some list(s), but this query tries to dedupe a list of dicts in that block of code, throwing a TypeError because dicts are unhashable.

@bkfunk
Copy link

bkfunk commented May 11, 2014

I think I'm getting a similar problem, only mine is on line 300 of api.py:

 <ipython-input-281-2e9a04f51cbe> in get_revisions(title, rvstartid, rvendid, rvcontinue)
      12         params['rvcontinue'] = rvcontinue
      13     request = api.APIRequest(site, params)
 ---> 14     result = request.query()
      15     return result

 /Users/bkarfunkel/anaconda/lib/python2.7/site-packages/wikitools/api.pyc in query(self,    querycontinue)
     154                         raise APIError(data['error']['code'], data['error']['info'])
     155                 if 'query-continue' in data and querycontinue:
 --> 156                         data = self.__longQuery(data)
     157                 return data
     158 

 /Users/bkarfunkel/anaconda/lib/python2.7/site-packages/wikitools/api.pyc in __longQuery(self, initialdata)
     208                         res = req.query(False)
     209                         for type in possiblecontinues:
 --> 210                                 total = resultCombine(type, total, res)
     211                         if 'query-continue' in res:
     212                                 numkeys = len(res['query-continue'].keys())

 /Users/bkarfunkel/anaconda/lib/python2.7/site-packages/wikitools/api.pyc in resultCombine(type, old, new)
     298                                         continue
     299                                 else: # Need to check for possible duplicates for some, this is faster than just iterating over new and checking for dups in ret
 --> 300                                         retset = set([tuple(entry.items()) for entry in ret['query']['pages'][key][type]])
     301                                         newset = set([tuple(entry.items()) for entry in new['query']['pages'][key][type]])
     302                                         retset.update(newset)

 TypeError: unhashable type: 'list'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants