Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#436 Timezone Problem

pythonwin (176)
Roscoe Bailey

I've been wrestling with the timezone module in pywin32 for several of days and was wondering if any one here might know how to solve the following Keyword: 'Std' error.

I've looked at the code and double checked my system registry and there is an entry for Std in each of the timezones in the hive.

Here is a listing from PythonWin and what can be done to repeat the failure:

PythonWin 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit (Intel)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information.
>>> import os
>>> import sys
>>> import time
>>> import pywin32
>>> import pywin32api
>>> import win32api
>>> import win32file
>>> import win32timezone
>>> import datetime
>>> assert 'Mountain Standard Time' in win32timezone.TimeZoneInfo.get_sorted_time_zone_names()
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python30\lib\site-packages\win32\lib\", line 588, in get_sorted_time_zone_names
tzs = TimeZoneInfo.get_sorted_time_zones()
File "C:\Python30\lib\site-packages\win32\lib\", line 606, in get_sorted_time_zones
zones = TimeZoneInfo.get_all_time_zones()
File "C:\Python30\lib\site-packages\win32\lib\", line 594, in get_all_time_zones
return [TimeZoneInfo(n) for n in TimeZoneInfo._get_time_zone_key_names()]
File "C:\Python30\lib\site-packages\win32\lib\", line 594, in <listcomp>
return [TimeZoneInfo(n) for n in TimeZoneInfo._get_time_zone_key_names()]
File "C:\Python30\lib\site-packages\win32\lib\", line 385, in __init__
File "C:\Python30\lib\site-packages\win32\lib\", line 406, in _LoadInfoFromKey
key = self._FindTimeZoneKey()
File "C:\Python30\lib\site-packages\win32\lib\", line 392, in _FindTimeZoneKey
zoneNames = dict(self._get_indexed_time_zone_keys('Std'))
File "C:\Python30\lib\site-packages\win32\lib\", line 581, in get_index_value
return key[index_key]
KeyError: 'Std'



  • Mark Hammond
    Mark Hammond

    I can't reproduce this, but I've assigned it to Jason who might have some insights (and sorry for the delay!)

  • Mark Hammond
    Mark Hammond

    • assigned_to: nobody --> jaraco
  • For me also, I'm unable to reproduce. The error suggests that there is a non-standard key in the registry in the time zone definitions. I'm going to close this ticket as we're unable to reproduce.

    If this is still a problem, please re-open the ticket (or add a comment). Please also run this command and attach the resulting tz.reg file:

    reg export "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Time Zones" tz.reg

    I will analyze the file and determine if the failure is something that we can correct against.

    • status: open --> closed-works-for-me