test_str: the UCS4 adaptive search path is never exercised
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 20/100
Piste de recherche
Start with Lib/test/test_str.py beside test_find and review string_tests.BaseTest.test_adaptive_find to match its existing long-string setup. Add the proposed non-BMP character case and run the relevant string tests; done when the UCS4 adaptive search path is exercised. The issue says the author already has the change ready and plans to open a pull request.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
Objects/stringlib/fastsearch.h compiles adaptive_find once per character
width. The UCS4 copy never ran under the entire test suite, because the only test
that reaches the adaptive path, string_tests.BaseTest.test_adaptive_find, uses
ASCII strings.
Evidence
Coverage from a --coverage build of main running the full suite
(./python -m test -j4, 552 files, 52,070 tests):
Function 'ucs4lib_adaptive_find' Lines executed:0.00% of 39
Function 'ucs2lib_adaptive_find' Lines executed:66.67% of 39
Function 'ucs1lib_adaptive_find' Lines executed:71.79% of 39
Function 'asciilib_adaptive_find' Lines executed:79.49% of 39
Why the existing test misses it
The adaptive branch is taken only when, in Objects/stringlib/fastsearch.h:800:
- the haystack is at least 2500 characters,
- the needle is at least 100 characters (or the haystack at least 30000),
- the needle is at least a third of the haystack.
test_adaptive_find meets all three, but with 'a' and 'b', so the code that
runs is the ASCII or UCS1 instantiation. Nothing in the suite builds a haystack
that wide-and-long out of non-BMP characters, so the UCS4 instantiation stays
cold.
Proposal
Add a test next to test_find in Lib/test/test_str.py that repeats the same
shape with '\U0001d11e' and '\U0001d11f'. With that test present,
ucs4lib_adaptive_find goes from 0.00% to 89.74% of 39 lines, and the remaining
branches are the count and reverse-search modes, which are separate entry points.
This is a test-only change, so it does not alter behaviour. I have it ready and
will open a PR against this issue.
CPython versions tested on
CPython main branch (3.16.0a1+)
Operating systems tested on
Linux
Linked PRs
- gh-160502
- Langage dominant
- Python
- Étoiles
- 77.7k
- Forks
- 38.3k
- Merge moyen
- 14 h 29 min
- PR mergées (30 j)
- 699
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python/cpython
-
topic-socket type-bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
python/cpython#160561 · 7 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
tests topic-profiling type-bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
python/cpython#160334 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
extension-modules type-bug
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 1 jour
-
Remove unused FVS_* macrosOuverteinterpreter-core type-feature
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
python/cpython#160109 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
extension-modules type-bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
python/cpython#160001 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de python/cpython
Issues similaires
-
[Resource] agent-claimcheckOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
yzhao062/awesome-auditable-ai#45 ·
Les mainteneurs répondent en général sous 3 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
NVIDIA/flare-local-inference#90 ·
Les mainteneurs répondent en général sous 1 jour
-
area/streaming comp/gateway P2 platform/telegram type/bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
NousResearch/hermes-agent#144897 ·
Les mainteneurs répondent en général sous 1 jour
-
request-theme
Difficulté 1/5 Moins d'une heure Accessibilité débutants 66/100
LizardByte/ThemerrDB#9575 ·
Les mainteneurs répondent en général sous 1 jour