diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2012-03-25 00:21:50 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-03-25 00:21:50 -0400 |
commit | 6fd70326cce88970fb651ee29948c2f37792bc54 (patch) | |
tree | 675f77d865e1988c1c35325b7047ae0ebd60b1d7 /coverage/backward.py | |
parent | cfa0e6044634aadb62c97a3920e60fb79fe4b6b3 (diff) | |
download | python-coveragepy-6fd70326cce88970fb651ee29948c2f37792bc54.tar.gz |
Remove obsolete code paths.
Diffstat (limited to 'coverage/backward.py')
-rw-r--r-- | coverage/backward.py | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index 236bef8..637a597 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -79,26 +79,19 @@ if sys.version_info >= (3, 0): try: open_source = tokenize.open # pylint: disable=E1101 except AttributeError: - try: - detect_encoding = tokenize.detect_encoding # pylint: disable=E1101 - except AttributeError: - assert 3 == 4 - def open_source(fname): - """Open a source file the best way.""" - return open(fname, "rU") - else: - from io import TextIOWrapper - # Copied from the 3.2 stdlib: - def open_source(fname): - """Open a file in read only mode using the encoding detected by - detect_encoding(). - """ - buffer = open(fname, 'rb') - encoding, _ = detect_encoding(buffer.readline) - buffer.seek(0) - text = TextIOWrapper(buffer, encoding, line_buffering=True) - text.mode = 'r' - return text + from io import TextIOWrapper + detect_encoding = tokenize.detect_encoding # pylint: disable=E1101 + # Copied from the 3.2 stdlib: + def open_source(fname): + """Open a file in read only mode using the encoding detected by + detect_encoding(). + """ + buffer = open(fname, 'rb') + encoding, _ = detect_encoding(buffer.readline) + buffer.seek(0) + text = TextIOWrapper(buffer, encoding, line_buffering=True) + text.mode = 'r' + return text else: def open_source(fname): """Open a source file the best way.""" |