From 43cec028a470ceb0a6dfcdabcf4b2d98c6c7e34c Mon Sep 17 00:00:00 2001 From: armorbreak001 Date: Wed, 22 Apr 2026 19:48:31 +0800 Subject: [PATCH] fix(factory): handle explicit tzinfo=None in arrow.get() When tzinfo=None is explicitly passed to arrow.get(), it was incorrectly treated as 'not provided', causing the factory to route to the 3-arg constructor path which fails for (str, fmt) calls. Use a sentinel to distinguish missing from explicit None. --- arrow/factory.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arrow/factory.py b/arrow/factory.py index 0913bfe1..04fde4e0 100644 --- a/arrow/factory.py +++ b/arrow/factory.py @@ -188,17 +188,22 @@ def get(self, *args: Any, **kwargs: Any) -> Arrow: arg_count = len(args) locale = kwargs.pop("locale", DEFAULT_LOCALE) - tz = kwargs.get("tzinfo", None) + _tz_missing = object() + tz = kwargs.get("tzinfo", _tz_missing) normalize_whitespace = kwargs.pop("normalize_whitespace", False) # if kwargs given, send to constructor unless only tzinfo provided if len(kwargs) > 1: arg_count = 3 - # tzinfo kwarg is not provided - if len(kwargs) == 1 and tz is None: + # tzinfo kwarg is not provided (distinguish from explicit tzinfo=None) + if len(kwargs) == 1 and tz is _tz_missing: arg_count = 3 + # Normalize explicit tzinfo=None to Python None for downstream code + if tz is _tz_missing: + tz = None + # () -> now, @ tzinfo or utc if arg_count == 0: if isinstance(tz, str):