Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arrow/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ def get(self, *args: Any, **kwargs: Any) -> Arrow:
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 (explicit tzinfo=None is treated as not provided)
if len(kwargs) == 1 and "tzinfo" not in kwargs:
arg_count = 3

# () -> now, @ tzinfo or utc
Expand Down
18 changes: 18 additions & 0 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,24 @@ def test_two_args_str_str(self):

assert result._datetime == datetime(2013, 1, 1, tzinfo=tz.tzutc())

def test_two_args_str_str_tzinfo_none(self):
# Regression test for issue #1259:
# Explicitly passing tzinfo=None must behave identically to omitting tzinfo.
# Previously this crashed with TypeError because len(kwargs)==1 and tz is None
# triggered the 3+ arg constructor path instead of the 2-arg str+format parse path.
result = self.factory.get("2025-01-01", "YYYY-MM-DD", tzinfo=None)
assert result._datetime == datetime(2025, 1, 1, tzinfo=tz.tzutc())

def test_no_args_tzinfo_none(self):
# Regression test for issue #1259:
# arrow.get(tzinfo=None) must return current UTC time, same as arrow.get().
from arrow.util import is_timestamp
result = self.factory.get(tzinfo=None)
now_utc = self.factory.utcnow()
# Allow a 2-second window to avoid flakiness
assert abs((result - now_utc).total_seconds()) < 2


def test_two_args_str_tzinfo(self):
result = self.factory.get("2013-01-01", tzinfo=ZoneInfo("US/Pacific"))

Expand Down