You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "hussein-awala (via GitHub)" <gi...@apache.org> on 2023/09/19 20:36:45 UTC

[GitHub] [airflow] hussein-awala commented on issue #34483: `pendulum.DateTime` objects now being serialized as python objects with non-standard timezones

hussein-awala commented on issue #34483:
URL: https://github.com/apache/airflow/issues/34483#issuecomment-1726432534

   A simple example to reproduce:
   ```python
   >>> import pendulum
   >>> from airflow.serialization.serializers.datetime import serialize, deserialize
   >>> dt = pendulum.now("Europe/Paris").in_tz("America/New_York")
   >>> dt
   DateTime(2023, 9, 19, 16, 35, 8, 500201, tzinfo=Timezone('America/New_York'))
   >>> serialized_dt = serialize(dt)
   >>> serialized_dt
   ({'timestamp': 1695155708.500201, 'tz': 'EDT'}, 'pendulum.datetime.DateTime', 1, True)
   >>> deserialize(classname=serialized_dt[1], version=serialized_dt[2], data=serialized_dt[0])
   Traceback (most recent call last):
     File "/home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.11/site-packages/pendulum/tz/zoneinfo/reader.py", line 50, in read_for
       file_path = pytzdata.tz_path(timezone)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.11/site-packages/pytzdata/__init__.py", line 74, in tz_path
       raise TimezoneNotFound('Timezone {} not found at {}'.format(name, filepath))
   pytzdata.exceptions.TimezoneNotFound: Timezone EDT not found at /home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.11/site-packages/pytzdata/zoneinfo/EDT
   
   During handling of the above exception, another exception occurred:
   
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/home/hussein.awala/hussein/airflow/airflow/serialization/serializers/datetime.py", line 70, in deserialize
       return DateTime.fromtimestamp(float(data[TIMESTAMP]), tz=timezone(data[TIMEZONE]))
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^
     File "/home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.11/site-packages/pendulum/tz/__init__.py", line 37, in timezone
       tz = _Timezone(name, extended=extended)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.11/site-packages/pendulum/tz/timezone.py", line 40, in __init__
       tz = read(name, extend=extended)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.11/site-packages/pendulum/tz/zoneinfo/__init__.py", line 9, in read
       return Reader(extend=extend).read_for(name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.11/site-packages/pendulum/tz/zoneinfo/reader.py", line 52, in read_for
       raise InvalidTimezone(timezone)
   pendulum.tz.zoneinfo.exceptions.InvalidTimezone: Invalid timezone "EDT"
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org