From cd11ab654d784a1612863cdf419764482c8dc3bb Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 25 Mar 2012 00:21:50 -0400 Subject: Remove obsolete code paths. --- coverage/backward.py | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'coverage/backward.py') diff --git a/coverage/backward.py b/coverage/backward.py index 236bef8e..637a5976 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.""" -- cgit v1.2.1