Skip to content
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

io: Handling ASCII stdout more gracefully. #256

Closed
wants to merge 1 commit into from

Conversation

jbohren
Copy link
Contributor

@jbohren jbohren commented Dec 21, 2015

@xqms Can you try running this branch in jenkins to better deal with the ASCII stdout?

This was the problem, as reported in #249 (comment)

Warnings << gazebo_ros_control:make /var/lib/jenkins/jobs/spacebot/workspace/build/_logs/gazebo_ros_control/build.make.000.log
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/home/max/install/catkin_tools/catkin_tools/execution/controllers.py", line 452, in run
    wide_log('\n'.join(lines))
  File "/home/max/install/catkin_tools/catkin_tools/common.py", line 450, in wide_log
    wide_log_fn(msg, **kwargs)
  File "/home/max/install/catkin_tools/catkin_tools/common.py", line 419, in disabled_wide_log
    log(msg, **kwargs)
  File "/home/max/install/catkin_tools/catkin_tools/common.py", line 272, in log
    print(*args, **kwargs)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 129: ordinal not in range(128)

The unicode character 2018 is "LEFT SINGLE QUOTATION MARK", emitted by gcc on my system:

[...] warning: enumeration value ‘EFFORT’ not handled in switch

@xqms
Copy link
Contributor

xqms commented Dec 22, 2015

Works for me under jenkins. The question is if this is any better than setting the output encoding to UTF-8

sys.setdefaultencoding('utf-8')

or always using str.encode('utf-8')...

@jbohren
Copy link
Contributor Author

jbohren commented Dec 22, 2015

Works for me under jenkins. The question is if this is any better than setting the output encoding to UTF-8

I'm wondering if there are any scenarios where stdout needs to be ASCII, and if in those scenarios, you get a similar exception. As opposed to just bring set to ASCII while still supporting utf-8.

@xqms
Copy link
Contributor

xqms commented Dec 22, 2015

I'm wondering if there are any scenarios where stdout needs to be ASCII

If so, what would be our strategy in that case? Drop all non-ASCII characters?
I'd argue encoding to UTF-8 is a better alternative.

As opposed to just bring set to ASCII while still supporting utf-8.

Not sure what that is supposed to mean ;-)

@jbohren
Copy link
Contributor Author

jbohren commented Dec 22, 2015

I'm wondering if there are any scenarios where stdout needs to be ASCII
If so, what would be our strategy in that case? Drop all non-ASCII characters?
I'd argue encoding to UTF-8 is a better alternative.

Yeah, I think that's fine, as well. It might make sense to set a global flag the first time it happens instead of catching an exception on every log call.

As opposed to just bring set to ASCII while still supporting utf-8.
Not sure what that is supposed to mean ;-)

*typo: being set to ASCII

From what I understand, Python's understanding of the stdout encoding might not be correct. That being said, if we encounter a situation like that down the line, we can fix it then.

@jbohren jbohren force-pushed the pre-0.4.0-io-encoding branch from 2d6a22e to 82cbd82 Compare December 22, 2015 19:46
@jbohren
Copy link
Contributor Author

jbohren commented Dec 22, 2015

Merged via a2cfdf7

@jbohren jbohren closed this Dec 22, 2015
@wjwwood wjwwood deleted the pre-0.4.0-io-encoding branch January 19, 2016 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants