Skip to content

Fix arrow.get() crash when tzinfo=None is explicitly passed#1260

Open
rexkirshner wants to merge 1 commit intoarrow-py:masterfrom
rexkirshner:fix-get-tzinfo-none
Open

Fix arrow.get() crash when tzinfo=None is explicitly passed#1260
rexkirshner wants to merge 1 commit intoarrow-py:masterfrom
rexkirshner:fix-get-tzinfo-none

Conversation

@rexkirshner
Copy link
Copy Markdown

Summary

Fixes #1259

arrow.get('2025-01-01', 'YYYY-MM-DD', tzinfo=None) raises TypeError because the factory's kwarg-detection logic treats an explicit tzinfo=None the same as an unrelated constructor kwarg (like year or month), incorrectly bumping arg_count to 3.

The one-line fix changes the condition from checking tz is None to checking "tzinfo" not in kwargs, which correctly distinguishes "tzinfo wasn't passed" from "tzinfo was explicitly passed as None."

Test plan

  • Added test_no_args_tzinfo_noneget(tzinfo=None) behaves like get()
  • Added test_one_arg_str_tzinfo_noneget("2013-01-01", tzinfo=None) parses as UTC
  • Added test_two_args_str_str_tzinfo_noneget("2013-01-01", "YYYY-MM-DD", tzinfo=None) parses as UTC (the exact case from the issue)
  • Full test suite passes (1905 tests, 99.93% coverage)

The condition for detecting non-tzinfo kwargs checked `tz is None`
instead of whether 'tzinfo' was actually absent from kwargs. This
caused `arrow.get('2025-01-01', 'YYYY-MM-DD', tzinfo=None)` to
incorrectly bump arg_count to 3, falling through to the constructor
path and raising TypeError.

Fixes arrow-py#1259

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b423717) to head (ca6f219).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1260   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         2315      2315           
  Branches       358       358           
=========================================
  Hits          2315      2315           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

arrow.get() behaviour for tzinfo=None

1 participant