Skip to content

Align regex, dataclasses and typing with Python 3.15 - #9189

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:split/regex-typing-315
Oct 18, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:split/regex-typing-315

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

Extract the regex/dataclasses/typing compatibility batch from #8954, after #9179 landed.

  • Add native re.Pattern.prefixmatch and re.Scanner.prefixmatch aliases.
  • Refresh the canonical regex consumers, dataclasses annotation handling, typing APIs, and associated regression tests/helpers.
  • Import all library changes through scripts/update_lib from CPython 3.15.0 commit d220409a13b77de7a6c30abe16ea90db01528edc, preserving existing RustPython markers and canonical guards.

The independent diff is 15 files: two native method attributes, five production library modules, and their tests/fixtures. No additional local skips, recursion-limit changes, or duplicate snippets were introduced.

Validation

Local validation used this commit on main 9f6f771965e93d0405bd2ab7958e084f82484f38. Main subsequently advanced to 3f55cf4af040a053892bec26061a1e472cd49b5f via #9163; there is no direct file overlap with this batch, and a source-only merge check is clean. Hosted merge CI will validate that newer integration.

On this commit:

  • Normal commit hooks passed.
  • Fresh release build and startup/loaded-library-path checks passed.
  • Eight candidate suites passed: selected test_re, test_dataclasses, test_typing, test_type_aliases, test_type_annotations, test_type_params, test_genericalias, and test_annotationlib.
  • VM getpath tests (5), the native fork-completion fixture (1), and default-profile C-API tests (123 passed, 4 ignored) passed. C-API-generated bytecode was preserved separately after the initial full-tree audit flagged it; final source/full-tree checks are clean.

The identical patch on its previous #9179-head base also passed all eight pinned CPython oracle suites, workspace native/doctests (1,394 passed), C-API tests (123 passed), and both strict Clippy gates. Those are prior-checkpoint results, not new full-aggregate claims for this rebased commit.

Local regex coverage excludes only ReTests.test_regression_gh94675 via the external runner because this environment previously denied its forkserver Unix-socket operation. The canonical source has no added local skip, and hosted CI keeps the full suite. Existing skips/expected failures and CPython-only exclusions remain visible; no omitted behavior is claimed as covered.

Assisted-by: OpenAI Codex:model version unavailable

Expose Pattern.prefixmatch and Scanner.prefixmatch and refresh their canonical re consumers, dataclasses annotation handling, typing APIs and regression fixtures from CPython d220409a13b77de7a6c30abe16ea90db01528edc.

Assisted-by: OpenAI Codex:model version unavailable
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bc20f63d-477e-40a5-8378-ed66099b1d27
📥 Commits

Reviewing files that changed from the base of the PR and between 3f55cf4 and b408fa0.

⛔ Files ignored due to path filters: 14
  • Lib/dataclasses.py is excluded by !Lib/**
  • Lib/re/__init__.py is excluded by !Lib/**
  • Lib/re/_compiler.py is excluded by !Lib/**
  • Lib/re/_parser.py is excluded by !Lib/**
  • Lib/test/test_dataclasses/__init__.py is excluded by !Lib/**
  • Lib/test/test_dataclasses/_types_proxy.py is excluded by !Lib/**
  • Lib/test/test_dataclasses/dataclass_module_3.py is excluded by !Lib/**
  • Lib/test/test_dataclasses/dataclass_module_3_str.py is excluded by !Lib/**
  • Lib/test/test_dataclasses/dataclass_module_4.py is excluded by !Lib/**
  • Lib/test/test_dataclasses/dataclass_module_4_str.py is excluded by !Lib/**
  • Lib/test/test_re.py is excluded by !Lib/**
  • Lib/test/test_type_aliases.py is excluded by !Lib/**
  • Lib/test/test_typing.py is excluded by !Lib/**
  • Lib/typing.py is excluded by !Lib/**
📒 Files selected for processing: 1
  • crates/vm/src/stdlib/_sre.rs
+--------------------------------------------------------------+
| Random thought: What if bugs are just undocumented features? |
+--------------------------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codspeed

codspeed Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:split/regex-typing-315 (b408fa0) with main (9f6f771)2

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (3f55cf4) during the generation of this report, so 9f6f771 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

:4: SyntaxWarning: invalid decimal literal
:7: SyntaxWarning: "\z" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\z"? A raw string is also an option.
:10: SyntaxWarning: "\400" is an invalid octal escape sequence. Such sequences will not work in the future. Did you mean "\400"? A raw string is also an option.
:4: SyntaxWarning: invalid decimal literal
:7: SyntaxWarning: "\z" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\z"? A raw string is also an option.
:10: SyntaxWarning: "\400" is an invalid octal escape sequence. Such sequences will not work in the future. Did you mean "\400"? A raw string is also an option.
:4: SyntaxWarning: invalid decimal literal
:7: SyntaxWarning: "\z" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\z"? A raw string is also an option.
:10: SyntaxWarning: "\400" is an invalid octal escape sequence. Such sequences will not work in the future. Did you mean "\400"? A raw string is also an option.
[x] lib: cpython/Lib/typing.py
[ ] test: cpython/Lib/test/test_typing.py (TODO: 1)
[x] test: cpython/Lib/test/test_type_aliases.py
[x] test: cpython/Lib/test/test_type_annotations.py
[x] test: cpython/Lib/test/test_type_params.py
[x] test: cpython/Lib/test/test_genericalias.py

dependencies:

  • typing

dependent tests: (20 tests)

  • typing: test_annotationlib test_builtin test_copy test_descr test_enum test_fractions test_funcattrs test_functools test_genericalias test_grammar test_inspect test_isinstance test_patma test_peg_generator test_pydoc test_pyrepl test_type_aliases test_type_params test_types test_typing

[x] lib: cpython/Lib/dataclasses.py
[x] test: cpython/Lib/test/test_dataclasses

dependencies:

  • dataclasses

dependent tests: (98 tests)

  • dataclasses: test__colorize test_copy test_ctypes test_enum test_genericalias test_patma test_pprint test_pydoc test_regrtest test_typing test_zoneinfo
    • pprint: test_htmlparser test_ssl test_sys_setprofile test_unittest
      • pdb: test_pdb
      • pickle: test_annotationlib test_argparse test_array test_ast test_asyncio test_bool test_builtin test_bytes test_bz2 test_codecs test_collections test_concurrent_futures test_configparser test_coroutines test_csv test_ctypes test_decimal test_defaultdict test_deque test_descr test_dict test_dictviews test_email test_enumerate test_exceptions test_fractions test_functools test_generators test_genericpath test_http_cookies test_importlib test_inspect test_io test_ipaddress test_iter test_itertools test_json test_list test_logging test_lzma test_memoryview test_minidom test_opcache test_operator test_ordered_dict test_os test_pathlib test_pickle test_picklebuffer test_pickletools test_platform test_plistlib test_positional_only_arg test_random test_range test_re test_set test_shelve test_slice test_socket test_statistics test_str test_string test_structseq test_super test_time test_trace test_tuple test_turtle test_type_aliases test_type_params test_types test_unittest test_uuid test_xml_dom_minicompat test_xml_etree test_xpickle test_zipfile test_zlib test_zoneinfo
    • pstats: test_profile test_pstats

[ ] test: cpython/Lib/test/test_sys.py (TODO: 4)
[x] test: cpython/Lib/test/test_syslog.py
[x] test: cpython/Lib/test/test_sys_setprofile.py (TODO: 1)
[ ] test: cpython/Lib/test/test_sys_settrace.py
[ ] test: cpython/Lib/test/test_audit.py (TODO: 14)
[ ] test: cpython/Lib/test/audit-tests.py

dependencies:

dependent tests: (236 tests)

  • sys: regrtestdata test___all__ test__colorize test__locale test__osx_support test_android test_annotationlib test_argparse test_array test_asdl_parser test_ast test_asyncio test_audit test_base64 test_bdb test_bigaddrspace test_bigmem test_binascii test_bisect test_buffer test_builtin test_bytes test_bz2 test_c_locale_coercion test_calendar test_class test_clinic test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_code_module test_codeccallbacks test_codecs test_collections test_compile test_compileall test_complex test_concurrent_futures test_context test_contextlib test_coroutines test_cprofile test_csv test_ctypes test_datetime test_dbm test_dbm_sqlite3 test_decimal test_descr test_dict test_difflib test_dis test_doctest test_doctest2 test_docxmlrpc test_dtrace test_dynamic test_dynamicclassattribute test_email test_embed test_ensurepip test_enum test_enumerate test_eof test_except_star test_exceptions test_external_inspection test_faulthandler test_fcntl test_file_eintr test_fileinput test_float test_fork1 test_format test_fractions test_frame test_frozen test_functools test_future_stmt test_gc test_generated_cases test_generators test_genericpath test_genexps test_getopt test_glob test_grammar test_gzip test_hash test_hashlib test_http_cookiejar test_httpservers test_importlib test_inspect test_int test_io test_ioctl test_iter test_itertools test_json test_launcher test_list test_listcomps test_locale test_logging test_long test_lzma test_mailbox test_marshal test_math test_memoryview test_metaclass test_mimetypes test_mmap test_monitoring test_msvcrt test_multibytecodec test_multiprocessing_main_handling test_netrc test_ntpath test_numeric_tower test_operator test_optparse test_ordered_dict test_os test_osx_env test_pathlib test_patma test_pdb test_peepholer test_perfmaps test_pickle test_pkg test_pkgutil test_platform test_plistlib test_popen test_posixpath test_print test_profile test_property test_pty test_pwd test_py_compile test_pyclbr test_pydoc test_pyexpat test_pyrepl test_quopri test_raise test_range test_re test_regrtest test_repl test_reprlib test_resource test_runpy test_sax test_scope test_script_helper test_select test_selectors test_shutil test_signal test_site test_slice test_smtplib test_socket test_sqlite3 test_ssl test_stable_abi_ctypes test_stat test_statistics test_str test_strftime test_string_literals test_strptime test_strtod test_struct test_subprocess test_support test_sys test_sys_setprofile test_sys_settrace test_sysconfig test_syslog test_tabnanny test_tarfile test_tempfile test_termios test_threading test_threading_local test_threadsignals test_time test_timeit test_tomllib test_tools test_trace test_traceback test_tracemalloc test_tuple test_type_cache test_type_comments test_types test_typing test_unicode_file test_unicode_file_functions test_unicodedata test_unittest test_urllib test_urllib2 test_urllib2net test_urlparse test_utf8_mode test_uuid test_venv test_wait3 test_wait4 test_wave test_weakref test_webbrowser test_winconsoleio test_winreg test_with test_wsgiref test_xml_etree test_xmlrpc test_xpickle test_zipapp test_zipfile test_zipfile64 test_zipimport test_zipimport_support test_zlib

[ ] test: cpython/Lib/test/test_pyrepl (TODO: 19)
[ ] test: cpython/Lib/test/test_repl.py (TODO: 5)

dependencies:

dependent tests: (no tests depend on pyrepl)

[x] lib: cpython/Lib/re
[ ] test: cpython/Lib/test/test_re.py (TODO: 4)
[x] test: cpython/Lib/test/re_tests.py

dependencies:

  • re

dependent tests: (83 tests)

  • re: test_android test_ast test_asyncio test_binascii test_builtin test_bytes test_clinic test_cmd_line test_ctypes test_dict test_dis test_docxmlrpc test_dtrace test_email test_embed test_faulthandler test_filecmp test_fileinput test_fnmatch test_format test_frame test_fstring test_functools test_future_stmt test_generated_cases test_genericalias test_glob test_hashlib test_http_cookiejar test_httplib test_httpservers test_imaplib test_importlib test_inspect test_ipaddress test_launcher test_logging test_mailbox test_mmap test_optparse test_ordered_dict test_platform test_pprint test_pydoc test_pyexpat test_pyrepl test_re test_regrtest test_runpy test_set test_site test_smtplib test_socket test_ssl test_strftime test_string test_strptime test_strtod test_structseq test_symtable test_syntax test_sys test_sysconfig test_tarfile test_tempfile test_tokenize test_tools test_traceback test_turtle test_types test_typing test_unittest test_unparse test_venv test_webbrowser test_winapi test_with test_wsgiref test_xmlrpc test_zipfile test_zipimport test_zoneinfo test_zstd

[ ] lib: cpython/Lib/runpy.py
[ ] test: cpython/Lib/test/test_runpy.py (TODO: 1)

dependencies:

  • runpy (native: importlib.machinery, importlib.util, sys)
    • io (native: _io, _thread, errno, msvcrt, sys)
    • pkgutil (native: importlib.machinery, importlib.util, marshal, os.path, sys)
    • os, warnings

dependent tests: (4 tests)

  • runpy: test_runpy
    • pdb: test_pdb
    • profile: test_profile
    • trace: test_trace

[ ] test: cpython/Lib/test/test_cmd_line.py (TODO: 22)

dependencies:

dependent tests: (no tests depend on cmd_line)

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

@youknowone
youknowone marked this pull request as ready for review October 18, 2026 13:37
@youknowone
youknowone merged commit 7137540 into RustPython:main Oct 18, 2026
23 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T13:47:36.784590Z b408fa0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b408fa0a3e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Lib/typing.py
field_names = [n for n, _ in fields]

nt = _make_nmtuple(typename, field_names, _make_eager_annotate(types), module=_caller())
nt = _make_nmtuple(typename, types, _make_eager_annotate(types), module=_caller())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep duplicate field names visible to namedtuple

When functional syntax contains duplicate names, such as NamedTuple('C', [('x', int), ('x', str)]), the preceding dict comprehension collapses the entries and passing that dict here makes collections.namedtuple silently create a one-field class using the last annotation. The previous field-name list instead raised the normal duplicate-field ValueError, so preserve the original names for namedtuple validation while materializing annotations separately.

Useful? React with 👍 / 👎.

Comment thread Lib/dataclasses.py
path = match[1].split(".")
root = sys.modules.get(cls.__module__)
for path_item in path:
root = getattr(root, path_item.strip(), None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bypass module getattr for annotation probing

When a dataclass lives in a module with PEP 562 __getattr__ and has an unresolved string annotation, this lookup invokes the module fallback; a non-AttributeError (or any side effect) now escapes and prevents class creation. The previous code used the module dictionary and treated the annotation as an ordinary field, so resolve the first path component directly from the module namespace before traversing nested proxy attributes.

Useful? React with 👍 / 👎.

Comment thread Lib/test/test_typing.py
self.assertEqual(gth(func2), {'args': Unpack[tuple[int, str]]})
hint = gth(func2)['args']
self.assertIsInstance(hint, types.GenericAlias)
self.assertEqual(hint.__args__[0], int)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Check all arguments of the rebuilt unpack alias

For the *tuple[int, str] get_type_hints cases, checking only index 0 lets the test pass even if rebuilding drops or replaces the trailing str, so it no longer protects the complete alias shape. Assert the entire __args__ tuple in both the direct and stringified cases; changing existing assertions or test logic is also disallowed by the repository's test policy.

AGENTS.md reference: AGENTS.md:L278-L278

Useful? React with 👍 / 👎.

youknowone pushed a commit that referenced this pull request Oct 19, 2026
* Align collections and testing libraries with Python 3.15

Refresh twelve production modules and canonical tests through scripts/update_lib at CPython d220409a13b77de7a6c30abe16ea90db01528edc. Preserve existing RustPython unittest helpers and test guards. Accept frozendict in native defaultdict and OrderedDict union slots, matching upstream PyAnyDict_Check without changing constructors, factories, or update order.

Validated as a local stack on the exact #9189 regex/dataclasses/typing prerequisite; this dependency avoids eager typing.ByteString deprecation during unittest warning tests.

Assisted-by: OpenAI Codex: model version unavailable

* Synchronize regression runner with doctest subtest reporting

Refresh the canonical test_regrtest consumer and its direct runner/pythoninfo closure through scripts/update_lib at CPython d220409a13b77de7a6c30abe16ea90db01528edc. Preserve both existing expected-failure markers. This aligns the runner test with doctest reporting two failed examples and one skipped example.

Assisted-by: OpenAI Codex: model version unavailable
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.

2 participants