BUG: tz_localize(UTC) not making a copy by jbrockmendel · Pull Request #46460 · pandas-dev/pandas (original) (raw)

You may be aware, but looks like this PR didn't fully pass the CI checks

https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=75723&view=logs&jobId=f64eb602-b0ed-5dcc-0a60-a7288ad39597&j=f64eb602-b0ed-5dcc-0a60-a7288ad39597&t=129bd72d-2137-55bd-1811-c4ce50c6dce8

_______________________ test_tz_localize_to_utc_copies ________________________
[gw1] win32 -- Python 3.8.12 C:\Miniconda\envs\pandas-dev\python.exe

    def test_tz_localize_to_utc_copies():
        # GH#46460
        arr = np.arange(5, dtype="i8")
        result = tzconversion.tz_convert_from_utc(arr, tz=UTC)
        tm.assert_numpy_array_equal(result, arr)
        assert not np.shares_memory(arr, result)
    
>       result = tzconversion.tz_convert_from_utc(arr, tz=None)

pandas\tests\tslibs\test_conversion.py:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas\_libs\tslibs\tzconversion.pyx:506: in pandas._libs.tslibs.tzconversion.tz_convert_from_utc
    converted = _tz_convert_from_utc(vals, tz)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   local_val = utc_val + deltas[pos]
E   UnboundLocalError: local variable 'deltas' referenced before assignment

pandas\_libs\tslibs\tzconversion.pyx:571: UnboundLocalError