Skip to content

Commit

Permalink
Convert docstring to unicode before parsing them (#103)
Browse files Browse the repository at this point in the history
Use the Unicode sandwich: bytes on the outside, Unicode on the inside.
  • Loading branch information
elyezer authored and omaciel committed Jun 14, 2016
1 parent bc3585f commit df327d6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions testimony/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,21 @@ def _parse_docstring(self):
return

# Create the contexts
tags, unexpected_tags, _ = self._parse_tags(
ast.get_docstring(self.module_def))
module_docstring = ast.get_docstring(self.module_def)
if module_docstring and not isinstance(module_docstring, type(u'')):
module_docstring = module_docstring.decode('utf-8')
class_docstring = ast.get_docstring(self.parent_class_def)
if class_docstring and not isinstance(class_docstring, type(u'')):
class_docstring = class_docstring.decode('utf-8')
function_docstring = self.docstring
if function_docstring and not isinstance(
function_docstring, type(u'')):
function_docstring = function_docstring.decode('utf-8')
tags, unexpected_tags, _ = self._parse_tags(module_docstring)
class_tags, class_unexpected_tags, _ = self._parse_tags(
ast.get_docstring(self.parent_class_def))
class_docstring)
function_tags, function_unexpected_tags, self.skipped_lines = (
self._parse_tags(self.docstring))
self._parse_tags(function_docstring))

# Update context dictionaries
tags.update(class_tags)
Expand Down

0 comments on commit df327d6

Please sign in to comment.