summaryrefslogtreecommitdiff
path: root/coverage/phystokens.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-05-17 22:53:02 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-05-17 22:53:02 -0400
commit9ac51b10e92e5faee2e0677887dcc536e3924a7f (patch)
tree79215b6d0e81c070e5670025f83677f899872284 /coverage/phystokens.py
parent5291dd2839d5adfe64106501e7f9fe4984cf53ac (diff)
downloadpython-coveragepy-git-9ac51b10e92e5faee2e0677887dcc536e3924a7f.tar.gz
Use more @contract, less assert
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]