-
-
Notifications
You must be signed in to change notification settings - Fork 406
Open
Milestone
Description
- I am on the latest Pendulum version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- Fedora 40:
- 3.0.0
Issue
An exception is raised when parsing specific date times.
Current date time on my machine, in case that is relevant.
>>> pendulum.now()
DateTime(2024, 8, 29, 16, 46, 14, 16970, tzinfo=Timezone('Europe/London'))
Example of the bad case:
>>> pendulum.parse('Tue, 02 Mar 2024 06:00:00 GMT', tz="UTC", strict=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sam/flexget.venv/lib64/python3.12/site-packages/pendulum/parser.py", line 30, in parse
return _parse(text, **options)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/flexget.venv/lib64/python3.12/site-packages/pendulum/parser.py", line 46, in _parse
return pendulum.datetime(
^^^^^^^^^^^^^^^^^^
File "/home/sam/flexget.venv/lib64/python3.12/site-packages/pendulum/__init__.py", line 143, in datetime
return DateTime.create(
^^^^^^^^^^^^^^^^
File "/home/sam/flexget.venv/lib64/python3.12/site-packages/pendulum/datetime.py", line 103, in create
tz = pendulum._safe_timezone(tz)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/flexget.venv/lib64/python3.12/site-packages/pendulum/__init__.py", line 112, in _safe_timezone
elif obj.tzname(None) == "UTC":
^^^^^^^^^^^^^^^^
File "/home/sam/flexget.venv/lib64/python3.12/site-packages/dateutil/tz/tz.py", line 238, in tzname
return self._tznames[self._isdst(dt)]
^^^^^^^^^^^^^^^
File "/home/sam/flexget.venv/lib64/python3.12/site-packages/dateutil/tz/tz.py", line 291, in _isdst
dstval = self._naive_is_dst(dt)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/flexget.venv/lib64/python3.12/site-packages/dateutil/tz/tz.py", line 259, in _naive_is_dst
timestamp = _datetime_to_timestamp(dt)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/flexget.venv/lib64/python3.12/site-packages/dateutil/tz/tz.py", line 1814, in _datetime_to_timestamp
return (dt.replace(tzinfo=None) - EPOCH).total_seconds()
^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'
Example of the good case:
>>> pendulum.parse('Tue, 02 Apr 2024 06:00:00 GMT', tz="UTC", strict=False)
DateTime(2024, 4, 2, 6, 0, 0, tzinfo=Timezone('UTC'))
This is affecting Flexget rss plugin, see: Flexget/Flexget#4036
vivodivivodivivodi
Metadata
Metadata
Assignees
Labels
No labels