[issue16322] time.tzname on Python 3.3.0 for Windows is decoded by wrong encoding

Petr Prikryl report at bugs.python.org
Mon Sep 21 23:43:01 CEST 2015


Petr Prikryl added the comment:

@eryksun: I see. In my case, I can set the locale before importing the time module. However, the code (asciidoc3.py) will be used as a module, and I cannot know if the user imported the time module or not.

Instead of your suggestion 
    result = result.encode('latin-1').decode('mbcs')

I was thinking to create a module say wordaround16322.py like this:

---------------
import locale
locale.setlocale(locale.LC_ALL, '')

import importlib
import time
importlib.reload(time)
---------------

I thought that reloading the time module would be the same as importing is later, after setting locale. If that worked, the module could be simply imported wherever it was needed. However, it does not work when imported after importing time. What is the reason? Does reload() work
only for modules coded as Python sources? Is there any other approach that would implement the workaroundXXX.py module?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16322>
_______________________________________


More information about the Python-bugs-list mailing list