From ffca91900b9675b1f0edd5201955a40a62c6671f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 31 Oct 2015 18:20:48 -0400 Subject: Force XML files to be UTF8 on Python 3. --- coverage/control.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'coverage/control.py') diff --git a/coverage/control.py b/coverage/control.py index b7ba055d..0a5ccae6 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -1047,7 +1047,10 @@ class Coverage(object): output_dir = os.path.dirname(self.config.xml_output) if output_dir and not os.path.isdir(output_dir): os.makedirs(output_dir) - outfile = open(self.config.xml_output, "w") + open_kwargs = {} + if env.PY3: + open_kwargs['encoding'] = 'utf8' + outfile = open(self.config.xml_output, "w", **open_kwargs) file_to_close = outfile try: reporter = XmlReporter(self, self.config) -- cgit v1.2.1