diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-05-17 22:53:02 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-05-17 22:53:02 -0400 |
commit | 6a7183dafc2b2ceba83527ecbdb485589ffc45c1 (patch) | |
tree | 2b35ef45daface6ed34d35fa53325dd183165472 /coverage/phystokens.py | |
parent | e4e17518c99d4503c513410d164f28723968bdb7 (diff) | |
download | python-coveragepy-6a7183dafc2b2ceba83527ecbdb485589ffc45c1.tar.gz |
Use more @contract, less assert
Diffstat (limited to 'coverage/phystokens.py')
-rw-r--r-- | coverage/phystokens.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/coverage/phystokens.py b/coverage/phystokens.py index 587ec1c..1bc6330 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] |