summaryrefslogtreecommitdiff
path: root/coverage/phystokens.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/phystokens.py')
-rw-r--r--coverage/phystokens.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/coverage/phystokens.py b/coverage/phystokens.py
index 587ec1c6..1bc6330d 100644
--- a/coverage/phystokens.py
+++ b/coverage/phystokens.py
@@ -151,6 +151,7 @@ generate_tokens = CachedTokenizer().generate_tokens
COOKIE_RE = re.compile(r"^\s*#.*coding[:=]\s*([-\w.]+)", flags=re.MULTILINE)
+@contract(source='bytes')
def _source_encoding_py2(source):
"""Determine the encoding for `source`, according to PEP 263.
@@ -247,6 +248,7 @@ def _source_encoding_py2(source):
return default
+@contract(source='bytes')
def _source_encoding_py3(source):
"""Determine the encoding for `source`, according to PEP 263.
@@ -257,7 +259,6 @@ def _source_encoding_py3(source):
string: the name of the encoding.
"""
- assert isinstance(source, bytes)
readline = iternext(source.splitlines(True))
return tokenize.detect_encoding(readline)[0]