[augeas-devel] Python 3 support for Augeas?

David Lutterkort lutter at redhat.com
Tue Apr 6 16:13:43 UTC 2010


On Mon, 2010-04-05 at 14:43 -0400, David Malcolm wrote:
> To what extent has anyone tried python-augeas with Python 3?

I've never tried it (since my python-fu is weak)

>    default = int(a.get("/files/etc/grub.conf/default"))
> TypeError: int() argument must be a string or a number, not 'NoneType'

The get in augeas.py is slightly wrong: aug_get return 1 if it found
exactly one entry in the tree for the given path, 0 if there is no
entry, and -1 if the path expression is invalid, or if more than one
entry matches the path expression.

Even if there is a single matching node in the tree, the associated
value can still be NULL (though that won't be the case for your example,
assuming you start with a valid /etc/grub.conf)

> This is probably fixable, but a deeper issue is:  what is the
> expectation around the encoding of a string value in augeas?  Is it a
> collection of bytes, or is it a unicode string with some encoding?

It's a collection of bytes; in practice, it's an ASCII string. Augeas
doesn't do anything clever with string encoding - it just copies bits
and pieces of the underlying files as byte arrays into the tree.
Internally, Augeas uses the C locale for all locale-sensitive
operations, like regexp matching.

> (it also suggests that the selftests may need to be stricter, given how
> far they seemed to get, whilst the code I'd generated was apparently
> totally broken :( )

Seems the tests are not testing corner cses, like the get of a
non-existing entry in the tree.

David





More information about the augeas-devel mailing list