Page MenuHomePhabricator

wikidataquery STRING unicode issues
Closed, DeclinedPublic

Description

Looking in wikidataquery.py everything is str(), not unicode(). No problem for most of it except when querying STRING["<some string>"]. If you do that and the string happens to contain a non-ascii character:

query = 'CLAIM[31:3305213] AND CLAIM[195:%s] AND STRING[217:"%s"]' % (instid, metadata.get(idField),)

    data = wd_query.query(wd_queryset)
  File "C:\pywikibot\coredev\pywikibot\data\wikidataquery.py", line 591, in quer
y
    fullQueryString = self.getQueryString(q, labels, props)
  File "C:\pywikibot\coredev\pywikibot\data\wikidataquery.py", line 481, in getQ
ueryString
    qStr = "q=%s" % quote(str(q))
  File "C:\pywikibot\coredev\pywikibot\data\wikidataquery.py", line 107, in __st
r__
    s = bracketIfQuerySet(self.qs[0])
  File "C:\pywikibot\coredev\pywikibot\data\wikidataquery.py", line 105, in brac
ketIfQuerySet
    return str(q)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe3' in position 76:
 ordinal not in range(128)
<type 'exceptions.UnicodeEncodeError'>
CRITICAL: Closing network session.

Pywikibot: [ssh] pywikibot-core.git (f0e0d87, g5686, 2015/06/06, 13:11:19, OUTDA
TED)
Release version: 2.0b3
requests version: 2.4.1
  cacerts: C:\Python27\lib\site-packages\requests\cacert.pem
    certificate test: ok
Python: 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]

Related Objects

StatusSubtypeAssignedTask
DeclinedNone
ResolvedMultichill
DeclinedNone
DeclinedNone

Event Timeline

Multichill raised the priority of this task from to Needs Triage.
Multichill updated the task description. (Show Details)
Multichill subscribed.

WDQ is going to be shut down. No need to spend any time on this.