Skip to content
Permalink
Browse files

Use defensive programming

  • Loading branch information
Juanjo Conti
Juanjo Conti committed Aug 31, 2015
1 parent ca78c3b commit bfe8186a733fd5e8eb9643fd9ada3a78e31a7c34
Showing with 11 additions and 4 deletions.
  1. +11 −4 nikola/plugins/command/import_wordpress.py
@@ -337,8 +337,11 @@ def show_info_about_mising_module(modulename):
# Add tag redirects
for tag in self.all_tags:
try:
tag_str = tag.decode('utf8')
except (AttributeError, UnicodeEncodeError):
if isinstance(tag, utils.bytes_str):
tag_str = tag.decode('utf8', 'replace')
else:
tag_str = tag
except AttributeError:
tag_str = tag
tag = utils.slugify(tag_str)
src_url = '{}tag/{}'.format(self.context['SITE_URL'], tag)
@@ -760,8 +763,12 @@ def import_postpage_item(self, item, wordpress_namespace, out_folder=None, attac
path = unquote(parsed.path.strip('/'))

try:
path = path.decode('utf8')
except (AttributeError, UnicodeEncodeError):
if isinstance(path, utils.bytes_str):
path = path.decode('utf8', 'replace')
else:
path = path
except AttributeError:
pdb.set_trace()
pass

# Cut out the base directory.

0 comments on commit bfe8186

Please sign in to comment.
You can’t perform that action at this time.