plainbox crashes if started with bogus LC_CTYPE inherited from OS X (via ssh)

Bug #1444662 reported by Maciej Kisielewski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PlainBox (Toolkit)
Won't Fix
Low
Unassigned

Bug Description

Steps to reproduce:

export LC_CTYPE=UTF-8
export LANGUAGE=pl plainbox

This uses =pl since polish seems to be the only language that has a non-trivial amount of translations that are not pure ASCII and thus triggers the problem by trying to convert non 7-bit ASCII to ASCII.

The looks like this:

Traceback (most recent call last):
  File "/home/kissiel/FUBAR/checkbox/venv/bin/plainbox", line 9, in <module>
    load_entry_point('plainbox==0.21.dev', 'console_scripts', 'plainbox')()
  File "/home/kissiel/FUBAR/checkbox/plainbox/plainbox/impl/box.py", line 122, in main
    raise SystemExit(PlainBoxTool().main(argv))
  File "/home/kissiel/FUBAR/checkbox/plainbox/plainbox/impl/clitools.py", line 324, in main
    return self.dispatch_and_catch_exceptions(ns)
  File "/home/kissiel/FUBAR/checkbox/plainbox/plainbox/impl/clitools.py", line 560, in dispatch_and_catch_exceptions
    return self.dispatch_command(ns)
  File "/home/kissiel/FUBAR/checkbox/plainbox/plainbox/impl/clitools.py", line 556, in dispatch_command
    return ns.command.invoked(ns)
  File "/home/kissiel/FUBAR/checkbox/plainbox/plainbox/impl/commands/cmd_run.py", line 45, in invoked
    self.provider_loader, self.config_loader, ns, ns.color).run()
  File "/home/kissiel/FUBAR/checkbox/plainbox/plainbox/impl/commands/inv_run.py", line 356, in run
    return self.do_normal_sequence()
  File "/home/kissiel/FUBAR/checkbox/plainbox/plainbox/impl/commands/inv_run.py", line 403, in do_normal_sequence
    self.export_and_send_results()
  File "/home/kissiel/FUBAR/checkbox/plainbox/plainbox/impl/commands/inv_run.py", line 814, in export_and_send_results
    self._save_results(self.ns.output_file, exported_stream)
  File "/home/kissiel/FUBAR/checkbox/plainbox/plainbox/impl/commands/inv_run.py", line 831, in _save_results
    copyfileobj(input_stream, translating_stream)
  File "/home/kissiel/FUBAR/checkbox/venv/lib/python3.4/shutil.py", line 69, in copyfileobj
    fdst.write(buf)
  File "/home/kissiel/FUBAR/checkbox/plainbox/plainbox/impl/exporter/__init__.py", line 359, in write
    return self.dest_stream.write(data.decode(self.encoding))
UnicodeEncodeError: 'ascii' codec can't encode character '\u2611' in position 8: ordinal not in range(128)
(venv)kissiel@lilly:~/FUBAR/checkbox$

locale output:
http://paste.ubuntu.com/10828447/

The ‘data’ var from the trace contains following : b' \x1b[32;1m\xe2\x98\x91 \x1b[0m: led/caps-lock\n'

Related branches

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Let's set LC_CTYPE to the bogus value inherited from OS X

zyga@fx:~$ export LC_CTYPE=UTF-8
bash: uwaga: setlocale: LC_CTYPE: nie można zmienić lokalizacji (UTF-8): Nie ma takiego pliku ani katalogu
^^ (sorry about the polish locale, here bash tells us that it cannot set LC_CTYPE like that)

Let's run python now.
zyga@fx:~$ python3
Python 3.4.3 (default, Mar 26 2015, 22:03:40)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.

Hmm, we're all good, right python?

>>> import sys
>>> sys.stdout.encoding
'ANSI_X3.4-1968'

Nope, we're f***d

Changed in plainbox:
status: New → Confirmed
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

While this won't fix everything. One thing we _can_ do is disable i18n when sys.stdout.encoding is ANSI_X3.4-1968 (I love the date, python sets us back by 47 years)

summary: - plainbox crashes when run from remote OSX host through SSH
+ plainbox crashes if started with bogus LC_CTYPE inherited from OS X (via
+ ssh)
description: updated
Zygmunt Krynicki (zyga)
Changed in plainbox:
importance: Undecided → Low
status: Confirmed → In Progress
assignee: nobody → Zygmunt Krynicki (zyga)
Zygmunt Krynicki (zyga)
Changed in plainbox:
milestone: none → 0.21
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Postponing to 0.22 as it chokes tarmac.

Changed in plainbox:
milestone: 0.21 → 0.22
Changed in plainbox:
milestone: 0.22 → 0.23
Changed in plainbox:
milestone: 0.23 → 0.24
Changed in plainbox:
milestone: 0.24 → future
Changed in plainbox:
status: In Progress → Confirmed
Po-Hsu Lin (cypressyew)
Changed in plainbox:
status: Confirmed → In Progress
Zygmunt Krynicki (zyga)
Changed in plainbox:
status: In Progress → Triaged
assignee: Zygmunt Krynicki (zyga) → nobody
Changed in plainbox:
milestone: future → none
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.