diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2017-05-03 16:42:10 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2017-05-03 16:42:10 +0100 |
commit | a81243cdd3f0e7db152251caeb478c19cd801277 (patch) | |
tree | 81b1543e162d67abba73e98378cc6fc28e9ee76b | |
parent | 471d8e86c3c174f7b075c306542c732f30893281 (diff) | |
download | sos-a81243cdd3f0e7db152251caeb478c19cd801277.tar.gz |
[plugins] work around Six string problems in HTML reports
A workaround for Six string encoding problems involving strings
that end in '\' characters was introduced for plain text reports
in commit 3d23564: a similar fix is also needed for HTML reports,
since the same string encoding problem can occur there too:
> /usr/lib/python2.7/site-packages/six.py(647)u()
-> return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
(Pdb) bt
/usr/sbin/sosreport(25)<module>()
-> main(sys.argv[1:])
/usr/lib/python2.7/site-packages/sos/sosreport.py(1632)main()
-> sos.execute()
/usr/lib/python2.7/site-packages/sos/sosreport.py(1606)execute()
-> self.html_report()
/usr/lib/python2.7/site-packages/sos/sosreport.py(1373)html_report()
-> self._html_report()
/usr/lib/python2.7/site-packages/sos/sosreport.py(1434)_html_report()
-> self.handle_exception()
/usr/lib/python2.7/site-packages/sos/sosreport.py(1432)_html_report()
-> html = plug.report()
/usr/lib/python2.7/site-packages/sos/plugins/__init__.py(930)report()
-> + "/" + _to_u(cmd['file'])
/usr/lib/python2.7/site-packages/sos/plugins/__init__.py(44)_to_u()
-> s = six.u(s)
> /usr/lib/python2.7/site-packages/six.py(647)u()
-> return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
Avoid this by applying the same workaround ('\$' -> '\ $') in the
existing Plugin _to_u() helper function.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/__init__.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index 49da6f26..cd34d196 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -36,6 +36,11 @@ from six.moves import zip, filter def _to_u(s): if not isinstance(s, six.text_type): + # Workaround python.six mishandling of strings ending in '\' by + # adding a single space following any '\' at end-of-line. + # See Six issue #60. + if s.endswith('\\'): + s += " " s = six.u(s) return s |