-
Notifications
You must be signed in to change notification settings - Fork 0
fix UTF8 escaping of log messages, retain newlines and tabs #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This fixes the broken tests in easybuilders#926 |
this is just wrong. we'll need another fix if this is all required |
unless you're OK with 'escaped' newlines and tabs in log messages, it's not required but without this (and using |
Agree wit stdweird, it's wrong:
|
@JensTimmerman: OK, it's stripping off too much, but that's another issue |
I would try something like:
Instead of the repr() call.
|
That plays nice with newlines and tabs in any case, so I'm all for it. >>> def bla(text):
... try:
... text = str(text)
... except UnicodeEncodeError:
... text = text.encode('utf8', 'replace')
... return text
...
>>> bla('"foo"')
'"foo"'
>>> bla('"foo\nbar"')
'"foo\nbar"'
>>> print bla('"foo\nbar"')
"foo
bar"
>>> bla('"foo\tbaz\nbar"')
'"foo\tbaz\nbar"'
>>> print bla('"foo\tbaz\nbar"')
"foo baz
bar" |
here's a list of some of the things that don't work: |
actually always using |
Note that this does not fail if the string contains UTF-16 characters if python was compiled with wide unicode character support (default since 2.2) |
changed to use @JensTimmerman's suggestion, EB unit tests are happy |
I also checked that this resolves the original issue, that was caused by the string |
Properly resolved in hpcugent/vsc-base#122, easybuilders#926 is no longer needed (replaced by easybuilders#935), so this PR has become useless. |
No description provided.