Fix crash when the image description is missing for an image containing non-ascii characters

title is already unicode, so we shouldn't need to decode it (and don't in generateXMLDump).
pull/442/head
Pokechu22 2 years ago
parent 25329be008
commit cad7260d7c

@ -1515,8 +1515,8 @@ def generateImageDump(config={}, other={}, images=[], start='', session=None):
imagefile.write(r.content)
imagefile.close()
# saving description if any
title = u'Image:%s' % (filename)
try:
title = u'Image:%s' % (filename)
if config['xmlrevisions'] and config['api'] and config['api'].endswith("api.php"):
r = session.get(config['api'] + u"?action=query&export&exportnowrap&titles=%s" % title)
xmlfiledesc = r.text
@ -1529,7 +1529,7 @@ def generateImageDump(config={}, other={}, images=[], start='', session=None):
xmlfiledesc = ''
logerror(
config=config,
text=u'The page "%s" was missing in the wiki (probably deleted)' % (title.decode('utf-8'))
text=u'The page "%s" was missing in the wiki (probably deleted)' % title
)
f = open('%s/%s.desc' % (imagepath, filename2), 'w')

Loading…
Cancel
Save