builtins: self.outf.write vs trace.note
mbp at canonical.com
Mon Nov 16 23:37:51 GMT 2009
2009/11/17 Gordon Tyler <gordon at doxxx.net>:
>> On the weekend I wrote some code that removes logging and unifies
>> Command.outf with the UIFactory so it should help with some of these
> So the trace module is gone?
No, trace is still there, and is used for reporting crashes or debug
I propose to give two main ways of writing user data to the terminal:
interactions like showing single messages or asking questions will be
through UIFactory methods; sending bulk data (like diff, log) will be
through a method UIFactory.make_output_stream. This will for the text
ui give a wrapped stdout that does encoding and synchronization with
Command.outf is still there, and points to make_output_stream.
>>> Traceback (most recent call last):
>>> File "C:\\Python26\\lib\\logging\\__init__.py", line 791, in emit
>>> stream.write(fs % msg.encode("UTF-8"))
>>> UnicodeDecodeError: \'ascii\' codec can\'t decode byte 0xc3 in position 7:
>>> ordinal not in range(128)
>> I saw some like these too, and they were typically to do with files
>> not having an encoding wrapper when they should.
> I worked around it by changing StringIOWrapper to encode() Unicode strings to the stream's encoding with the 'replace' option, which allows encodings like 'ascii' to handle weird character without throwing exceptions.
> It seemed like a bit of a skanky hack though, so I haven't published it. And seeing as how you're changing a lot of the infrastructure around it, I should wait and see if it fixes itself?
I think so.
>> Since the code you're calling into is changing I probably wouldn't
>> worry about the failure until someone reviews your branch. Thanks for
>> trying it though.
> Are there changes on trunk that I should be merging into my branch? Should I continue with my branch or is it obsolete now?
I'll put my branch up, you could review it, and then maybe merge it
with yours? Or vice versa.
More information about the bazaar