New submission from Andrei Kulakov <andrei....@gmail.com>:

There are a few places where old code does essentially the same thing as 
`html.escape()`, and can be replaced with html.escape():

 - more readable
 - less error prone on refactorings
 - will benefit if html.escape() performance is improved in the future
 - will be easier to grep for in case in the future html.escape() is enhanced 
with new escapes & it will be useful to consider applying it to all instances 
where it is used.

Here's what I found:

https://github.com/python/cpython/blob/main/Lib/difflib.py#L1914

https://github.com/python/cpython/blob/09eb81711597725f853e4f3b659ce185488b0d8c/Lib/plistlib.py#L158

https://github.com/python/cpython/blob/09eb81711597725f853e4f3b659ce185488b0d8c/Lib/pydoc.py#L525

https://github.com/python/cpython/blob/09eb81711597725f853e4f3b659ce185488b0d8c/Lib/xml/dom/minidom.py#L306

(^ keep existing escape of double quote)

https://github.com/python/cpython/blob/09eb81711597725f853e4f3b659ce185488b0d8c/Lib/xml/sax/saxutils.py#L27

https://github.com/python/cpython/blob/09eb81711597725f853e4f3b659ce185488b0d8c/Lib/xmlrpc/client.py#L149

I can add a PR if this sounds good.

----------
components: Library (Lib)
messages: 396161
nosy: andrei.avk
priority: normal
severity: normal
status: open
title: html.escape can be used in a few places in the standard lib instead of 
similar existing code
type: enhancement
versions: Python 3.11

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44465>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to