Skip to content

fix(standard-provider): convert all pendulum objects on virtualenv version mismatch#69438

Open
Alwaysgaurav1 wants to merge 2 commits into
apache:mainfrom
Alwaysgaurav1:fix/50752-python-virtualenv-pendulum-mismatch
Open

fix(standard-provider): convert all pendulum objects on virtualenv version mismatch#69438
Alwaysgaurav1 wants to merge 2 commits into
apache:mainfrom
Alwaysgaurav1:fix/50752-python-virtualenv-pendulum-mismatch

Conversation

@Alwaysgaurav1

Copy link
Copy Markdown

Description

When using PythonVirtualenvOperator with pendulum<3 in the virtual environment while the host runs Pendulum v3, pickling/unpickling fails because Pendulum's internal representations are incompatible across major versions.

The existing _pendulum_to_native_datetime function only converts pendulum.DateTime objects to native datetime.datetime. However, other Pendulum types (Date, Time, Duration, Timezone) can also leak into serialized arguments and return values, causing AttributeError exceptions like type object 'Timezone' has no attribute '_unpickle'.

This PR extends both the host-side and guest-side conversion functions to handle all Pendulum types:

  • pendulum.Datedatetime.date
  • pendulum.Timedatetime.time
  • pendulum.Durationdatetime.timedelta
  • pendulum.tz.timezone.PendulumTimezonezoneinfo.ZoneInfo or datetime.timezone

The guest-side _native_datetime_to_pendulum function in the Jinja2 template is also updated to convert the native types back to their Pendulum equivalents.

A new unit test test_pendulum_to_native_datetime_extended verifies all the new type conversions.

Closes: #50752

@Alwaysgaurav1 Alwaysgaurav1 force-pushed the fix/50752-python-virtualenv-pendulum-mismatch branch from bdb51a0 to 1f3771f Compare July 9, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Airflow 3: cannot run a PythonVirtualenvOperator with pendulum<3

1 participant