summaryrefslogtreecommitdiff
path: root/cloudinit/handlers/__init__.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-11-06 14:13:30 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-11-06 14:13:30 -0800
commit7d027a031a3649ac04965a09cd26563ac9d760fd (patch)
treecb04d4327c4bdcd0ceca1da317d33242abf8b8d5 /cloudinit/handlers/__init__.py
parentc508fa0c4159f93df077a2d46ed481fd5d8c8803 (diff)
downloadvyos-cloud-init-7d027a031a3649ac04965a09cd26563ac9d760fd.tar.gz
vyos-cloud-init-7d027a031a3649ac04965a09cd26563ac9d760fd.zip
Fix the case where a unknown type is seen and
it has contents which are in unicode which seems to cause python to blow-up when this happens since 'string-escape' doesn't work on unicode (at least in 2.6). LP: #1075756
Diffstat (limited to 'cloudinit/handlers/__init__.py')
-rw-r--r--cloudinit/handlers/__init__.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/cloudinit/handlers/__init__.py b/cloudinit/handlers/__init__.py
index 99caed1f..e843eb75 100644
--- a/cloudinit/handlers/__init__.py
+++ b/cloudinit/handlers/__init__.py
@@ -171,7 +171,11 @@ def walker_callback(pdata, ctype, filename, payload):
elif payload:
# Extract the first line or 24 bytes for displaying in the log
start = _extract_first_or_bytes(payload, 24)
- details = "'%s...'" % (start.encode("string-escape"))
+ try:
+ details = "'%s...'" % (start.encode("string-escape"))
+ except TypeError:
+ # Unicode doesn't support string-escape...
+ details = "'%s...'" % (start)
if ctype == NOT_MULTIPART_TYPE:
LOG.warning("Unhandled non-multipart (%s) userdata: %s",
ctype, details)