From 1973042c8cac74bcef0dadac245f9477c82f065d 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/codeunit.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'coverage/codeunit.py') diff --git a/coverage/codeunit.py b/coverage/codeunit.py index f54bda5e..55f44a24 100644 --- a/coverage/codeunit.py +++ b/coverage/codeunit.py @@ -1,8 +1,8 @@ """Code unit (module) handling for Coverage.""" -import glob, os, tokenize +import glob, os -from coverage.backward import string_class, StringIO +from coverage.backward import open_source, string_class, StringIO from coverage.misc import CoverageException @@ -104,10 +104,7 @@ class CodeUnit(object): """Return an open file for reading the source of the code unit.""" if os.path.exists(self.filename): # A regular text file: open it. - if hasattr(tokenize, 'open'): # Python 3.2 and later - return tokenize.open(self.filename) - else: - return open(self.filename) + return open_source(self.filename) # Maybe it's in a zip file? source = self.file_locator.get_zip_data(self.filename) -- cgit v1.2.1