<div dir="ltr">I think I have a good idea how to fix this.  in lldbsuite.support we can add unicode_file.py.  Make it implement the file interface so that it looks just like an io object so it can be used with print(file=), and with the 'with' keyword, etc.  Make the open method call io.open() with an encoding, then make the read / write methods do a python version check before sending the read / write call to the underlying io object.  Then you basically just do<div><br></div><div>self.session_file = unicode_file.open(path, mode='w', encoding='utf-8')</div><div><br></div><div>and then you can write however you want.</div><div><br></div><div>print(u"", self.session_file)</div><div>print("", self.session_file)</div><div><br></div><div>will both work in any python version</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 28, 2016 at 10:21 AM Tamas Berghammer <<a href="mailto:tberghammer@google.com">tberghammer@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">tberghammer added a comment.<br>
<br>
The traceback calculation is done inside unittest2 so I think we shouldn't change it and we don't have access to the session variable either.<br>
<br>
<br>
<a href="http://reviews.llvm.org/D16680" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16680</a><br>
<br>
<br>
<br>
</blockquote></div>