'ascii' codec can't decode

Posted on
Sat Oct 03, 2020 2:08 am
davinci offline
Posts: 353
Joined: Feb 14, 2015

'ascii' codec can't decode

Code: Select all
 Script Error                    Klima überprüfen.py: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)
   Script Error                    Exception Traceback (most recent call shown last):

     Klima überprüfen.py, line 58, at top level
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)


The problem is "°C".

Why ist this still a problem?
How can I fix this globally?

Posted on
Sat Oct 03, 2020 6:09 am
DaveL17 offline
User avatar
Posts: 5900
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: 'ascii' codec can't decode

davinci wrote:
Code: Select all
 Script Error                    Klima überprüfen.py: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)
   Script Error                    Exception Traceback (most recent call shown last):

     Klima überprüfen.py, line 58, at top level
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)


The problem is "°C".

Why ist this still a problem?
How can I fix this globally?

Unfortunately, you can't fix it globally as it's an issue with Python 2.x. The simplest workaround it to replace all string instances with Unicode. Don't use str() and instead use:

Code: Select all
unicode("This should print ºC without error.")
u"This should print ºC without error."
Unicode prior to Python 3 is a major pain. Smarter people than I can probably explain it better, but the bottom line is that there are more characters possible than can be described by a standard register (it's really just the 'º' that's causing the hiccup). The range is 128 and the character is 194 (OxC2). In Python 3, all strings are Unicode.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Oct 03, 2020 7:31 am
davinci offline
Posts: 353
Joined: Feb 14, 2015

Re: 'ascii' codec can't decode

Thanks. That means a lot of work.

Any indication we will finally get Python 3 in 2020?

Posted on
Sat Oct 03, 2020 7:38 am
FlyingDiver offline
User avatar
Posts: 5321
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: 'ascii' codec can't decode

davinci wrote:
Thanks. That means a lot of work.

Any indication we will finally get Python 3 in 2020?


2020? No way. Won't happen until Apple releases a version of MacOS without Python2 support, I think.

Fixing your issues usually just means changing all ascii strings ("a string") to unicode strings (u"a string"). If you post the actual script we can help more.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Oct 03, 2020 9:48 am
davinci offline
Posts: 353
Joined: Feb 14, 2015

Re: 'ascii' codec can't decode

I have too many scripts. :)

I just remove the ° for now, since I get this message only in case of an extreme temperature.

Will there be the need for changing scripts in python 3?

I don't understand why Indigo is holding out for so long. It is not that Python 2 works flawlessly. Especially outside the US it is not easy with this limitation.

Posted on
Sat Oct 03, 2020 9:55 am
FlyingDiver offline
User avatar
Posts: 5321
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: 'ascii' codec can't decode

davinci wrote:
I don't understand why Indigo is holding out for so long. It is not that Python 2 works flawlessly. Especially outside the US it is not easy with this limitation.


Because Catalina was the first version of MacOS to ship with Python 3. And switching to Python 3 using the native install would mean you couldn't run Indigo on any previous OS versions. Which would exclude a lot of older hardware that runs Indigo just fine, but won't run Catalina. And so on. It's not a simple thing to do.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Oct 03, 2020 10:00 am
DaveL17 offline
User avatar
Posts: 5900
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: 'ascii' codec can't decode

davinci wrote:
I don't understand why Indigo is holding out for so long. It is not that Python 2 works flawlessly. Especially outside the US it is not easy with this limitation.

Matt and Jay can certainly speak for themselves and have address the Python 3 issue before. But a huge part of it is that Indigo must support Python 2 and Python 3 during the transition so that folks don't have their installations completely blow up. Stability is too important to be taken lightly.

There are considerable differences between Python 2 and Python 3 and eventually all scripts and plugins will have to be redone to support the move. Apple is way behind the times with their Python support (it's fairly niche to their overall customer base) and their focus appears to be elsewhere. :(

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests