Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue14902] test_logging failed

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Jul 1, 2012, 5:04 AM

Post #1 of 14 (254 views)
Permalink
[issue14902] test_logging failed

Juancarlo Añez <apalala [at] gmail> added the comment:

My local timezone is (VET,VET) == time.tzname, and test_logging fails because time.timezone is off by 30 minutes. I couldn't find the cause for the problem with time.timezone, but logging is not to blame. I'm running the tests on Ubuntu 12.04 AMD64 which handles my time zone correctly throughout.

I'm submitting a patch that allows test_logging to pass by not relying on time.timezone.

----------
keywords: +patch
nosy: +apalala
Added file: http://bugs.python.org/file26224/test_logging_wo_timezone.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 2:39 AM

Post #2 of 14 (245 views)
Permalink
[issue14902] test_logging failed [In reply to]

Changes by Vinay Sajip <vinay_sajip [at] yahoo>:


----------
assignee: -> vinay.sajip
nosy: +vinay.sajip

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 4:31 AM

Post #3 of 14 (248 views)
Permalink
[issue14902] test_logging failed [In reply to]

Vinay Sajip <vinay_sajip [at] yahoo> added the comment:

@Yuriy: I set my location to Moscow (using the Gnome date widget) and ran the test, but no failure occurs.

vinay [at] eta-jaunt:~/projects/python/default$ date
Tue Jul 3 15:12:39 MSD 2012
vinay [at] eta-jaunt:~/projects/python/default$ ./python Lib/test/regrtest.py test_logging
[1/1] test_logging
1 test OK.

@Juan: Since the logging test doesn't seem to be broken, I'd rather not patch it; it was at least useful for throwing up a problem. For some reason time.timezone seems to be off, and that should probably be flagged as a separate issue.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 4:54 AM

Post #4 of 14 (247 views)
Permalink
[issue14902] test_logging failed [In reply to]

Yuriy Syrovetskiy <cblp [at] cblp> added the comment:

@vinay.sajip
My time.timezone is -14400. What is yours?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 4:56 AM

Post #5 of 14 (243 views)
Permalink
[issue14902] test_logging failed [In reply to]

Yuriy Syrovetskiy <cblp [at] cblp> added the comment:

And datetime.datetime.now().tzinfo is always None.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 5:50 AM

Post #6 of 14 (246 views)
Permalink
[issue14902] test_logging failed [In reply to]

Juancarlo Añez <apalala [at] gmail> added the comment:

@Vinay The test *is* broken in theory, because it uses today's time.timezone to make calculations over a datetime in the past (1993), even when official time zones have changes in recent years for Caracas, Moscow, and others: http://www.timeanddate.com/news/time/. As it is, the test will pass on some locations and fail on others, even if time.timezone is correct.

If time.timezone is wrong for certain locations is a separate issue that I will post as soon as I complete the unit test. I took a look at Modules/timemodule.c,and there seems to be nothing wrong there.

In short, the bug is: test_time() incorrectly uses the current time.timezone to make calculations over dates in the past.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 5:57 AM

Post #7 of 14 (249 views)
Permalink
[issue14902] test_logging failed [In reply to]

Juancarlo Añez <apalala [at] gmail> added the comment:

> And datetime.datetime.now().tzinfo is always None.

I can reproduce that.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 7:21 AM

Post #8 of 14 (243 views)
Permalink
[issue14902] test_logging failed [In reply to]

Vinay Sajip <vinay_sajip [at] yahoo> added the comment:

Sorry, I didn't quite grasp what the problem was before (timezones changing over time). I understand better now :-)

@Yuriy: On my test machine (Ubuntu Jaunty), with Moscow set as my location, the value of time.timezone is -10800 (for Caracas, it's 16200). The datetime.datetime.now().tzinfo is None, as you've both said.

I will look at this soon. Yuriy, can you confirm that with Juancarlo's patch, the test also works for you?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 7:24 AM

Post #9 of 14 (245 views)
Permalink
[issue14902] test_logging failed [In reply to]

Vinay Sajip <vinay_sajip [at] yahoo> added the comment:

BTW I just noticed that you created this issue on 24 May. Sorry I only saw it today - in future, if you add logging issues, please add me to the nosy list, and that way I'll pick it up sooner. Usually one of the other committers adds me, but this time no-one did :-(

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 8:31 AM

Post #10 of 14 (248 views)
Permalink
[issue14902] test_logging failed [In reply to]

Juancarlo Añez <apalala [at] gmail> added the comment:

I did extensive testing on time.timezone, and it is correct as far as the current date is concerned. The problem, as mentioned before, is that test_logging is using time.timezone for dates in the past for which the time zone may have been different from the current one on the current location.

The attached patch shows that time calculations involving time.timezone may not be valid for dates different from the current one, as not even daylight-savings/summer times are taken into account, so the test may also fail depending on the time of the year it is run on.

----------
Added file: http://bugs.python.org/file26246/test_timezones.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 10:16 AM

Post #11 of 14 (240 views)
Permalink
[issue14902] test_logging failed [In reply to]

Vinay Sajip <vinay_sajip [at] yahoo> added the comment:

Yes, thanks for doing the detailed analysis. I see that the original code was trying to adjust the timezone for a past time effectively using current timezone rules, which is why it doesn't work.

Your patch appears equivalent to the slightly simpler

dt = datetime.datetime(1993, 4, 21, 8, 3, 0, 0, utc)
r.created = time.mktime(dt.astimezone(None).timetuple())

which echoes the intent of the original code to adjust for the timezone. Can you see any reason why the above shouldn't work? On my test machine, it worked fine with the above code and locations of Moscow, London and Caracas (the original code failed with Caracas, though not with Moscow - but do I understand that the original is broken).

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 11:15 AM

Post #12 of 14 (248 views)
Permalink
[issue14902] test_logging failed [In reply to]

Juancarlo Añez <apalala [at] gmail> added the comment:

@Vinay No reason. datetime.astimezone(None) is documented in 3.3. You may even use:

r.created = time.mktime(dt.astimezone().timetuple())

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 11:16 AM

Post #13 of 14 (243 views)
Permalink
[issue14902] test_logging failed [In reply to]

Changes by Juancarlo Añez <apalala [at] gmail>:


----------
type: compile error -> behavior

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 3, 2012, 1:36 PM

Post #14 of 14 (249 views)
Permalink
[issue14902] test_logging failed [In reply to]

Roundup Robot <devnull [at] psf> added the comment:

New changeset 56260d30985d by Vinay Sajip in branch 'default':
Closes #14902: Fixed timezone conversion of a date/time in the past. Thanks to Yuriy Syrovetskiy for the report and Juancarlo Añez for the patch on which this fix is based.
http://hg.python.org/cpython/rev/56260d30985d

----------
nosy: +python-dev
resolution: -> fixed
stage: -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.