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.

classification
Title: Fix strftime on windows.
Type: behavior Stage: resolved
Components: Extension Modules, Windows Versions: Python 3.0, Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: kevinwatters, loewis, ocean-city
Priority: normal Keywords: patch

Created on 2009-02-13 16:24 by ocean-city, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_strftime_on_windows.patch ocean-city, 2009-02-13 16:24
experimental_wcsftime.patch ocean-city, 2009-02-14 05:32 this is not fix. just experimental patch
Messages (8)
msg81946 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-02-13 16:24
On windows, format string should be encoded as mbcs. Otherwise, result
of strftime would be broken. Here is the patch.
msg81981 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-02-14 00:12
I think we should use wcsftime on Windows, even though it works very
similar to your patch (with the primary difference being that it uses
alloca instead of Py_Malloc).
msg81993 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-02-14 05:32
I experimentally implemented with wcsftime, but I couldn't get same
result as strftime + mbcs conversion. Probably because wcsftime depends
on locale.
msg81994 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-02-14 06:00
Sorry, if we use wcsftime, I cannot create the patch. On VC6, wcsftime
returns not unicode but mbcs string which copied to wchar array.

Maybe on snakebite.org, I can access VC9 and confirm its behavior on it? ;-)
msg81998 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-02-14 07:42
> On VC6, wcsftime simply converts *format* to mbcs string, calls
> strftime, and converts result to unicode, so there is no difference
> between my patch and wcsftime.

Right.

> (Newer VC's wcsftime might have different
> implementation though) Maybe you are concerning about the cost of extra
> unicode object creation on non-windows platform? 

No. I'm concerned primarily about code cleanliness, by relying on
library code rather than implementing stuff ourselves.

OTOH, the conversion to narrow strings still needs to happen on Unix
(and probably needs to use the locale's encoding, not UTF-8), so
a uniform treatment also has a value.
msg82222 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-02-16 07:50
Locale is my weak point. :-(
If there is locale encoding function like PyUnicode_DecodeFSDefault for
file system encoding, I think I can use it.
msg82225 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-02-16 08:24
Using TZNAME_ENCODING is fine; I just think it has an incorrect value on
Unix.

All in all, I think the (original) patch is fine, please apply.
msg82228 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-02-16 09:30
Thanks, fixed in r69664(py3k) and r69665(release30-maint).
History
Date User Action Args
2022-04-11 14:56:45adminsetgithub: 49499
2010-04-27 20:32:07loewissetpriority: normal
2009-02-16 09:30:04ocean-citysetstatus: open -> closed
priority: high -> (no value)
messages: + msg82228
resolution: accepted -> fixed
stage: commit review -> resolved
2009-02-16 08:24:18loewissetresolution: accepted
messages: + msg82225
2009-02-16 07:50:57ocean-citysetmessages: + msg82222
2009-02-14 07:42:20loewissetmessages: + msg81998
2009-02-14 06:00:48ocean-citysetmessages: + msg81994
2009-02-14 05:39:46ocean-citysetmessages: - msg81992
2009-02-14 05:32:38ocean-citysetfiles: + experimental_wcsftime.patch
messages: + msg81993
2009-02-14 04:29:32ocean-citysetmessages: + msg81992
2009-02-14 00:12:33loewissetnosy: + loewis
messages: + msg81981
2009-02-13 17:26:57kevinwatterssetnosy: + kevinwatters
2009-02-13 16:36:38ocean-citysetpriority: high
2009-02-13 16:30:38ocean-citylinkissue5239 dependencies
2009-02-13 16:24:07ocean-citycreate