TST7337: Fix test failures on windows.
State: closed

closes #7337

Use dateutil.tz.tzutc() to construct UTC timezone instead of dateutil.tz.gettz('UTC')
Update docs to reflect this.
Tidy up examples in the timezones section of the docs.


Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Windows
description: Windows OS
name: Timezones
description: Timezone data dtype

Comments:
passed 26-32/26-64 builds so far!

looking good

Fingers crossed!

ok...good news and bad news...

py 2 looks good all fixed
py 3 otoh....(this happens with 33 & 34 on 32/64 bit

```
======================================================================
ERROR: test_append_with_timezones_dateutil (pandas.io.tests.test_pytables.TestHDFStore)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\tests\test_pytables.py", line 2086, in test_append_with_timezones_dateutil
    store.append('df_tz', df, data_columns=['A'])
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 911, in append
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 1270, in _write_to_group
    s.write(obj=value, append=append, complib=complib, **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 3605, in write
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 3293, in create_axes
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 3288, in create_axes
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 1755, in set_atom
    "invalid timezone specification")
TypeError: invalid timezone specification

======================================================================
ERROR: test_convert_datetime_list (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 311, in _convert_listlike
    return DatetimeIndex._simple_new(values, None, tz=tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 468, in _simple_new
    result.tz = tools._maybe_get_tz(tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 60, in _maybe_get_tz
    tz = tslib.maybe_get_tz(tz)
  File "tslib.pyx", line 1044, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17381)
  File "tslib.pyx", line 1051, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17272)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 919, in gettz
    tz = tzfile(name)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 232, in __init__
    if fileobj.read(4).decode() != "TZif":
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 695, in test_convert_datetime_list
    dr2 = DatetimeIndex(list(dr), name='foo')
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 214, in __new__
    data = tools.to_datetime(data, errors='raise')
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 323, in to_datetime
    return _convert_listlike(arg, box, format)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 313, in _convert_listlike
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 302, in _convert_listlike
    coerce=coerce, unit=unit)
  File "tslib.pyx", line 1183, in pandas.tslib.array_to_datetime (pandas\tslib.c:19139)
ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

======================================================================
ERROR: test_convert_tz_aware_datetime_datetime (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 311, in _convert_listlike
    return DatetimeIndex._simple_new(values, None, tz=tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 468, in _simple_new
    result.tz = tools._maybe_get_tz(tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 60, in _maybe_get_tz
    tz = tslib.maybe_get_tz(tz)
  File "tslib.pyx", line 1044, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17381)
  File "tslib.pyx", line 1051, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17272)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 919, in gettz
    tz = tzfile(name)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 232, in __init__
    if fileobj.read(4).decode() != "TZif":
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 588, in test_convert_tz_aware_datetime_datetime
    result = to_datetime(dates_aware)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 323, in to_datetime
    return _convert_listlike(arg, box, format)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 313, in _convert_listlike
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 302, in _convert_listlike
    coerce=coerce, unit=unit)
  File "tslib.pyx", line 1183, in pandas.tslib.array_to_datetime (pandas\tslib.c:19139)
ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

======================================================================
ERROR: test_datetimeindex_tz_nat (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 311, in _convert_listlike
    return DatetimeIndex._simple_new(values, None, tz=tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 468, in _simple_new
    result.tz = tools._maybe_get_tz(tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 60, in _maybe_get_tz
    tz = tslib.maybe_get_tz(tz)
  File "tslib.pyx", line 1044, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17381)
  File "tslib.pyx", line 1051, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17272)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 919, in gettz
    tz = tzfile(name)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 232, in __init__
    if fileobj.read(4).decode() != "TZif":
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 760, in test_datetimeindex_tz_nat
    idx = to_datetime([Timestamp("2013-1-1", tz=self.tzstr('US/Eastern')), NaT])
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 323, in to_datetime
    return _convert_listlike(arg, box, format)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 313, in _convert_listlike
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 302, in _convert_listlike
    coerce=coerce, unit=unit)
  File "tslib.pyx", line 1183, in pandas.tslib.array_to_datetime (pandas\tslib.c:19139)
ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

======================================================================
ERROR: test_tzaware_datetime_to_index (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 311, in _convert_listlike
    return DatetimeIndex._simple_new(values, None, tz=tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 468, in _simple_new
    result.tz = tools._maybe_get_tz(tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 60, in _maybe_get_tz
    tz = tslib.maybe_get_tz(tz)
  File "tslib.pyx", line 1044, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17381)
  File "tslib.pyx", line 1051, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17272)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 919, in gettz
    tz = tzfile(name)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 232, in __init__
    if fileobj.read(4).decode() != "TZif":
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 677, in test_tzaware_datetime_to_index
    index = DatetimeIndex(d)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 214, in __new__
    data = tools.to_datetime(data, errors='raise')
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 323, in to_datetime
    return _convert_listlike(arg, box, format)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 313, in _convert_listlike
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 302, in _convert_listlike
    coerce=coerce, unit=unit)
  File "tslib.pyx", line 1183, in pandas.tslib.array_to_datetime (pandas\tslib.c:19139)
ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

======================================================================
FAIL: test_field_access_localize (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 389, in test_field_access_localize
    self.assert_numpy_array_equal(dr.hour, expected)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\util\testing.py", line 91, in assert_numpy_array_equal
    raise AssertionError('{0} is not equal to {1}.'.format(np_array, assert_equal))
AssertionError: [ 1  2  3  4  5  6  7  8  9 10] is not equal to [0 1 2 3 4 5 6 7 8 9].

======================================================================
FAIL: test_frame_reset_index (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 713, in test_frame_reset_index
    self.assertEqual(xp, rs)
AssertionError: tzfile('c:\\python33-32\\lib\\site-packages\\dateutil\\zoneinfo\\zoneinfo--latest.tar.gz') != None

----------------------------------------------------------------------
Ran 7271 tests in 417.895s

FAILED (SKIP=320, errors=5, failures=2)
```

The tests with `UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte` errors are due to the fact that the following code has different results between python 2 and python 3 on windows:

``` python
>>>from dateutil.tz import gettz
>>>gettz('Europe/London')._filename
# python 2
'Europe/London'
# python 3
'c:\\python33-32\\lib\\site-packages\\dateutil\\zoneinfo\\zoneinfo--latest.tar.gz'
```

In python 3, you get the same filename for all timezones.

We follow the dateutil package and rely on the filename for serializing timezones. Obviously if they all report the same filename then this isn't going to work.

The change in behaviour is actually due to a change in the tarfile package from the standard library. When you extract a file from a tar archive in python 3, it's named for the archive, in python 2 for the filename you are extracting.

This covers all but 3 of the test failures but I think this is a bug in tarfile for python 3.

I hacked `dateutil` locally to fix the timezone name issue and all of these failures go away. (I did get some pytz related failures but hopefully they're not related.) 

So I think we can say that all of these failures are related to the timezone/filename issue.

@jreback  I'm not sure how best to solve this. Ideally we'd fix the `tarfile` package - and failing that the `dateutil` package to work around the bug - but I guess both of those will be a slowish process and certainly would take a while to roll out to all `pandas` users.

I can't think of a good workaround in pandas for this - there's always the possibility that a user constructs a 'bad' `dateutil` timezone outside of our control and uses it with `pandas`.

Some less-than-good suggestions:
- Hack _maybe_get_tz to correct the filename on the timezones it constructs then that would help in some cases but only when you construct the timezone from a string.
- Hack _maybe_get_tz and _get_tz_cache_key it to reject tzfile objects with ".tar.gz" in the filename (on windows/py3 only)

I'll have a play with these but let me know what you think.

what do you DO with the `_filename`?

doesn't `gettz('Europe/London').tzname(datetime.datetime.today())` get what you need which is the timezone name?

Use it to identify the timezone. `dateutil` itself uses the filename.

`tzname` is different depending on the date e.g. 

``` python
In [14]: from dateutil.tz import gettz
In [15]: tz = gettz('Europe/London')
In [18]: tz.tzname(datetime.datetime(2001, 1, 1))
Out[18]: 'GMT'
In [19]: tz.tzname(datetime.datetime(2001, 6, 1))
Out[19]: 'BST'
```

so you can't use it as an identifier. [edit] and it doesn't match the timezone!

Originally I used the tz object itself (since different instances of the same zone are equal) but that doesn't serialize (so `pytables`, `ujson` stuff failed). As far as I can tell, there isn't an equivalent to `tz.zone` which you'd use with a `pytz` timezone.

ok...so its mainly test failures and serialization. e.g. you need to know a unique 'name' for the zone, rigth?

yeah I simply would not allow them on construction, I know its hacky, but rejecting if `.tar.gz` in the `_filename` looks like a good soln (you don't have to check the platform at all).. raise a helpful error.

and I would file a bug-report with dateutil (as this works on linux, so odd that it doesn't on windows) and works in py2.

Exactly. We need to be able to identify the zone in a few other places as well:
- repr via tslib.get_timezone()  (and the standard `dateutil` repr).
- checking timezones are the same (e.g. tseries.tools._infer_tzinfo, Index.equals, various places in tslib)
- cache key for looking up transition/deltas in tslib.

Rejecting `.tar.gz` should be a good solution and there are relatively few places where we need to check. On linux or on python 2, as far as I can tell the filename will never contain that string so we shouldn't need any platform checks.

If we modify `maybe_get_tz` to set the filename correctly then users will still be able to use strings to specify `dateutil` timezones as well.

Agree re filing a bug - probably with the maintainer of the tarfile package as well.

I'll try and sort this out this afternoon. I'll put the changes in this PR but won't squash them so we can see the two parts - let me know if that suits you.

yep sounds fine

also, their seems to be a `dateutil.tz.tzwin` that help any? (that has functions in it on windows but not on linux)

I think that class is for windows registry timezones - but it doesn't seem to be used when you call `gettz`. That prefers to use the data in `dateutil.zoneinfo`. I'm not sure why. 

Anyway, I think I've got this working. I've tested on python 2.7 and 3.3 on windows and 2.7 on linux. The timezone related test failures are gone (with the exception of one failure which I can't replicate manually but which wasn't failing for you and doesn't seem to be tz-related).

The changes are:
- Enforce correct filename when creating (maybe_get_tz) or reading (get_zone) the timezone information.
- Update tests to construct `utc` timezones correctly as `dateutil.tz.tzutc()`.
- Update tests to avoid constructing `dateutil` timezones to avoid the filename issue.

@dbew yes....let's get passing...then go from them to make even more robust!

if you are satisfied that works on windows then ping me when passing travis (we can merge and then address any follow up failing tests).

@dbew ok, ready to go on this?

Yes, travis all fine, so let's go.

thanks!

Just a couple of test failures remain....these you know about?

```
C:\Users\Jeff Reback\Documents\GitHub\pandas>more test.33-64.log
............c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: unorderable types: str() < int(), sort order is undefined for incomparable o
bjects
  "incomparable objects" % e, RuntimeWarning)
c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: unorderable types: int() < str(), sort order is undefined for incomparable objects
  "incomparable objects" % e, RuntimeWarning)
..c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1028: RuntimeWarning: unorderable types: int() > str(), sort order is undefined for incomparable objects
  "incomparable objects" % e, RuntimeWarning)
c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1028: RuntimeWarning: unorderable types: str() > int(), sort order is undefined for incomparable objects
  "incomparable objects" % e, RuntimeWarning)
....................S...........S...........S...........S...............................................................................................................................................
.............................................................S...S.SSSS.....SSSSSSSSSSSSSSS.SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS.SS.S........................................................................................................................................
......S..........................................................................................................................................................S......................................
...........................................................................................................................................................S............................................
......................SS................Exception AttributeError: AttributeError("'File' object has no attribute '_node_manager'",) in .......Exception ValueError: ValueError('Bad tz filename. Dateuti
l on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones implicitly by passing a string like "dateutil/Europe/London"
 when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tslib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
ib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
ib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
ib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
ib._localize_tso' ignored
E..SSSS............................S...................................................S.................SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS....S......................................................
.............S.............................SSSSSSSSSSS..................................................................................................................................................
.............................S..........S..................................S..................S..S.SSSSSSS.......................S.......S..........S......S.....SSSSSSSSSSSSSSSSSSSSSSSSSS.............
.....................................................................................................................................................SS......................................S..........
.............................................................................S..S.......................................................................................................................
..................................................S...S.................................................................................................................................................
...............................S........................................................................................................................................................................
........................................................S.............................................S.................................................................................................
...............E...............................................................................................................................................S........................................
....................................................................S...................................................................................................................................
............................................................................................................................................S.SSSSS.....................................................
...................................................................................................................S..S......................................S.S........................................
..................................................................................S.....................................................................................................................
........SS.....S...SS.......S.S.......................SS.....S...SS.......S.S..............SS..SS............................................S.....S..SS..S......S......S..............SS.SSSSS.S....S..
.....SSS.......................................................................................................................................................................................S......S.
..................................c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: Cannot compare type 'Timestamp' with type 'str', sort
order is undefined for incomparable objects
  "incomparable objects" % e, RuntimeWarning)
.................................................c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: Cannot compare type 'Timestamp' with ty
pe 'int', sort order is undefined for incomparable objects
  "incomparable objects" % e, RuntimeWarning)
....................................................................................................S............................................................................S.....S................
...............................................S........................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
..........................................................................................................................................................S.............................................
.....................................................................................................................S.....SS......................S...S.............SSS.........S............SS........
.....SSS....SSSS......................SSSSS..SS..............................................................................SS.........................................................................
....S.......................S.............................SS............................................S...............................................................................................
.....................................................................S.......
======================================================================
ERROR: test_append_with_timezones_dateutil (pandas.io.tests.test_pytables.TestHDFStore)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\tests\test_pytables.py", line 2097, in test_append_with_timezones_dateutil
    store.append('df_tz', df)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 911, in append
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 1270, in _write_to_group
    s.write(obj=value, append=append, complib=complib, **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3605, in write
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3293, in create_axes
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3288, in create_axes
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 1755, in set_atom
    "invalid timezone specification")
TypeError: invalid timezone specification

======================================================================
ERROR: test_utc_with_system_utc (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tslib.pyx", line 862, in pandas.tslib._get_utcoffset (pandas\tslib.c:15096)
AttributeError: 'tzwin' object has no attribute '_utcoffset'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\tseries\tests\test_timezones.py", line 795, in test_utc_with_system_utc
    ts = Timestamp('2001-01-05 11:56', tz=maybe_get_tz('dateutil/UTC'))
  File "tslib.pyx", line 196, in pandas.tslib.Timestamp.__new__ (pandas\tslib.c:5959)
  File "tslib.pyx", line 946, in pandas.tslib.convert_to_tsobject (pandas\tslib.c:16117)
  File "tslib.pyx", line 864, in pandas.tslib._get_utcoffset (pandas\tslib.c:15145)
  File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 31, in utcoffset
    if self._isdst(dt):
  File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 66, in _isdst
    self._dstweeknumber)
  File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 165, in picknthweekday
    first = datetime.datetime(year, month, 1, hour, minute)
ValueError: month must be in 1..12

----------------------------------------------------------------------
Ran 7001 tests in 139.652s

FAILED (SKIP=397, errors=2)

C:\Users\Jeff Reback\Documents\GitHub\pandas>
```

Argh! I thought I'd got them all. Running all of the tests was crashing
python on my Windows system so I was doing things a bit piecemeal. I'll
take a look when I get to work tomorrow. Sorry this has taken so many
goes...

On Monday, 9 June 2014, jreback notifications@github.com wrote:

> Just a couple of test failures remain....these you know about?
> 
> C:\Users\Jeff Reback\Documents\GitHub\pandas>more test.33-64.log
> ............c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: unorderable types: str() < int(), sort order is undefined for incomparable o
> bjects
>   "incomparable objects" % e, RuntimeWarning)
> c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: unorderable types: int() < str(), sort order is undefined for incomparable objects
>   "incomparable objects" % e, RuntimeWarning)
> ..c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1028: RuntimeWarning: unorderable types: int() > str(), sort order is undefined for incomparable objects
>   "incomparable objects" % e, RuntimeWarning)
> c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1028: RuntimeWarning: unorderable types: str() > int(), sort order is undefined for incomparable objects
>   "incomparable objects" % e, RuntimeWarning)
> ....................S...........S...........S...........S...............................................................................................................................................
> .............................................................S...S.SSSS.....SSSSSSSSSSSSSSS.SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
> SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS.SS.S........................................................................................................................................
> ......S..........................................................................................................................................................S......................................
> ...........................................................................................................................................................S............................................
> ......................SS................Exception AttributeError: AttributeError("'File' object has no attribute '_node_manager'",) in .......Exception ValueError: ValueError('Bad tz filename. Dateuti
> l on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones implicitly by passing a string like "dateutil/Europe/London"
>  when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tslib._localize_tso' ignored
> Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
> plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
> ib._localize_tso' ignored
> Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
> plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
> ib._localize_tso' ignored
> Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
> plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
> ib._localize_tso' ignored
> Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
> plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
> ib._localize_tso' ignored
> E..SSSS............................S...................................................S.................SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS....S......................................................
> .............S.............................SSSSSSSSSSS..................................................................................................................................................
> .............................S..........S..................................S..................S..S.SSSSSSS.......................S.......S..........S......S.....SSSSSSSSSSSSSSSSSSSSSSSSSS.............
> .....................................................................................................................................................SS......................................S..........
> .............................................................................S..S.......................................................................................................................
> ..................................................S...S.................................................................................................................................................
> ...............................S........................................................................................................................................................................
> ........................................................S.............................................S.................................................................................................
> ...............E...............................................................................................................................................S........................................
> ....................................................................S...................................................................................................................................
> ............................................................................................................................................S.SSSSS.....................................................
> ...................................................................................................................S..S......................................S.S........................................
> ..................................................................................S.....................................................................................................................
> ........SS.....S...SS.......S.S.......................SS.....S...SS.......S.S..............SS..SS............................................S.....S..SS..S......S......S..............SS.SSSSS.S....S..
> .....SSS.......................................................................................................................................................................................S......S.
> ..................................c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: Cannot compare type 'Timestamp' with type 'str', sort
> order is undefined for incomparable objects
>   "incomparable objects" % e, RuntimeWarning)
> .................................................c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: Cannot compare type 'Timestamp' with ty
> pe 'int', sort order is undefined for incomparable objects
>   "incomparable objects" % e, RuntimeWarning)
> ....................................................................................................S............................................................................S.....S................
> ...............................................S........................................................................................................................................................
> ........................................................................................................................................................................................................
> ........................................................................................................................................................................................................
> ........................................................................................................................................................................................................
> ........................................................................................................................................................................................................
> ........................................................................................................................................................................................................
> ........................................................................................................................................................................................................
> ........................................................................................................................................................................................................
> ........................................................................................................................................................................................................
> ..........................................................................................................................................................S.............................................
> .....................................................................................................................S.....SS......................S...S.............SSS.........S............SS........
> .....SSS....SSSS......................SSSSS..SS..............................................................................SS.........................................................................
> ....S.......................S.............................SS............................................S...............................................................................................
> 
> # .....................................................................S.......
> 
> ## ERROR: test_append_with_timezones_dateutil (pandas.io.tests.test_pytables.TestHDFStore)
> 
> Traceback (most recent call last):
>   File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\tests\test_pytables.py", line 2097, in test_append_with_timezones_dateutil
>     store.append('df_tz', df)
>   File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 911, in append
>     *_kwargs)
>   File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 1270, in _write_to_group
>     s.write(obj=value, append=append, complib=complib, *_kwargs)
>   File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3605, in write
>     *_kwargs)
>   File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3293, in create_axes
>     raise e
>   File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3288, in create_axes
>     *_kwargs)
>   File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 1755, in set_atom
>     "invalid timezone specification")
> TypeError: invalid timezone specification
> 
> # 
> 
> ## ERROR: test_utc_with_system_utc (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
> 
> Traceback (most recent call last):
>   File "tslib.pyx", line 862, in pandas.tslib._get_utcoffset (pandas\tslib.c:15096)
> AttributeError: 'tzwin' object has no attribute '_utcoffset'
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\tseries\tests\test_timezones.py", line 795, in test_utc_with_system_utc
>     ts = Timestamp('2001-01-05 11:56', tz=maybe_get_tz('dateutil/UTC'))
>   File "tslib.pyx", line 196, in pandas.tslib.Timestamp.**new** (pandas\tslib.c:5959)
>   File "tslib.pyx", line 946, in pandas.tslib.convert_to_tsobject (pandas\tslib.c:16117)
>   File "tslib.pyx", line 864, in pandas.tslib._get_utcoffset (pandas\tslib.c:15145)
>   File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 31, in utcoffset
>     if self._isdst(dt):
>   File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 66, in _isdst
>     self._dstweeknumber)
>   File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 165, in picknthweekday
>     first = datetime.datetime(year, month, 1, hour, minute)
> ValueError: month must be in 1..12
> 
> ---
> 
> Ran 7001 tests in 139.652s
> 
> FAILED (SKIP=397, errors=2)
> 
> C:\Users\Jeff Reback\Documents\GitHub\pandas>
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/pydata/pandas/pull/7362#issuecomment-45550550.

np....thanks for the followups!

So, the `pytables` test I just missed this when I was updating the tests to construct the `dateutil` timezones correctly.

The `test_utc_with_system_utc` is the one I added yesterday. Not sure how I missed that this was failing - it definitely fails for me on windows. The problem is that 

``` python
from dateutil.tz import gettz
from datetime import datetime
u = gettz('UTC')
u.utcoffset(datetime(2001, 1, 1))
```

raises an exception on Windows. The result of `gettz('UTC')` is a `tzwin` object that hasn't been constructed properly. Definitely a bug in `dateutil`  - see [this bug report](https://bugs.launchpad.net/dateutil/+bug/1010050).

Given that, I think it makes sense to skip the test on windows until the bug in `dateutil` is fixed.

I've run the tests in `pandas/io/tests/test_pytables.py` and `pandas/tseries/tests/test_timezones.py` on windows in python 2.7 and 3 and on linux in python 2.7. As I've only changed the tests in those files there shouldn't be any extra failures this time!

I've pushed the changes onto a new branch in the @AHLMSS repository [here](https://github.com/ahlmss/pandas/tree/tst7337_again), pull request [here](https://github.com/pydata/pandas/pull/7414)