diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2011-01-30 09:42:00 -0500 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2011-01-30 09:42:00 -0500 |
| commit | 1973042c8cac74bcef0dadac245f9477c82f065d (patch) | |
| tree | 259e51488d1ec5287a8f255f4a08f1436a320c04 /coverage/backward.py | |
| parent | cd2d387ab90f3f07af49f1e045bdae4d8b1f588a (diff) | |
| download | python-coveragepy-git-1973042c8cac74bcef0dadac245f9477c82f065d.tar.gz | |
Isolate the open/tokenize.open distinction into backward.py
Diffstat (limited to 'coverage/backward.py')
| -rw-r--r-- | coverage/backward.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index 425bcc6e..23c0a569 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") + |
