From 2e37d40a9eceff624d27e25fe352c7e1855641d1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 30 Jan 2011 09:42:00 -0500 Subject: Isolate the open/tokenize.open distinction into backward.py --- coverage/backward.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'coverage/backward.py') diff --git a/coverage/backward.py b/coverage/backward.py index 425bcc6..23c0a56 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -71,3 +71,13 @@ try: import configparser except ImportError: import ConfigParser as configparser + +# Python 3.2 provides `tokenize.open`, the best way to open source files. +try: + import tokenize + open_source = tokenize.open +except AttributeError: + def open_source(fname): + """Open a source file the best way.""" + return open(fname, "rU") + -- cgit v1.2.1