Tuesday, March 15, 2016

Here in summary the problem which locked me for almost one week (#825):

>>> from builtins import str
>>> import xml.etree.ElementTree as ET
>>> a = ET.Element('a')
>>> a.set(str('name'), str('10'))
>>> ET.dump(a)
<a b'name'="b'10'" />

Above output (which of course is invalid XML syntax) comes under Python 2. Under Python 3 it is correct:

<a name="10" />

The explanation is that python-future introduces a special helper class newstr to simulate, under Python 2, the behaviour of Python 3 strings.

But xml.etree.ElementTree doesn’t know about python-future and produces invalid XML when you feed it with such a string.

If you use ElementTree and want to support both 2 and 3, then avoid newstr and use six.text_type instead. After all python-future is a higher-level compatibility layer than six which tries to save you some work.

Because the same problem occured in other places as well, I tried to systematically replace all:

from builtins import str


import six
str = six.text_type

But that was not good. Many doctests now failed again because one advantage of future’s newstr class was to get printed without the “u” in front of the string literal… This example shows that the newstr class is not a useless luxus.

Lino fulfilling your biggest wishes

I have about four customers who are urgently waiting for me advancing with their project. How to chose which one to serve first? Today I used a new technique:

  • I intuitively chose one of them. (Today it was Alexa because I believe that she is the one who is most locked without my progress. The others aren’t less important but they have lots of other things to do as well.)

  • I asked her “What is your biggest wish? (only one, and only from those which I am able to fulfill)”

  • She answered without hesitation: #766. Her non hesitating answer was a confirmation that she was the right candidate to get a wish fulfilled.

  • I worked a few hours on #766 to fullfill her wish, then did a release.

And now I will hopefully sleep well and long.