Skip to content

CI: enable python3.15 job - #66473

Open
Alvaro-Kothe wants to merge 13 commits into
pandas-dev:mainfrom
Alvaro-Kothe:ci/python315
Open

CI: enable python3.15 job#66473
Alvaro-Kothe wants to merge 13 commits into
pandas-dev:mainfrom
Alvaro-Kothe:ci/python315

Conversation

@Alvaro-Kothe

Copy link
Copy Markdown
Member

Comment thread pandas/_libs/tslibs/strptime.pyx Outdated
Comment on lines +838 to +851
tz = parse_timezone_directive(group_val)
if group_val:
tz = parse_timezone_directive(group_val)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows python/cpython#132922. It changed the behavior to make the %z format optional.

$ cmd='import datetime; print(datetime.datetime.strptime("2010-01-01 12:00:00", "%Y-%m-%d %H:%M:%S%z"))'

$ /usr/bin/python3.14 -c "$cmd"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import datetime; print(datetime.datetime.strptime("2010-01-01 12:00:00", "%Y-%m-%d %H:%M:%S%z"))
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.14/_strptime.py", line 815, in _strptime_datetime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.14/_strptime.py", line 555, in _strptime
    raise ValueError("time data %r does not match format %r" %
                     (data_string, format))
ValueError: time data '2010-01-01 12:00:00' does not match format '%Y-%m-%d %H:%M:%S%z'

$ ~/opt/python315-asan/bin/python3.15 -c "$cmd"
2010-01-01 12:00:00

Is this change correct, or we should be raising an error in case group_val is None?

cc @jbrockmendel

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My instinct is that we should not be following the stdlib on this because it can lead to weird behavior in mixed-input cases. But I need to look into the consequences more closely before giving a strong opinion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do something like

if group_val is None:
    raise ValueError(f"time data \"{val}\" doesn't match format \"{fmt}\"")
tz = parse_timezone_directive(group_val)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we keep the existing behavior

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Alvaro-Kothe
Alvaro-Kothe marked this pull request as ready for review July 27, 2026 22:47
@Alvaro-Kothe
Alvaro-Kothe requested a review from mroeschke as a code owner July 27, 2026 22:47
Comment thread pandas/tests/indexes/test_old_base.py Outdated
msg = "index (0|0.5) is out of bounds for axis 0 with size 0"
else:
msg = "slice indices must be integers or None or have an __index__ method"
msg = (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we condition this on PY315 so that we can eventually simplify it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if it's better now. The only place where I didn't apply the conditional was in test_constructor_keyword, but added a comment to compensate.

Comment thread pandas/_libs/tslibs/strptime.pyx Outdated
us = int(s)
ns = us % 1000
us = us // 1000
# elif group_key == 'A':

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

23 corresponds to "N" in _parse_code_table. I think several of these are off

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the elif above it, since it's not present in CPython's code. Thanks for pointing it out.

@jbrockmendel

Copy link
Copy Markdown
Member

Does to_datetime(["2010-01-01 12:00:00+04:00"], format="%Y-%m-%d %H:%M:%S%:z") correctly raise ValueError? I think it might be an incorrect KeyError here

@Alvaro-Kothe

Copy link
Copy Markdown
Member Author

Does to_datetime(["2010-01-01 12:00:00+04:00"], format="%Y-%m-%d %H:%M:%S%:z") correctly raise ValueError? I think it might be an incorrect KeyError here

It was raising KeyError because colon_z was not in the dictionary. I ported python/cpython#136961 to handle %:z and added tests for it. If the intended behavior is to raise an error, we probably can check if colon_z was parsed and raise an error.

Seems that the error message "Cannot convert None to Decimal" only
occurs on linux.
Comment thread .github/workflows/unit-tests.yml Outdated
Comment thread .github/workflows/unit-tests.yml
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.

BUG: A test_to_datetime.py test fails on Python 3.15

3 participants