summaryrefslogtreecommitdiff
path: root/coverage/python.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-03-14 13:40:14 -0400
committerNed Batchelder <ned@nedbatchelder.com>2017-03-14 13:40:14 -0400
commit13ed869c6be652f0b7729cebb26583d03c7ab12a (patch)
tree4081c110d336d83ccb0f2d83c004a249a46e3c3f /coverage/python.py
parente626cb5cf730217fbedc3d06b80215c09bbe7013 (diff)
downloadpython-coveragepy-git-13ed869c6be652f0b7729cebb26583d03c7ab12a.tar.gz
Minimal IronPython support.
IronPython is weird: 2.7.7 has "str is unicode", and unicode.encode produces unicode! f_lasti is missing, and frame globals are missing.
Diffstat (limited to 'coverage/python.py')
-rw-r--r--coverage/python.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/coverage/python.py b/coverage/python.py
index f75be60a..9418c386 100644
--- a/coverage/python.py
+++ b/coverage/python.py
@@ -26,7 +26,13 @@ def read_python_source(filename):
"""
with open(filename, "rb") as f:
- return f.read().replace(b"\r\n", b"\n").replace(b"\r", b"\n")
+ source = f.read()
+
+ if env.IRONPYTHON:
+ # IronPython reads Unicode strings even for "rb" files.
+ source = bytes(source)
+
+ return source.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
@contract(returns='unicode')