Skip to content

Don't use undocumented re.template()#1827

Merged
m-blaha merged 2 commits intorpm-software-management:masterfrom
hroncok:re_template
May 12, 2022
Merged

Don't use undocumented re.template()#1827
m-blaha merged 2 commits intorpm-software-management:masterfrom
hroncok:re_template

Conversation

@hroncok
Copy link
Copy Markdown
Contributor

@hroncok hroncok commented May 12, 2022

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.

hroncok added 2 commits May 12, 2022 16:39
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.
Copy link
Copy Markdown

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. dnf uses escape(needle), the regex cannot use backtracking, and so re.template() can be safely replaced with re.compile().

@hroncok
Copy link
Copy Markdown
Contributor Author

hroncok commented May 12, 2022

BTW I could actually use re.compile() here to make the diff less noisy, if you (the dnf maintains) prefer that.

@vstinner
Copy link
Copy Markdown

re.sub() calls re.compile() internally ;-) The change LGTM.

@m-blaha
Copy link
Copy Markdown
Member

m-blaha commented May 12, 2022

To be honest I have absolutely no idea what is re.template() supposed to do. So I tend to believe that you guys know better and merge the change.

@hroncok
Copy link
Copy Markdown
Contributor Author

hroncok commented May 12, 2022

To be honest I have absolutely no idea what is re.template() supposed to do.

Nobody does. That's why it is being removed from Python.

@m-blaha
Copy link
Copy Markdown
Member

m-blaha commented May 12, 2022

:)

@m-blaha m-blaha merged commit cda67a0 into rpm-software-management:master May 12, 2022
@hroncok hroncok deleted the re_template branch May 12, 2022 16:35
@hroncok
Copy link
Copy Markdown
Contributor Author

hroncok commented May 12, 2022

Do I need to open a bugzilla to get this backported to rawhide in the next ~1 month?

@m-blaha
Copy link
Copy Markdown
Member

m-blaha commented May 13, 2022

There should be new release by that time. But just to be sure and not to forget, I've backported your patch to rawhide right now. So no need for a bugzilla.

@hroncok
Copy link
Copy Markdown
Contributor Author

hroncok commented May 13, 2022

🙇

EDIT: This was meant as a thank you, but I've been told that it can mean to apologize, so calrifying.

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.

3 participants