Deprecate re.LOCALE
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 35.9k
- Métriques de merge des PR
- Métriques de PR en attente
Description
Feature or enhancement
Proposal:
Deprecate the re.LOCALE flag and the inline (?L) modifier: emit a DeprecationWarning when compiling a pattern that uses them, for removal no earlier than Python 3.18.
re.LOCALE only works with bytes patterns and only makes sense in 8-bit locales, which are rare today (it does not work in UTF-8 or other multibyte locales). It makes matching an order of magnitude slower: it excludes compile-time optimization of character sets, and at matching time it calls the locale-dependent C functions for every character instead of a table lookup. It also complicates the engine: every character class and case-insensitive operation needs a third variant beside the plain and Unicode ones, and every new optimization must special-case it.
A scan of the top 5,000 PyPI projects found 14 matches in 9 projects, and in the observed cases the flag was unnecessary. The replacement is to decode input and use str patterns, or to spell the needed byte semantics explicitly in the pattern.
This was discussed in 2023 in https://discuss.python.org/t/what-to-do-with-re-locale/32600 with a consensus for deprecation; matching str patterns with re.LOCALE has already been an error since Python 3.6 (bpo-22407).
Linked PRs
- gh-153178
Guide de contribution
Ouvrir 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.
Piste de recherche
Commencez par retracer la manière dont CPython compile le flag re.LOCALE et le modificateur inline (?L), puis examinez gh-153178 pour repérer le travail déjà en cours. Le travail est considéré comme terminé lorsque la compilation de l’une ou l’autre forme émet une DeprecationWarning, tout en préservant le calendrier de suppression indiqué et le comportement existant jusqu’à la suppression.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- backend
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100