It's in item 3 from Effective Python, by Brett Slatkin, which goes over having methods that always go to unicode or to byte streams taking either unicode or byte style strings, for both Python 2 and Python 3. Essentially you figure out what you want it to be in, and you write a couple helper routes to go in either the "to unicode" or the "to bytes" direction. It basically looks at the type of the string/bytes you give it, and makes sure it becomes what you need. It's going to assume an encoding like utf-8.
On Mon, Jan 25, 2016 at 9:09 PM, Zachary Turner <ztur...@google.com> wrote: > I'm also not sure why Linux isn't failing. Looking at the documentation > for io.write object, i see this: > > write(*s*) <https://docs.python.org/2/library/io.html#io.TextIOBase.write> > > Write the unicode > <https://docs.python.org/2/library/functions.html#unicode> string *s* to > the stream and return the number of characters written. > So clearly it does have to be a unicode object, and saying > print(self.getvalue(), file=self.session) is clearly NOT printing a unicode > string to the file. > > What's the pattern you're referring to? You can't convert a string to a > unicode without specifying an encoding, and it seems annoying to have to do > that on every single call to print. > > On Mon, Jan 25, 2016 at 8:54 PM Zachary Turner <ztur...@google.com> wrote: > >> sorry, yea I stuck around for a while after that patch waiting for >> emails, but nothing came through. Please revert in the meantime, I'll work >> on a fix tomorrow. >> >> On Mon, Jan 25, 2016 at 8:52 PM Todd Fiala via lldb-dev < >> lldb-dev@lists.llvm.org> wrote: >> >>> I think I see what happened w/r/t why no emails when out when the build >>> went heavy red. (Well they went out internally, but not externally). When >>> I made the change on Friday to improve the workflow for the Green Dragon OS >>> X builder and test output, I switched email over to the builder step, which >>> doesn't know anything about who made which changes. So it didn't know who >>> to put on the blame list for the broken build. Drats, I'll have to figure >>> that out. >>> >>> I'd really prefer to have all those stages happening in one build step >>> to keep it clear what's going on. >>> >>> On Mon, Jan 25, 2016 at 8:25 PM, Todd Fiala <todd.fi...@gmail.com> >>> wrote: >>> >>>> Well our whole test suite just stopped running, so yes. >>>> >>>> On Mon, Jan 25, 2016 at 6:58 PM, Enrico Granata <egran...@apple.com> >>>> wrote: >>>> >>>>> >>>>> On Jan 25, 2016, at 6:48 PM, Todd Fiala via lldb-dev < >>>>> lldb-dev@lists.llvm.org> wrote: >>>>> >>>>> Not sure exactly what it is, but all the tests are failing due to some >>>>> bad assumptions of unicode vs. str on Python 2 vs. 3 if I had to guess. >>>>> >>>>> >>>>> Author: zturner >>>>> Date: Mon Jan 25 18:59:42 2016 >>>>> New Revision: 258759 >>>>> >>>>> URL: http://llvm.org/viewvc/llvm-project?rev=258759&view=rev >>>>> Log: >>>>> Write the session log file in UTF-8. >>>>> >>>>> Previously we were writing in the default encoding, which depends >>>>> on the operating system and is not guaranteed to be unicode aware. >>>>> On Python 3, this would lead to a situation where writing unicode >>>>> text to the log file generates an exception. The fix here is to >>>>> write session logs using the proper encoding, which incidentally >>>>> fixes another test, so xfail is removed from that. >>>>> >>>>> sounds like a likely culprit from what you’re saying >>>>> >>>>> I am not going to be able to look at details on that, but here's a >>>>> link to the log on the OS X builder: >>>>> >>>>> >>>>> Do you want me to revert? >>>>> >>>>> http://lab.llvm.org:8080/green/job/lldb_build_test/16166/console >>>>> >>>>> -- >>>>> -Todd >>>>> _______________________________________________ >>>>> lldb-dev mailing list >>>>> lldb-dev@lists.llvm.org >>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev >>>>> >>>>> >>>>> >>>>> Thanks, >>>>> *- Enrico* >>>>> 📩 egranata@.com ☎️ 27683 >>>>> >>>>> >>>> >>>> >>>> -- >>>> -Todd >>>> >>> >>> >>> >>> -- >>> -Todd >>> _______________________________________________ >>> lldb-dev mailing list >>> lldb-dev@lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev >>> >> -- -Todd
_______________________________________________ lldb-dev mailing list lldb-dev@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev