Closed altendky closed 5 years ago
My best guess so far is that the Casablanca file previously ended with a single \n
but now has two. In Reader._parse_posix_tz()
with pytzdata==2018.7 '\n<+01>-1\n'
is read from the file thus passing '<+01>-1'
to posix_spec()
. With 2018.8 it instead reads out '\n\n'
which strips to ''
resulting in the InvalidPosixSpec
exception.
000003a0: 0000 0000 0008 0000 0e10 0004 4c4d 5400 ............LMT.
000003b0: 2b30 3100 2b30 3000 0000 0000 0000 0000 +01.+00.........
000003c0: 0a3c 2b30 313e 2d31 0a .<+01>-1.
000005d0: 1001 0400 0000 0000 0800 000e 1000 0400 ................
000005e0: 0000 0001 084c 4d54 002b 3031 002b 3030 .....LMT.+01.+00
000005f0: 0000 0000 0000 0000 0000 000a 0a .............
Looks to also have been raised in sdispater/pytzdata#8.
@sdispater pls, what is the state of this?
Reported again in #370. As noted there it looks to be fixed in https://github.com/sdispater/pendulum/commit/94d28b0d3cb524ae02361bd1ed7ea03e2e655e4e.
When working #357 I noticed a test was failing based on updated libraries since the last Travis build on master. It seems that pytzdata==2018.8 broke
test_timezones_are_loadable()
.https://github.com/sdispater/pytzdata/commit/af119bfa833acc4a548f64779d6683748bd8acc0
https://github.com/sdispater/pendulum/blob/d0eebd906e63f99ca9603f7d57b0f6d09ce75940/tests/tz/test_timezones.py#L12-L16
Specifically, it fails for
'Africa/Casablanca'
. I'll try to take a look at this and see if I can understand the issue.test results
```python ~/pendulum master poetry run python -m pytest tests ================================================= test session starts ================================================== platform linux -- Python 3.7.2, pytest-3.10.1, py-1.8.0, pluggy-0.9.0 rootdir: /home/altendky/pendulum, inifile: plugins: cov-2.6.1 collected 1097 items tests/test_helpers.py ................... [ 1%] tests/test_main.py . [ 1%] tests/test_parsing.py ...... [ 2%] tests/date/test_add.py ................ [ 3%] tests/date/test_behavior.py ........... [ 4%] tests/date/test_comparison.py ........................ [ 7%] tests/date/test_construct.py .. [ 7%] tests/date/test_day_of_week_modifiers.py ..................................................... [ 12%] tests/date/test_diff.py .................................................................... [ 18%] tests/date/test_fluent_setters.py ... [ 18%] tests/date/test_getters.py .............. [ 19%] tests/date/test_start_end_of.py ......................................... [ 23%] tests/date/test_strings.py ........ [ 24%] tests/date/test_sub.py ............... [ 25%] tests/datetime/test_add.py ................................ [ 28%] tests/datetime/test_behavior.py ......................... [ 30%] tests/datetime/test_comparison.py ................................... [ 34%] tests/datetime/test_construct.py ................ [ 35%] tests/datetime/test_create_from_timestamp.py ... [ 35%] tests/datetime/test_day_of_week_modifiers.py ....................................................... [ 40%] tests/datetime/test_diff.py .................................................................................... [ 48%] .............................................. [ 52%] tests/datetime/test_fluent_setters.py ................ [ 54%] tests/datetime/test_from_format.py .......................................................... [ 59%] tests/datetime/test_getters.py ....................................... [ 62%] tests/datetime/test_naive.py ......... [ 63%] tests/datetime/test_start_end_of.py ............................................ [ 67%] tests/datetime/test_strings.py ........................ [ 69%] tests/datetime/test_sub.py ............................ [ 72%] tests/datetime/test_timezone.py ... [ 72%] tests/duration/test_add_sub.py ....... [ 73%] tests/duration/test_arithmetic.py ... [ 73%] tests/duration/test_behavior.py .. [ 73%] tests/duration/test_construct.py ............ [ 74%] tests/duration/test_in_methods.py ..... [ 75%] tests/duration/test_in_words.py .......... [ 76%] tests/duration/test_total_methods.py ..... [ 76%] tests/formatting/test_formatter.py ..................... [ 78%] tests/helpers/test_local_time.py .. [ 78%] tests/localization/test_da.py . [ 78%] tests/localization/test_de.py . [ 79%] tests/localization/test_es.py . [ 79%] tests/localization/test_fa.py . [ 79%] tests/localization/test_fo.py . [ 79%] tests/localization/test_fr.py .. [ 79%] tests/localization/test_ko.py . [ 79%] tests/localization/test_lt.py . [ 79%] tests/parsing/test_parse_iso8601.py ... [ 79%] tests/parsing/test_parsing.py .................... [ 81%] tests/parsing/test_parsing_duration.py ...... [ 82%] tests/period/test_add_subtract.py ..... [ 82%] tests/period/test_arithmetic.py ... [ 83%] tests/period/test_behavior.py .. [ 83%] tests/period/test_construct.py ........ [ 83%] tests/period/test_hashing.py .. [ 84%] tests/period/test_range.py .......... [ 85%] tests/time/test_add.py ............ [ 86%] tests/time/test_behavior.py ..... [ 86%] tests/time/test_comparison.py .................... [ 88%] tests/time/test_construct.py .. [ 88%] tests/time/test_diff.py .................................................... [ 93%] tests/time/test_fluent_setters.py . [ 93%] tests/time/test_strings.py ...... [ 93%] tests/time/test_sub.py ............. [ 95%] tests/tz/test_helpers.py ... [ 95%] tests/tz/test_local_timezone.py ..s [ 95%] tests/tz/test_timezone.py ..................................... [ 99%] tests/tz/test_timezones.py .F [ 99%] tests/tz/zoneinfo/test_posix_timezone.py ... [ 99%] tests/tz/zoneinfo/test_reader.py ..... [100%] ======================================================= FAILURES ======================================================= _____________________________________________ test_timezones_are_loadable ______________________________________________ spec = '' def posix_spec(spec): # type: (str) -> PosixTimezone try: > return _posix_spec(spec) pendulum/tz/zoneinfo/posix_timezone.py:39: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ spec = '' def _posix_spec(spec): # type: (str) -> PosixTimezone m = _spec.match(spec) if not m: > raise ValueError("Invalid posix spec") E ValueError: Invalid posix spec pendulum/tz/zoneinfo/posix_timezone.py:47: ValueError During handling of the above exception, another exception occurred: def test_timezones_are_loadable(): zones = pendulum.timezones for zone in zones: > pendulum.timezone(zone) tests/tz/test_timezones.py:16: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pendulum/tz/__init__.py:36: in timezone tz = _Timezone(name, extended=extended) pendulum/tz/timezone.py:30: in __init__ tz = read(name, extend=extended) pendulum/tz/zoneinfo/__init__.py:9: in read return Reader(extend=extend).read_for(name) pendulum/tz/zoneinfo/reader.py:46: in read_for return self.read(file_path) pendulum/tz/zoneinfo/reader.py:58: in read return self._parse(fd) pendulum/tz/zoneinfo/reader.py:113: in _parse trule = self._parse_posix_tz(fd) pendulum/tz/zoneinfo/reader.py:211: in _parse_posix_tz return posix_spec(s) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ spec = '' def posix_spec(spec): # type: (str) -> PosixTimezone try: return _posix_spec(spec) except ValueError: > raise InvalidPosixSpec(spec) E pendulum.tz.zoneinfo.exceptions.InvalidPosixSpec: Invalid POSIX spec: pendulum/tz/zoneinfo/posix_timezone.py:41: InvalidPosixSpec =================================================== warnings summary =================================================== tests/formatting/test_formatter.py:241 /home/altendky/pendulum/tests/formatting/test_formatter.py:241: DeprecationWarning: invalid escape sequence \[ assert f.format(d, "[YYYY] YYYY \[YYYY\]") == "YYYY 2016 [2016]" tests/formatting/test_formatter.py:242 /home/altendky/pendulum/tests/formatting/test_formatter.py:242: DeprecationWarning: invalid escape sequence \D assert f.format(d, "\D D \\\D") == "D 28 \\28" tests/datetime/test_from_format.py::test_from_format_with_escaped_elements /home/altendky/pendulum/pendulum/formatting/formatter.py:406: DeprecationWarning: Flags not at the start of the expression '(?PForgive my bypassing of
poetry
while messing with the pytz[data] versions and reporting here. I haven't used poetry really yet.package versions
```python ✘ ~/pendulum master poetry run python -m pip freeze appdirs==1.4.3 aspy.yaml==1.2.0 atomicwrites==1.3.0 attrs==19.1.0 Babel==2.6.0 black==18.9b0 CacheControl==0.12.5 cachy==0.2.0 certifi==2019.3.9 cfgv==1.5.0 chardet==3.0.4 cleo==0.6.8 Click==7.0 coverage==4.5.3 filelock==3.0.10 html5lib==1.0.1 identify==1.4.0 idna==2.8 importlib-metadata==0.8 jsonschema==3.0.1 lockfile==0.12.2 more-itertools==5.0.0 msgpack==0.6.1 nodeenv==1.3.3 pastel==0.1.0 pendulum==2.0.4 pkginfo==1.5.0.1 pluggy==0.9.0 poetry==0.12.11 pre-commit==1.14.4 py==1.8.0 pylev==1.3.0 pyparsing==2.3.1 pyrsistent==0.14.11 pytest==3.10.1 pytest-cov==2.6.1 python-dateutil==2.8.0 pytz==2018.9 pytzdata==2018.8 PyYAML==3.13 requests==2.21.0 requests-toolbelt==0.8.0 shellingham==1.3.0 six==1.12.0 toml==0.10.0 tomlkit==0.5.3 tox==3.7.0 urllib3==1.24.1 virtualenv==16.4.3 webencodings==0.5.1 zipp==0.3.3 ```