Skip to content

Sync ten foundational Python libraries with Python 3.15 - #9140

Merged
youknowone merged 2 commits into
RustPython:mainfrom
youknowdot:split-pure-python-foundations-final
Oct 15, 2026
Merged

youknowone merged 2 commits into
RustPython:mainfrom
youknowdot:split-pure-python-foundations-final

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Split ten dependency-first Python libraries from #8954, with the minimal native annotation-order prerequisite exposed by their canonical functools coverage.

The ten modules, ordered with shared dependencies before their consumers:

  1. _py_abc
  2. stat
  3. genericpath
  4. ntpath
  5. posixpath
  6. functools
  7. gettext
  8. string (one package)
  9. optparse
  10. mimetypes

Run actual scripts/update_lib migrate individually for 25 implementation/test/support paths from CPython d220409a13b77de7a6c30abe16ea90db01528edc. Seven paths remain unchanged; the resulting diff is 18 files, +707/-194. The only departure from canonical source is the existing TestLRUPy.test_lru_hash_only_once expected-failure override, with its original reason and body preserved.

Includes ABC __class__ fallback parity, stat constants, path ALL_BUT_LAST/positional-only APIs, functools dispatch/cache updates, immutable gettext/optparse tables, string cleanup and MIME mapping/UTF-8 changes. Native ABC/functools prerequisites are on main except for the focused annotation-order correction included below. Deferred lazy-import/GC/native-dependent families are outside this batch.

Validation

  • Normal commit hooks passed; original tested head 4c0eab3; repaired tested head ea77258.
  • Matching narrow release CLI build passed after workspace/parser/XML package cleanup, retaining third-party caches. Features: threading,stdlib,stdio,importlib,host_env; --no-default-features --bin rustpython -j1 --offline --locked.
  • 21 selected canonical cases + 2 supplemental cases passed, each in a fresh process with optimize=0, no bytecode writes, private temporary directory, locale C, 30-second timeout (+5-second kill grace), 1 GiB memory cap and bounded combined output. Zero skips, expected failures or unexpected successes.
  • Separate natural-startup probe passed with real frozen import machinery and untouched candidate source-backed os/stat/path imports. The bounded case runner explicitly selects candidate library source; this is distinct from natural-startup validation and is not freeze-stdlib or ABI conformance certification.
  • stat and ntpath selections use faithful canonical AST method/helper/fixture extraction. An earlier full test_stat import hit the sandbox's AF_UNIX socket restriction before any stat test ran; that receipt was retained. A subsequent harness-only identity check was corrected to capture the actual fresh native-module generation. Final results use the corrected generation-bound checks without changing library sources.
  • All tracked source hashes rechecked after execution; worktree clean, no generated bytecode.

This is bounded selected-body coverage, not full test_stat/test_ntpath or full module-suite coverage, and does not claim Windows, GC/UAF, thread-stress or general subprocess coverage.

AI assistance is disclosed in the commit trailer.

CI repair: positional-only annotation ordering

The new canonical TestSingleDispatch.test_positional_only_argument exposed a native prerequisite in Ubuntu CI: compiler annotation emission placed regular positional parameters before positional-only parameters, so annotation-inferred singledispatch registered the wrong type. Follow-up ea77258db0f8c442c2be478e67c237983fdeee0a adds the exact +4/-4 compiler fix from the remaining mega changes. It emits positional-only annotations first, matching CPython. No Lib assertion, fixture, marker or expected-failure change was made.

The repaired head passed normal hooks, a fresh matching narrow release build, and strict scoped all-target rustpython-codegen Clippy. The original 23 bounded selections and natural startup probe passed again, as did the unchanged failing canonical method and a tiny six-entry annotation-order oracle. The same oracle passed on pinned exact-final CPython. All runs used fresh bounded processes with -S/-B, optimize0, C locale/private temporary directories and verified source/binary receipts; all original library hashes are unchanged. These are selected-case results, not full-suite coverage. Existing CI failures remain visible pending the new-head runs.

Migrate _py_abc, stat, genericpath, ntpath, posixpath, functools, gettext, string, optparse, and mimetypes with related canonical tests using scripts/update_lib from CPython d220409a13b77de7a6c30abe16ea90db01528edc. Preserve the existing pure LRU hash-count expected failure.

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

coderabbitai Bot commented Oct 15, 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: 089f91cf-2566-4b6e-8739-898f235b5496
📥 Commits

Reviewing files that changed from the base of the PR and between 8a9d66c and ea77258.

⛔ Files ignored due to path filters: 18
  • Lib/_py_abc.py is excluded by !Lib/**
  • Lib/functools.py is excluded by !Lib/**
  • Lib/genericpath.py is excluded by !Lib/**
  • Lib/gettext.py is excluded by !Lib/**
  • Lib/mimetypes.py is excluded by !Lib/**
  • Lib/ntpath.py is excluded by !Lib/**
  • Lib/optparse.py is excluded by !Lib/**
  • Lib/posixpath.py is excluded by !Lib/**
  • Lib/stat.py is excluded by !Lib/**
  • Lib/string/__init__.py is excluded by !Lib/**
  • Lib/test/test_abc.py is excluded by !Lib/**
  • Lib/test/test_functools.py is excluded by !Lib/**
  • Lib/test/test_genericpath.py is excluded by !Lib/**
  • Lib/test/test_mimetypes.py is excluded by !Lib/**
  • Lib/test/test_ntpath.py is excluded by !Lib/**
  • Lib/test/test_optparse.py is excluded by !Lib/**
  • Lib/test/test_posixpath.py is excluded by !Lib/**
  • Lib/test/test_string/_support.py is excluded by !Lib/**
📒 Files selected for processing: 1
  • crates/codegen/src/compile.rs
+---------------------------------+
| Bug-free code is the new black. |
+---------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ 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.

@github-actions

github-actions Bot commented Oct 15, 2026 •

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/optparse.py
[x] test: cpython/Lib/test/test_optparse.py

dependencies:

  • optparse

dependent tests: (3 tests)

  • optparse: test_decimal test_optparse
    • profile: test_profile

[ ] lib: cpython/Lib/pprint.py
[ ] test: cpython/Lib/test/test_pprint.py

dependencies:

  • pprint (native: sys)
    • collections (native: _collections, _weakref, itertools, sys)
    • dataclasses (native: itertools, sys)
    • io (native: _io, _thread, errno, msvcrt, sys)
    • re (native: _casefix, _constants, _sre, sys, unicodedata)
    • types (native: _types, sys)

dependent tests: (98 tests)

  • pprint: test_htmlparser test_pprint 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_enum test_enumerate test_exceptions test_fractions test_functools test_generators test_genericalias 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_memoryio 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_posix 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_typing test_unittest test_uuid test_xml_dom_minicompat test_xml_etree test_xpickle test_zipfile test_zlib test_zoneinfo
      • logging: test_asyncio test_concurrent_futures test_hashlib test_pkgutil test_support test_urllib2net
      • tracemalloc: test_tracemalloc

[x] lib: cpython/Lib/ntpath.py
[x] test: cpython/Lib/test/test_ntpath.py

dependencies:

  • ntpath

dependent tests: (55 tests)

  • ntpath: test_httpservers test_ntpath test_pathlib
    • pathlib: test_ast test_dbm_sqlite3 test_ensurepip test_importlib test_json test_launcher test_logging test_netrc test_os test_pathlib test_peg_generator test_pkgutil test_pyrepl test_runpy test_tarfile test_tempfile test_tomllib test_tools test_traceback test_unparse test_venv test_winapi test_zipapp test_zipfile test_zoneinfo test_zstd
      • compileall: test_compileall
      • importlib: test_asdl_parser test_bdb test_cmd_line_script test_codecs test_ctypes test_doctest test_external_inspection test_frozen test_hashlib test_importlib test_inspect test_linecache test_modulefinder test_multiprocessing_main_handling test_py_compile test_pyclbr test_pydoc test_reprlib test_sundry test_support test_unittest test_zipfile test_zipimport test_zoneinfo
      • zipapp: test_pdb

[x] lib: cpython/Lib/genericpath.py
[x] test: cpython/Lib/test/test_genericpath.py

dependencies:

  • genericpath

dependent tests: (40 tests)

  • genericpath: test_genericpath
    • ntpath: test_httpservers test_ntpath test_pathlib
      • pathlib: test_ast test_dbm_sqlite3 test_ensurepip test_importlib test_json test_launcher test_logging test_netrc test_os test_pathlib test_peg_generator test_pkgutil test_pyrepl test_runpy test_tarfile test_tempfile test_tomllib test_tools test_traceback test_unparse test_venv test_winapi test_zipapp test_zipfile test_zoneinfo test_zstd
    • posixpath: test_posixpath test_zipfile
      • fnmatch: test_embed test_fnmatch
      • http.server: test_robotparser test_urllib2_localnet test_xmlrpc
      • importlib.metadata: test_importlib
      • mimetypes: test_mimetypes
      • wsgiref.util: test_wsgiref

[x] lib: cpython/Lib/stat.py
[x] test: cpython/Lib/test/test_stat.py

dependencies:

  • stat

dependent tests: (125 tests)

  • stat: test__osx_support test_argparse test_asyncio test_dbm_dumb test_dbm_sqlite3 test_http_cookiejar test_importlib test_inspect test_os test_pathlib test_posix test_py_compile test_shutil test_site test_support test_tarfile test_tempfile test_zipapp test_zipfile
    • filecmp: test_compileall test_filecmp test_genericalias
    • genericpath: test_genericpath
      • ntpath: test_httpservers test_ntpath
      • posixpath: test_posixpath
    • glob: test_bz2 test_glob test_mailbox test_regrtest test_tokenize test_unicode_file test_zipimport
      • pathlib: test_ast test_ensurepip test_importlib test_json test_launcher test_logging test_netrc test_pathlib test_peg_generator test_pkgutil test_pyrepl test_runpy test_tomllib test_tools test_traceback test_unparse test_venv test_winapi test_zoneinfo test_zstd
      • pdb: test_pdb
    • netrc:
      • ftplib: test_ftplib test_urllib2
    • pathlib:
      • importlib: test_asdl_parser test_bdb test_cmd_line_script test_codecs test_ctypes test_doctest test_external_inspection test_frozen test_hashlib test_importlib test_linecache test_modulefinder test_multiprocessing_main_handling test_pyclbr test_pydoc test_reprlib test_sundry test_unittest test_zoneinfo
    • posixpath:
      • fnmatch: test_embed test_fnmatch
      • http.server: test_robotparser test_urllib2_localnet test_xmlrpc
      • mimetypes: test_mimetypes
      • wsgiref.util: test_wsgiref
    • shutil: test_ctypes test_largefile test_peepholer test_sax test_string_literals test_subprocess test_sysconfig
      • ctypes.util: test_ctypes
      • multiprocessing.util: test_asyncio test_concurrent_futures
      • tempfile: test_asyncio test_bytes test_cmd_line test_compile test_concurrent_futures test_contextlib test_cprofile test_csv test_dis test_faulthandler test_fileinput test_generated_cases test_importlib test_pickle test_pkg test_pstats test_pyrepl test_selectors test_shlex test_socket test_sys test_sys_settrace test_tabnanny test_termios test_threadedtempfile test_turtle test_urllib test_urllib_response test_winconsoleio test_zipfile64
      • webbrowser: test_webbrowser
    • zipfile: test_zipfile test_zipimport_support

[x] lib: cpython/Lib/abc.py
[x] lib: cpython/Lib/_py_abc.py
[x] test: cpython/Lib/test/test_abc.py

dependencies:

  • abc

dependent tests: (11 tests)

  • abc: test_abc test_abstract_numbers test_binop test_copy test_descr test_dynamicclassattribute test_functools test_inspect test_io test_pyexpat test_typing

[x] lib: cpython/Lib/string
[x] test: cpython/Lib/test/test_userstring.py

dependencies:

  • string

dependent tests: (77 tests)

  • string: test_annotationlib test_collections test_csv test_descr test_dict test_email test_fnmatch test_genericalias test_grp test_importlib test_inspect test_mmap test_ntpath test_pwd test_pyrepl test_re test_secrets test_shlex test_shutil test_socket test_string test_tokenize test_traceback test_weakset test_zipfile
    • idlelib: test_idle
    • logging: test_asyncio test_concurrent_futures test_decimal test_hashlib test_logging test_pkgutil test_support test_unittest test_urllib2net
      • asyncio.futures: test_asyncio
      • concurrent.futures._base: test_concurrent_futures
      • hashlib: test_hmac test_smtplib test_tarfile test_unicodedata test_urllib2_localnet
      • multiprocessing.util: test_asyncio test_compileall test_concurrent_futures
      • venv: test_venv
    • urllib.request: test_http_cookiejar test_pathlib test_pydoc test_sax test_site test_ssl test_urllib test_urllib2 test_urllibnet
      • pathlib: test_ast test_dbm_sqlite3 test_ensurepip test_httpservers test_importlib test_json test_launcher test_netrc test_os test_pathlib test_peg_generator test_pyrepl test_runpy test_tempfile test_tomllib test_tools test_unparse test_winapi test_zipapp test_zipfile test_zoneinfo test_zstd

[x] lib: cpython/Lib/posixpath.py
[x] test: cpython/Lib/test/test_posixpath.py

dependencies:

  • posixpath

dependent tests: (75 tests)

  • posixpath: test_pathlib test_posixpath test_zipfile
    • fnmatch: test_embed test_fnmatch test_os
      • bdb: test_bdb test_pdb
      • glob: test_bz2 test_glob test_mailbox test_regrtest test_site test_tokenize test_unicode_file test_zipimport
      • shutil: test_argparse test_compileall test_ctypes test_filecmp test_httpservers test_importlib test_inspect test_largefile test_launcher test_logging test_modulefinder test_peepholer test_peg_generator test_pkgutil test_py_compile test_reprlib test_sax test_shutil test_string_literals test_subprocess test_support test_sysconfig test_tarfile test_tempfile test_traceback test_venv test_zoneinfo
      • tracemalloc: test_tracemalloc
      • urllib.request: test_http_cookiejar test_pydoc test_ssl test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet
    • http.server: test_robotparser test_xmlrpc
      • pydoc: test_enum
      • wsgiref.simple_server: test_wsgiref
      • xmlrpc.server: test_docxmlrpc
    • importlib.metadata: test_importlib
    • mimetypes: test_mimetypes
    • pathlib: test_ast test_dbm_sqlite3 test_ensurepip test_importlib test_json test_netrc test_pathlib test_pyrepl test_runpy test_tomllib test_tools test_unparse test_winapi test_zipapp test_zipfile test_zstd

[x] lib: cpython/Lib/mimetypes.py
[x] test: cpython/Lib/test/test_mimetypes.py

dependencies:

  • mimetypes

dependent tests: (44 tests)

  • mimetypes: test_mimetypes
    • http.server: test_httpservers test_logging test_robotparser test_urllib2_localnet test_xmlrpc
      • pydoc: test_enum test_pydoc
      • wsgiref.simple_server: test_wsgiref
      • xmlrpc.server: test_docxmlrpc
    • urllib.request: test_http_cookiejar test_pathlib test_sax test_site test_ssl test_urllib test_urllib2 test_urllib2net test_urllibnet
      • pathlib: test_ast test_dbm_sqlite3 test_ensurepip test_importlib test_json test_launcher test_netrc test_os test_pathlib test_peg_generator test_pkgutil test_pyrepl test_runpy test_tarfile test_tempfile test_tomllib test_tools test_traceback test_unparse test_venv test_winapi test_zipapp test_zipfile test_zoneinfo test_zstd

[x] lib: cpython/Lib/gettext.py
[x] test: cpython/Lib/test/test_gettext.py

dependencies:

  • gettext

dependent tests: (209 tests)

  • gettext: test_gettext test_tools
    • argparse: test_argparse
      • ast: test_ast test_builtin test_codeop test_compile test_compiler_codegen test_dis test_fstring test_future_stmt test_peepholer test_peg_generator test_site test_ssl test_type_comments test_ucn test_unparse
      • calendar: test_calendar test_imaplib test_strftime
      • compileall: test_compileall
      • dis: test__opcode test_code test_compiler_assemble test_dtrace test_inspect test_monitoring test_opcache test_patma test_positional_only_arg test_type_cache
      • ensurepip: test_ensurepip test_venv
      • gzip: test_fileinput test_tarfile test_xmlrpc
      • http.server: test_httpservers test_logging test_robotparser test_urllib2_localnet
      • inspect: test_abc test_asyncgen test_buffer test_clinic test_collections test_coroutines test_decimal test_enum test_functools test_generators test_grammar test_ntpath test_operator test_posixpath test_pydoc test_signal test_sqlite3 test_traceback test_turtle test_type_annotations test_type_params test_types test_typing test_unittest test_yield_from test_zipimport test_zipimport_support test_zoneinfo
      • mimetypes: test_mimetypes
      • pdb: test_pdb
      • pickle: test_annotationlib test_array test_asyncio test_bool test_bytes test_bz2 test_codecs test_concurrent_futures test_configparser test_csv test_ctypes test_defaultdict test_deque test_descr test_dict test_dictviews test_email test_enumerate test_exceptions test_fractions test_genericalias test_genericpath test_http_cookies test_importlib test_io test_ipaddress test_iter test_itertools test_json test_list test_lzma test_memoryio test_memoryview test_minidom test_ordered_dict test_os test_pathlib test_pickle test_picklebuffer test_pickletools test_platform test_plistlib test_posix 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_type_aliases test_unittest test_uuid test_xml_dom_minicompat test_xml_etree test_xpickle test_zipfile test_zlib test_zoneinfo
      • platform: test__locale test__osx_support test_asyncio test_baseexception test_cmath test_ctypes test_fcntl test_math test_regrtest test_shutil test_strptime test_sysconfig test_winreg test_wsgiref
      • py_compile: test_cmd_line_script test_importlib test_modulefinder test_multiprocessing_main_handling test_py_compile test_runpy
      • random: test_asyncio test_bisect test_complex test_context test_dbm_dumb test_devpoll test_dummy_thread test_email test_float test_grp test_heapq test_hmac test_importlib test_int test_long test_mmap test_numeric_tower test_poll test_pow test_pprint test_pwd test_queue test_richcmp test_selectors test_sort test_strtod test_struct test_sys test_thread test_threading test_tokenize test_weakref test_zipfile test_zstd
      • sqlite3.main: test_sqlite3
      • tokenize: test_linecache test_tabnanny
      • webbrowser: test_webbrowser
      • zipapp: test_zipapp
      • zipfile: test_pkgutil test_zipfile test_zipfile64
    • getopt: test_getopt
      • base64: test_base64 test_smtplib test_urllib2
      • filecmp: test_filecmp
      • quopri: test_quopri
      • timeit: test_timeit
    • optparse: test_optparse
      • profile: test_profile

[x] lib: cpython/Lib/functools.py
[ ] test: cpython/Lib/test/test_functools.py (TODO: 1)

dependencies:

  • functools

dependent tests: (51 tests)

  • functools: test_annotationlib test_argparse test_asyncio test_builtin test_bytes test_call test_clinic test_codeop test_context test_contextlib_async test_ctypes test_datetime test_dbm_dumb test_dbm_sqlite3 test_dis test_doctest test_enum test_fileio test_fractions test_functools test_genericalias test_gettext test_gzip test_hmac test_inspect test_iter test_itertools test_math_property test_monitoring test_posixpath test_py_compile test_pyexpat test_pyrepl test_random test_repl test_reprlib test_shutil test_signal test_sort test_sqlite3 test_ssl test_sys_settrace test_timeout test_traceback test_typing test_unicodedata test_unittest test_webbrowser test_winsound test_xml_etree test_zoneinfo

Legend:

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

Emit positional-only annotations before regular positional annotations, matching declaration order and the canonical functools regression coverage.

Assisted-by: OpenAI Codex:model version unavailable
@youknowone
youknowone marked this pull request as ready for review October 15, 2026 11:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-15T11:50:21.304197Z ea77258 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.

@youknowone
youknowone merged commit 8f12a32 into RustPython:main Oct 15, 2026
20 of 21 checks passed

@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: ea77258db0

ℹ️ 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".

mime_dict = mimetypes.read_mime_types(filename)
mock_open.assert_called_with(filename, encoding='utf-8',
errors='surrogateescape')
mock_open.assert_called_with(filename, encoding='utf-8')

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 Restore the deleted malformed-MIME regression tests

When a MIME type file contains malformed UTF-8, this assertion change is accompanied by deletion of test_read_mime_types_invalid_utf8_comment and test_read_mime_types_invalid_utf8_type, eliminating the only regression coverage for the prior surrogate-escape behavior. The repository's critical test rules forbid both changing assertions and deleting test logic; retain these cases (marking them expected-failure if the strict behavior is currently required) instead of removing them.

AGENTS.md reference: AGENTS.md:L273-L275

Useful? React with 👍 / 👎.

Comment thread Lib/functools.py
raise TypeError(f'{funcname} requires at least '
'1 positional argument')
return self._dispatch(args[0].__class__).__get__(self._obj, self._cls)(*args, **kwargs)
method = self._dispatch(args[self._dispatch_arg_index].__class__)

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 Guard the second singledispatch argument before indexing

When a plain-function singledispatchmethod is accessed on the class and called with only its explicit instance, such as C.m(C()) for def m(self, value), _dispatch_arg_index is 1 while the existing guard only rejects an empty tuple. This line consequently raises IndexError: tuple index out of range instead of the expected missing-argument TypeError; check that the selected dispatch index exists before indexing.

Useful? React with 👍 / 👎.

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