test locale for Unicode support

Bug #1270359 reported by Rolf Leggewie
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pastebinit
Fix Released
Medium
Unassigned
pastebinit (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

pastebinit needs Unicode support to work. It would be nice if it tested for it and raised an error understandable to the average user.

$ LC_ALL=C.UTF-8 pastebinit -v
pastebinit v1.4
$ LC_ALL=C.UTF-8 pastebinit -v
pastebinit v1.4
leggewie@1001P:/etc$ LC_ALL=C pastebinit -v
Traceback (most recent call last):
  File "/usr/bin/pastebinit", line 293, in <module>
    pastebind = preloadPastebins()
  File "/usr/bin/pastebinit", line 102, in preloadPastebins
    instance.read(filename)
  File "/usr/lib/python3.2/configparser.py", line 689, in read
    self._read(fp, filename)
  File "/usr/lib/python3.2/configparser.py", line 994, in _read
    for lineno, line in enumerate(fp, start=1):
  File "/usr/lib/python3.2/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 167: ordinal not in range(128)

Revision history for this message
Stéphane Graber (stgraber) wrote :

I pushed two commits that should improve this quite a bit.

1) pastebinit will now ignore any pastebin configuration file it can't read because of encoding errors (in this case, the Chinese Ubuntu pastebin contained utf-8 characters for the submit button).
2) pastebinit will now read input files in raw byte mode and not attempt decoding, so it can submit utf-8 encoded files even if it's not itself running under an utf-8 locale

I won't however add a specific check for an utf-8 locale because while that's easy to do on Linux, it's not so much easy when you also need to support Windows, MacOS, ...

Changed in pastebinit (Ubuntu):
status: New → Fix Committed
status: Fix Committed → Triaged
importance: Undecided → Low
Changed in pastebinit:
status: New → Triaged
importance: Undecided → Medium
status: Triaged → Fix Committed
Changed in pastebinit:
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pastebinit - 1.4-2ubuntu1

---------------
pastebinit (1.4-2ubuntu1) trusty; urgency=medium

  * Merge from Debian unstable. Remaining changes:
    - Don't build-depend on python-support.

pastebinit (1.4-2) unstable; urgency=low

  * patches:
    ~ update upstream to r205. Fix unicode problem. LP: #1270359
      This essentially gives us upstream release 1.4.1
    ~ increase timeout to 15s to account for bad networks
  * watch: only check for 2-level (major.minor) upstream releases
  * drop preinst script as obsolete

pastebinit (1.4-1) unstable; urgency=low

  [ Bart Martens ]
  * update watch file

  [ Rolf Leggewie ]
  * new upstream release 1.4
    - upstream bugfixes
      ~ crash in create_connection(). LP: #1032221
      ~ point shebang to python3. LP: #988468
      ~ allow calling pastebin by basename. Closes: #705979, LP: #977331
      ~ allow pasting several files at once. Closes: #662242
    - control: bump python to python3 in run-time dependencies
               remove python-configobj from run-time dependencies
    - drop all debian-patches as obsolete
  * control:
    - drop obsolete DMUA field
    - update to standard version 3.9.5. No further changes.
  * copyright: update upstream and my copyright to 2014
 -- Stephane Graber <email address hidden> Thu, 23 Jan 2014 21:52:07 -0500

Changed in pastebinit (Ubuntu):
status: Triaged → Fix Released
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.