False negatives don't matter much - users in Eclipse will still see 'u'. We
want to avoid false positives, i.e. trying to display µ when we can't do
so. I think using sys.stdout.encoding is an improvement for all the users
where it is set. But if you're not sure, leave it, and we'll do it in a
separate pull request.


On 3 February 2013 12:59, JanSchulz <notifications@github.com> wrote:

> In IPython/core/magics/execution.py:
>
> > @@ -1091,3 +1071,43 @@ def parse_breakpoint(text, current_file):
> >          return current_file, int(text)
> >      else:
> >          return text[:colon], int(text[colon+1:])
> > +
> > +def _format_time(timespan, precision=3):
> > +    """Formats the timespan in a human readable form"""
> > +    import math
> > +    # XXX: Unfortunately the unicode 'micro' symbol can cause problems in
> > +    # certain terminals.  Until we figure out a robust way of
> > +    # auto-detecting if the terminal can deal with it, use plain 'us' for
> > +    # microseconds.  I am really NOT happy about disabling the proper
> > +    # 'micro' prefix, but crashing is worse... If anyone knows what the
> > +    # right solution for this is, I'm all ears...
>
> I just read https://bugs.launchpad.net/ipython/+bug/348466 And I'm not
> sure what happens here: if some user has the terminal encoding set to
> ascii, it will result in an unicode error.
>
> For example eclipse set the default stdout encoding in the embedded
> console to None but print works...:
>
> >>> import sys>>> print(sys.stdout.encoding)None>>> print(u'µ'.encode(sys.stdout.encoding))Traceback (most recent call last):
>   File "<console>", line 1, in <module>TypeError: encode() argument 1 must be string, not None>>> print(u'µ')µ
>
> I think the only "working" solution would be to try to print a "µ" and if
> hat fails use "u" instead, but I've no idea how to do that without actually
> printing a char to the console...
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/ipython/ipython/pull/2855/files#r2870793>.
>
>