← Back to team overview

python-quantities-developers team mailing list archive

[Bug 449218] Re: make unit formatting configurable at run time

 

** Changed in: python-quantities
       Status: In Progress => Fix Committed

-- 
make unit formatting configurable at run time
https://bugs.launchpad.net/bugs/449218
You received this bug notification because you are a member of Python
Quantities Development Team, which is subscribed to python-quantities.

Status in Physical Quantities for Python: Fix Committed

Bug description:
Hi quantities devs,

I'm just starting to play around with quantities, and I really like it.

I'm trying to print out some quantities, but I'm getting encoding errors. I compiled quantities without the --no-unicode flag, which seems to be causing problems with my text editor (TextMate). I tried to work around this problem by printing quantity.dimensionality.string. This fix works for superscripts, but fails for the degree symbol. For example: ``print 20 * pq.degC`` fails in my text editor (see error message below).

Was ``dimensionality.string`` intended to make the dimensionality ascii printable? Or is there something else causing my problems (I don't have much experience with character encodings)?

Thanks!
-Tony

Note that this error doesn't occur in the terminal.

System:
Mac OS X 10.5.6
python 2.5.1 (original Leopard install)
numpy 1.3.0
quantities 0.5b2


#------Error message-------
UnicodeDecodeError: ascii, °C, 0, 1, ordinal not in range(128)

function write in codecs.py at line 303
data, consumed = self.encode(object, self.errors)
Warning: It seems that you are trying to print a plain string containing unicode characters. In many contexts, setting the script encoding to UTF-8 and using plain strings with non-ASCII will work, but it is fragile. See also this ticket.

You can fix this by changing the string to a unicode string using the 'u' prefix (e.g. u"foobar").



References