| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
pendulum.instance() raised 'AttributeError: NoneType object has no attribute lower' for datetimes whose tzinfo is a pytz.FixedOffset. _safe_timezone() detects pytz zones via their localize() method and then uses their .zone name. Named pytz zones carry a zone string, but fixed-offset zones (pytz.FixedOffset) have zone = None, so that None was passed to timezone(), which crashed. Fall back to the tzinfo's UTC offset when there is no zone name, mirroring how other offset-only tzinfos are handled. Added a regression test (skipped when pytz is unavailable).
|
Addressed both review points and rebased onto current master:
A local editable build was attempted, but the native extension linker failed on this macOS environment before tests could start (undefined Python symbols); CI will exercise the test on the project’s supported build runners. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #807. pendulum.instance() raised AttributeError: 'NoneType' object has no attribute 'lower' for a datetime whose tzinfo is a pytz.FixedOffset:
Root cause
_safe_timezone() detects pytz timezones by the presence of a localize() method and then uses their .zone name:
Named pytz zones (e.g. America/New_York) expose a zone string, but fixed-offset zones (pytz.FixedOffset) have zone = None. That None was passed to timezone(None), which does name.lower() and crashes.
Fix
When a pytz zone has no zone name, fall back to its UTC offset (the same approach already used for other offset-only tzinfo objects further down the same branch). Named zones are unaffected.
Verification
Disclosure: prepared with AI assistance; reviewed and verified locally against the test suite.