-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.11.0b1 regression: re.template removed without a deprecation period #92728
Comments
Python 3.11.0b1 removed it: python/cpython@b09184bf05 It might be resurrected for a proper deprecation period, but it is going away. See python/cpython#92728 I've looked at the original commit that introduced this code: 6707f47 There is no clear indication that would suggest why re.template was used.
However, I am not sure if I can revert the removal + deprecate after the feature freeze, or if I must only revert the removal in 3.11 and deprecate it in 3.12+. Will start with a PR to main anyway. EDIT: I won't send a PR before there is a consensus. |
Removal discussed at #91367 |
The discussion started in this larger issue about re "reorganization": #91308 |
I don't understand the purpose of the
The only thing which seems to be changed is that repetition is not supported by TEMPLATE:
|
Code search for "TEMPLATE" in re/sre source code files of Python 3.10:
|
To be honest, I don't understand the purpose of the |
If we decide to not revert the change, I suggest to document the removal in What's New in Python 3.11 and explain how to port impacted applications. For example, replace |
I suppose we should do that even if we "just" deprecate it. |
PEP 387 says: https://peps.python.org/pep-0387/#backwards-compatibility-rules
The rationale here is that since Yes, projects use and abuse private and undocumented functions, and yes, they are broken when these private/undocumented functions are changed or removed. I suggest to document the removal, but don't revert it. Projects using it can replace |
@pablogsal: As the Python 3.11 release manager, do you have an opinion on this removal? |
I cannot really relate to the "not documented == private" assumption, but I'll leave that decision to core contributors. However, if that is the consensus it would be great to have that written in the PEP. |
As for this specific case, |
I am surprised that this function was used anywhere. I searched on GitHub before removing it and did not found anything relevant on first 20 or like pages. The original intention of this function is not clear, but it was never correctly implemented. Instead, it started raising an error for repetition operations since 29c4ba9. I suppose that it was not the original intention. The comment about disabling backtracking is not completely true, because an alternation and a conditional pattern involve backtracking too. |
Python 3.11.0b1 removed it: python/cpython@b09184bf05 It might be resurrected for a proper deprecation period, but it is going away. See python/cpython#92728 I've looked at the original commit that introduced this code: 6707f47 There is no clear indication that would suggest why re.template was used.
People will use almost anything that'll get their job done. This particular example is almost 14 years old and I guess nobody remembers why they used it. There might be more code like this outside of our search possibilities (e.g. proprietary code). That's why I think a deprecation period is in order :) |
Undocumented functions do not require a deprecation period. A removal notice in whatsnew will suffice. This is doubly true for function that is flimsy, never fully implemented, and was at least partially disabled. |
Well, I removed it because I was going to add new features containing "template" in the name, and I thought that it can be confusing. But if you think that it is worth, I am not opposing to reverting #32300 and adding a deprecation warning instead. |
I have no opinion on this particular removal/deprecation, but just quickly want to point to PEP8 (https://peps.python.org/pep-0008/#public-and-internal-interfaces) and it's directive that: Perhaps there are reasons why this does not hold true for |
Yes, I believe that would be in the spirit of the policy. I will try to draft a PR shortly and then I will leave it for the others to decide if it's worth it. |
How long the deprecation period should be? Would the only 3.11 be enough? |
The policy speaks of 2 releases. |
…pythonGH-32300)" This reverts commit b09184b. Fixes python#92728
I've opened #93161 |
I disagree. |
Revert "bpo-47211: Remove function re.template() and flag re.TEMPLATE (pythonGH-32300)" This reverts commit b09184b. (cherry picked from commit 16a7e4a) Co-authored-by: Miro Hrončok <[email protected]>
Revert "bpo-47211: Remove function re.template() and flag re.TEMPLATE (GH-32300)" This reverts commit b09184b. (cherry picked from commit 16a7e4a) Co-authored-by: Miro Hrončok <[email protected]>
Thank you @hugovk for your investigation and PR. |
Thank you @hroncok for the PR ;) |
Bug report
In Python 3.10, the
re.template
function exists and is not deprecated:In Python 3.11.0b1 this function is gone:
This was removed in b09184bf05 without a depreciation period.
Despite being undocumented, projects actually use this function, see e.g. rpm-software-management/dnf#1827
Please restore this function and deprecate it in 3.11 and 3.12 if you want to remove it in 3.13. (That is how I understand PEP 387, section Making Incompatible Changes.)
Your environment
The text was updated successfully, but these errors were encountered: