diff options
author | Cédric Bosdonnat <cbosdonnat@suse.com> | 2017-09-05 15:37:33 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cbosdonnat@suse.com> | 2017-09-06 11:20:50 +0200 |
commit | 9f76c63d16a7dcd7cc3f4f2d6ac20e8d978d8c22 (patch) | |
tree | b2fa3877d575b040927095b088d450d442a0dd97 | |
parent | a42c936f607b695780e8a4a289ac6ad945f54391 (diff) | |
download | virt-bootstrap.git-9f76c63d16a7dcd7cc3f4f2d6ac20e8d978d8c22.tar.gz virt-bootstrap.git-9f76c63d16a7dcd7cc3f4f2d6ac20e8d978d8c22.tar.xz virt-bootstrap.git-9f76c63d16a7dcd7cc3f4f2d6ac20e8d978d8c22.zip |
python3 compat: python3 strings have no decode()
Since python3 strings are already Unicode-capable, there have no
decode() function. Libguestfs content strings can be either python 2
or 3 strings, only decode them to utf-8 for python2.
-rw-r--r-- | src/virtBootstrap/utils.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/virtBootstrap/utils.py b/src/virtBootstrap/utils.py index 6dbea87..84d1629 100644 --- a/src/virtBootstrap/utils.py +++ b/src/virtBootstrap/utils.py @@ -167,7 +167,9 @@ class BuildImage(object): self.g.mount('/dev/sda', '/') success = False if self.g.is_file('/etc/shadow'): - shadow_content = self.g.read_file('/etc/shadow').decode('utf-8') + shadow_content = self.g.read_file('/etc/shadow') + if hasattr(shadow_content, 'decode'): + shadow_content = shadow_content.decode('utf-8') shadow_content = shadow_content.split('\n') if shadow_content: # Note: 'shadow_content' is a list, pass-by-reference is used |