Author nneonneo
Recipients nneonneo
Date 2013-01-27.08:48:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359276526.88.0.340808653296.issue17049@psf.upfronthosting.co.za>
In-reply-to
Content
Try this at a command-prompt:

$ python -m calendar -L ja_JP --encoding utf8

The result is a crash:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/calendar.py", line 708, in <module>
    main(sys.argv)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/calendar.py", line 703, in main
    result = result.encode(options.encoding)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 49: ordinal not in range(128)

The reason is because the TimeEncoding class doesn't properly return the encoding it should use, so 'encoding' ends up being None in "with TimeEncoding(self.locale) as encoding:" lines.

Trivial patch:

--- calendar.py	2013-01-27 03:48:08.000000000 -0500
+++ calendar.py	2013-01-27 03:48:08.000000000 -0500
@@ -488,6 +488,7 @@
     def __enter__(self):
         self.oldlocale = _locale.getlocale(_locale.LC_TIME)
         _locale.setlocale(_locale.LC_TIME, self.locale)
+        return self.locale[1]
 
     def __exit__(self, *args):
         _locale.setlocale(_locale.LC_TIME, self.oldlocale)
History
Date User Action Args
2013-01-27 08:48:46nneonneosetrecipients: + nneonneo
2013-01-27 08:48:46nneonneosetmessageid: <1359276526.88.0.340808653296.issue17049@psf.upfronthosting.co.za>
2013-01-27 08:48:46nneonneolinkissue17049 messages
2013-01-27 08:48:46nneonneocreate