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: Failure in test_strptime on Windows
Type: behavior Stage: resolved
Components: Tests, Windows Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nadeem.vawda Nosy List: brett.cannon, loewis, nadeem.vawda, pitrou, python-dev, skrah, vstinner
Priority: normal Keywords: buildbot, patch

Created on 2012-02-24 20:13 by nadeem.vawda, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue14113.diff skrah, 2012-02-26 17:52 review
Messages (16)
msg154153 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2012-02-24 20:13
Recent failures on one of the Windows XP buildbots:

http://www.python.org/dev/buildbot/all/builders/x86%20XP-4%203.x/builds/6049/steps/test/logs/stdio
http://www.python.org/dev/buildbot/all/builders/x86%20XP-4%203.x/builds/6051/steps/test/logs/stdio

    FAIL: test_date_time (test.test_strptime.LocaleTime_Tests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_strptime.py", line 91, in test_date_time
        "LC_date_time incorrect")
    AssertionError: False is not true : LC_date_time incorrect
msg154248 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2012-02-25 13:17
Also failing on the Windows 7 bot:

http://www.python.org/dev/buildbot/all/builders/x86%20Windows7%203.x/builds/4453/steps/test/logs/stdio
msg154249 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-25 14:05
New changeset d5aa731bae5e by Nadeem Vawda in branch 'default':
Use assertEqual in test_strptime for better failure messages (cf. issue #14113).
http://hg.python.org/cpython/rev/d5aa731bae5e
msg154364 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-02-26 15:57
It looks like test_locale from test_format.py changes the locale on Windows:

>>> import time                                                                                      >>> magic_date = (1999, 3, 17, 22, 44, 55, 2, 76, 0)                                                 >>> time.strftime("%c", magic_date)
'03/17/99 22:44:55'
>>> import locale
>>> locale.getdefaultlocale()
('en_US', 'cp1252')                                                                                  >>> time.strftime("%c", magic_date)                                                                  '03/17/99 22:44:55'
>>> oldloc = locale.setlocale(locale.LC_ALL, '')
>>> oldloc
'English_United States.1252'
>>> time.strftime("%c", magic_date)                                                                  '3/17/1999 10:44:55 PM'
>>> locale.setlocale(locale.LC_ALL, oldloc)
'English_United States.1252'
>>> time.strftime("%c", magic_date)                                                                  '3/17/1999 10:44:55 PM'
msg154375 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-02-26 17:52
Attached a fix that is tested on Windows.
msg154376 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-02-26 17:59
Patch works under Linux here.
msg154393 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-02-26 21:24
Does test.support track the locale for test mutations? If not we might want to add that check w/ all of the other interpreter state checks we have.
msg154406 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2012-02-26 22:07
> Attached a fix that is tested on Windows.

Patch looks good to me.


> Does test.support track the locale for test mutations?

No, it doesn't.
msg154413 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-02-26 22:45
>> Attached a fix that is tested on Windows.
>
> Patch looks good to me.

-            oldloc = locale.setlocale(locale.LC_ALL, '')
+            oldloc = locale.setlocale(locale.LC_ALL)

Python provides locale.getlocale().
msg154415 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-02-26 22:48
Created issue14135 for having test.support check the locale to see if it has been changed.
msg154416 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2012-02-26 22:48
> Python provides locale.getlocale().

That was my initial thought too, but it seems that getlocale() doesn't
accept LC_ALL as its argument:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python3.3/locale.py", line 523, in getlocale
        raise TypeError('category LC_ALL is not supported')
    TypeError: category LC_ALL is not supported
msg154443 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-02-27 09:01
> ... it seems that getlocale() doesn't accept LC_ALL as its argument:

The current situation is not ideal. getlocale() is documented to fail
("category may be one of the LC_* values except LC_ALL"), but it only
fails if there's a semicolon in the locale name:

if category == LC_ALL and ';' in localename:
    raise TypeError('category LC_ALL is not supported')


I'd prefer that getlocale(LC_ALL) fails consistently on all systems.
msg154446 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-27 09:20
New changeset 1ea466240792 by Stefan Krah in branch 'default':
Issue #14113: Fix a test_strptime failure caused by changes to LC_ALL.
http://hg.python.org/cpython/rev/1ea466240792
msg154496 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-02-27 17:48
I've created #14142 for the getlocale(LC_ALL) situation. The main issue
is fixed, Nadeem's changes result in better error messages, so I think we
can close this.

Perhaps the assertEqual changes should be backported to 3.2 and 2.7
to keep the files in sync (leaving the issue open for that).
msg154497 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2012-02-27 17:51
> Perhaps the assertEqual changes should be backported to 3.2 and 2.7
> to keep the files in sync (leaving the issue open for that).

Agreed. I'll also make similar changes to the other test cases; my
initial changes only touched the tests that were failing.
msg154576 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-28 22:26
New changeset 3ea8d0afe541 by Nadeem Vawda in branch '2.7':
Give better failure messages in test_strptime (cf. issue #14113).
http://hg.python.org/cpython/rev/3ea8d0afe541

New changeset 8d2ffe1f25d3 by Nadeem Vawda in branch '3.2':
Give better failure messages in test_strptime (cf. issue #14113).
http://hg.python.org/cpython/rev/8d2ffe1f25d3

New changeset 46ab2d46337c by Nadeem Vawda in branch 'default':
Merge: Give better failure messages in test_strptime (cf. issue #14113).
http://hg.python.org/cpython/rev/46ab2d46337c
History
Date User Action Args
2022-04-11 14:57:27adminsetgithub: 58321
2012-02-28 22:34:27nadeem.vawdasetstatus: open -> closed
2012-02-28 22:26:10python-devsetmessages: + msg154576
2012-02-27 17:51:02nadeem.vawdasetassignee: nadeem.vawda
messages: + msg154497
2012-02-27 17:48:09skrahsetresolution: fixed
messages: + msg154496
stage: commit review -> resolved
2012-02-27 09:20:46python-devsetmessages: + msg154446
2012-02-27 09:01:39skrahsetmessages: + msg154443
2012-02-26 22:48:37nadeem.vawdasetmessages: + msg154416
2012-02-26 22:48:33brett.cannonsetmessages: + msg154415
2012-02-26 22:45:17vstinnersetmessages: + msg154413
2012-02-26 22:07:57nadeem.vawdasetmessages: + msg154406
2012-02-26 21:24:26brett.cannonsetnosy: + brett.cannon
messages: + msg154393
2012-02-26 17:59:29pitrousetnosy: + pitrou, loewis, vstinner

messages: + msg154376
stage: needs patch -> commit review
2012-02-26 17:52:18skrahsetfiles: + issue14113.diff
keywords: + patch
messages: + msg154375
2012-02-26 15:57:08skrahsetnosy: + skrah
messages: + msg154364
2012-02-25 14:05:52python-devsetnosy: + python-dev
messages: + msg154249
2012-02-25 13:17:26nadeem.vawdasetmessages: + msg154248
2012-02-24 20:13:17nadeem.vawdacreate