hercules-team / python-augeas

Python bindings for Augeas
GNU Lesser General Public License v2.1
44 stars 31 forks source link

Whether enc() / dec() so necessary. #18

Closed seamus-45 closed 8 years ago

seamus-45 commented 8 years ago

With below code I always get: UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

#!/usr/bin/env python2
# -*- coding: utf-8 -*-

from augeas import Augeas

val = 'Привет'
aug = Augeas()
aug.set('/augeas/load/Desktop/lens','desktop.lns')
aug.set('/augeas/load/Desktop/incl','/tmp/mate-screenshot.desktop')
aug.load()
aug.set('/files/tmp/mate-screenshot.desktop/Desktop Entry/Name',val)
aug.save()

It looks like value is encoded twice. When I declare val = u'Привет' as unicode string error is gone.

But, first example of code works great without enc() function at all. Also there is related issue, which forced me to create a bug report