Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Fix bug where snowballstemmer chokes on Unicode word #264

Merged
merged 3 commits into from
Jun 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Bug Fixes

* Fixed an issue where the ``--source`` flag would result in improperly
spaced output (#256, #257, #260).
* Fixed an issue where if a first word in a docstring had Unicode characters
and the docstring was not a unicode string, an exception would be raised
(#258, #264).


2.0.0 - April 18th, 2017
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import with_statement
import os
from setuptools import setup

# Do not update the version manually - it is managed by `bumpversion`.
Expand Down
9 changes: 8 additions & 1 deletion src/pydocstyle/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,14 @@ def check_imperative_mood(self, function, docstring): # def context
if check_word in IMPERATIVE_BLACKLIST:
return violations.D401b(first_word)

correct_form = IMPERATIVE_VERBS.get(stem(check_word))
try:
correct_form = IMPERATIVE_VERBS.get(stem(check_word))
except UnicodeDecodeError:
# This is raised when the docstring contains unicode
# characters in the first word, but is not a unicode
# string. In which case D302 will be reported. Ignoring.
return

if correct_form and correct_form != check_word:
return violations.D401(
correct_form.capitalize(),
Expand Down
5 changes: 5 additions & 0 deletions src/tests/test_cases/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ def double_quotes_backslash_uppercase():
def unicode_unmarked():
"""Юникод."""

@expect('D302: Use u""" for Unicode docstrings')
def first_word_has_unicode_byte():
"""あy."""


@expect("D400: First line should end with a period (not 'y')")
def lwnlkjl():
Expand Down Expand Up @@ -376,5 +380,6 @@ def bad_decorated_function():
"""Bad (E501) but decorated"""
pass


expect(os.path.normcase(__file__ if __file__[-1] != 'c' else __file__[:-1]),
'D100: Missing docstring in public module')
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ envlist = py27, py33, py34, py35, pypy, docs
setenv =
LANG=C
LC_ALL=C
commands = py.test --pep8 --cache-clear -v src/tests
commands = py.test --pep8 --cache-clear -vv src/tests
deps =
-rrequirements/runtime.txt
-rrequirements/tests.txt
Expand Down