This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Return value missing in calendar.TimeEncoding.__enter__
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: calendar throws UnicodeEncodeError when locale is specified
View: 17049
Assigned To: Nosy List: JJeffries, Retro, christian.heimes, eric.araujo, georg.brandl, ixokai, psam, r.david.murray, serhiy.storchaka, tim.golden, twouters, vstinner
Priority: normal Keywords:

Created on 2011-12-06 13:07 by psam, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg148915 - (view) Author: (psam) Date: 2011-12-06 13:07
The v2.6 of __enter__() of TimeEncoding has been fixed in v2.7 in relation with the return of setlocale(), but for no apparent reason, its necessary returned value is no more there.


    def __enter__(self):
        self.oldlocale = _locale.getlocale(_locale.LC_TIME)
        _locale.setlocale(_locale.LC_TIME, self.locale)
+       return _locale.getlocale(_locale.LC_TIME)[1]
msg149165 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-12-10 16:16
Good catch.  The code doesn’t break because there is a check for None later on (certainly because getlocale may return None, but here __enter__ always returns None).  How did you find this?  If you have a code snippet that reproduces the bug we’ll be able to add it to the test suite before fixing the bug.
msg149298 - (view) Author: (psam) Date: 2011-12-12 13:13
The problem was detected in a Django project, as the template engine was not able to support the original encoding.
I don't have a real test code snippet, but you may try something like:


Note: for Windows, locale='' or locale='fra_FRA' are ok, not locale='fr_FR' or no specified locale.
msg149323 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-12-12 16:06
I don’t know this module well, so I’m adding Georg, who last changed that method, and other people from #10092 to the nosy list.
msg180794 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-27 20:54
See also issue17049. This is not a theoretical bug.
msg180796 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2013-01-27 21:00
Then you can close one bug as duplicate and commit a fix for the other :)
Date User Action Args
2022-04-11 14:57:24adminsetgithub: 57748
2013-01-28 17:10:14serhiy.storchakasetstatus: open -> closed
superseder: calendar throws UnicodeEncodeError when locale is specified
resolution: duplicate
stage: test needed -> resolved
2013-01-27 21:00:33eric.araujosetmessages: + msg180796
2013-01-27 20:54:39serhiy.storchakasetnosy: + serhiy.storchaka

messages: + msg180794
versions: - Python 3.2, Python 3.3
2011-12-12 16:06:34eric.araujosetnosy: + twouters, georg.brandl, ixokai, christian.heimes, tim.golden, Retro, r.david.murray, JJeffries
messages: + msg149323
2011-12-12 13:14:04vstinnersetnosy: + vstinner
2011-12-12 13:13:36psamsetmessages: + msg149298
2011-12-10 16:16:41eric.araujosetnosy: + eric.araujo
title: A return is missing in TimeEncoding of -> Return value missing in calendar.TimeEncoding.__enter__
messages: + msg149165

versions: + Python 3.2, Python 3.3
stage: test needed
2011-12-06 13:07:51psamcreate