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: test_email: failure on Windows
Type: behavior Stage: resolved
Components: email, Tests Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: belopolsky Nosy List: Alexander.Belopolsky, barry, belopolsky, pitrou, python-dev, r.david.murray, skrah, vstinner
Priority: high Keywords: buildbot

Created on 2012-06-24 19:43 by skrah, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (9)
msg163827 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-06-24 19:43
I'm getting this failure in test_email (Windows 64-bit build):

======================================================================                                               
ERROR: test_localtime_epoch_notz_daylight_false (test_utils.LocaltimeTests)                                          
----------------------------------------------------------------------                                               
Traceback (most recent call last):                                                                                   
  File "C:\Users\stefan\pydev\cpython\lib\test\test_email\test_utils.py", line 112, in test_localtime_epoch_notz_dayl
ight_false                                                                                                           
    t1 = utils.localtime(t0)                                                                                         
  File "C:\Users\stefan\pydev\cpython\lib\email\utils.py", line 397, in localtime                                    
    seconds = time.mktime(tm)                                                                                        
OverflowError: mktime argument out of range                                                                          
                                                                                                                     
======================================================================                                               
ERROR: test_localtime_epoch_notz_daylight_true (test_utils.LocaltimeTests)                                           
----------------------------------------------------------------------                                               
Traceback (most recent call last):                                                                                   
  File "C:\Users\stefan\pydev\cpython\lib\test\test_email\test_utils.py", line 105, in test_localtime_epoch_notz_dayl
ight_true                                                                                                            
    t1 = utils.localtime(t0)                                                                                         
  File "C:\Users\stefan\pydev\cpython\lib\email\utils.py", line 397, in localtime                                    
    seconds = time.mktime(tm)                                                                                        
OverflowError: mktime argument out of range
msg163851 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-06-24 20:35
Same here with VS 2008.
msg163856 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-06-24 20:46
I haven't touched localtime since pycon, so I presume this hasn't been detected before due to our lack of a windows 64bit buildbot.
msg163865 - (view) Author: Alexander Belopolsky (Alexander.Belopolsky) Date: 2012-06-24 21:21
I don't have a Win 64 setup, but I think replacing 1970 with say 1990 in the tests should fix the problem.
msg163993 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2012-06-25 17:07
I am surprised that we don't see the same failure on 32-bit windows buildbot.  Windows mktime does not support negative time_t in either 32 or 64 bit version:

http://msdn.microsoft.com/en-us/library/d1y53h2a(v=vs.110).aspx

We are probably just lucky and no Windows buildbot uses a TZ set ahead of UTC.   Stefan, what is your timezone?

What is happening here is that mktime() is called for 1970-01-01 00:00 which results in positive timestamp for the timezones west of Greenwich and negative timestamp east of Greenwich.  For example, using GNU date:

$ TZ=Europe/Paris date -d "1970-01-01 00:00" +%s
-3600

$ TZ=America/New_York date -d "1970-01-01 00:00" +%s
18000

I am adding Victor as an expert on pushing the limits of date/time functions.
msg163994 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-06-25 17:24
My timezone is CET, so that fits your explanation. Indeed, the failure
also occurs on Windows 32-bit.
msg163995 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2012-06-25 17:33
Is this something that has to be fixed during the freeze?  The fix is trivial: s/1970/1990/g, but I planned to revisit TZ-dependent tests during the beta period.  I think we don't use run_with_tz() enough.  It would also be great to make it work on windows.
msg174858 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-05 01:06
New changeset 367e376e5ba2 by Victor Stinner in branch '3.3':
Close #15165: Fix test_email on Windows 64 bits
http://hg.python.org/cpython/rev/367e376e5ba2

New changeset 651e8613e579 by Victor Stinner in branch 'default':
(Merge 3.3) Close #15165: Fix test_email on Windows 64 bits
http://hg.python.org/cpython/rev/651e8613e579
msg174859 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-11-05 01:12
This issue is not related to the email module, but it is a Windows limitation: datetime.datetime(1970, 1, 1).timestamp() raises a same OverflowError.
History
Date User Action Args
2022-04-11 14:57:32adminsetgithub: 59370
2012-11-05 01:12:48vstinnersetmessages: + msg174859
2012-11-05 01:06:23python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg174858

resolution: fixed
stage: resolved
2012-06-25 17:33:33belopolskysetassignee: belopolsky
messages: + msg163995
2012-06-25 17:24:56skrahsetmessages: + msg163994
title: test_email: failure on Windows 64-bit -> test_email: failure on Windows
2012-06-25 17:07:21belopolskysetnosy: + vstinner
messages: + msg163993
2012-06-24 21:21:16Alexander.Belopolskysetnosy: + Alexander.Belopolsky
messages: + msg163865
2012-06-24 20:46:46r.david.murraysetpriority: normal -> high

nosy: + belopolsky, barry
messages: + msg163856

components: + email
2012-06-24 20:35:18pitrousetnosy: + pitrou
messages: + msg163851
2012-06-24 19:43:57skrahcreate