Skip to content

BUG: OSError 22 (Invalid argument) in tzconversion tests on Windows/Python 3.11 #63315

@sanchit122006

Description

@sanchit122006

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

Steps to Reproduce the Bug
Set up a Conda environment with Python 3.11 on Windows.

Install development dependencies (NumPy, Cython, etc.).

Build Pandas from the main branch using Meson in the Visual Studio Command Prompt (this step completes successfully).

Bash

# Command used for installation:
python -m pip install -ve . --no-build-isolation -Ceditable-verbose=true
Run the test suite:

Bash

pytest pandas

Issue Description

Summary of Bug

Running the Pandas test suite (pytest pandas) immediately fails on my Windows development environment, raising an OSError: [Errno 22] Invalid argument originating from the time.localtime() function within python-dateutil during time zone conversion tests.

This seems to be a platform-specific issue, likely related to a timestamp exceeding the valid range for the C runtime library on Windows for the tested dates.

Complete Traceback

Click to expand full traceback
FEExceptions caught in Qt event loop:
________________________________________________________________________________
Traceback (most recent call last):
  File "pandas/_libs/tslibs/tzconversion.pyx", line 128, in pandas._libs.tslibs.tzconversion.Localizer.utc_val_to_local_val
    return utc_val + _tz_localize_using_tzinfo_api(
  File "pandas/_libs/tslibs/tzconversion.pyx", line 759, in pandas._libs.tslibs.tzconversion._tz_localize_using_tzinfo_api
    dt = _astimezone(dts, tz)
  File "pandas/_libs/tslibs/tzconversion.pyx", line 791, in pandas._libs.tslibs.tzconversion._astimezone
    return tz.fromutc(result)
  File "C:\Users\My\.conda\envs\pandas-dev\Lib\site-packages\dateutil\tz\_common.py", line 144, in fromutc
    return f(self, dt)
  File "C:\Users\My\.conda\envs\pandas-dev\Lib\site-packages\dateutil\tz\_common.py", line 261, in fromutc
    _fold = self._fold_status(dt, dt_wall)
  File "C:\Users\My\.conda\envs\pandas-dev\Lib\site-packages\dateutil\tz\_common.py", line 196, in _fold_status
    if self.is_ambiguous(dt_wall):
  File "C:\Users\My\.conda\envs\pandas-dev\Lib\site-packages\dateutil\tz\tz.py", line 254, in is_ambiguous
    naive_dst = self._naive_is_dst(dt)
  File "C:\Users\My\.conda\envs\pandas-dev\Lib\site-packages\dateutil\tz\tz.py", line 260, in _naive_is_dst
    return time.localtime(timestamp + time.timezone).tm_isdst
OSError: [Errno 22] Invalid argument

### Expected Behavior

The test suite should run completely, with no fatal OSError exceptions.

### Installed Versions

<details>

<summary>Click to expand Environment Information</summary>

**OS/Compiler Environment:**
* OS: Windows (Issue reproduced in VS Native Tools Command Prompt)
* Python: 3.11.14 (from Miniforge/Conda)
* Build Method: Meson / pip install -ve . --no-build-isolation
* VS Build Tools: 2022

**Key Dependencies (from `pip show`):**
* pandas: 3.0.0rc0+21.g499c5d4dd5 (Built from `main` branch)
* numpy: 2.3.5
* python-dateutil: 2.9.0.post0
* tzdata: 2025.2

</details>

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI SlopSuspected of being AI-generated, which is not welcome.BugNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions