Skip to content

Add stub for html._replace_charref from standard library#15925

Merged
AlexWaygood merged 1 commit into
python:mainfrom
quis:patch-1
Jun 19, 2026
Merged

Add stub for html._replace_charref from standard library#15925
AlexWaygood merged 1 commit into
python:mainfrom
quis:patch-1

Conversation

@quis

@quis quis commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

_replace_charref is defined here: https://github.com/python/cpython/blob/64fab74bd7288bfa67cd7727452febdaafed4270/Lib/html/__init__.py#L91-L115

Although it’s a private attribute we have a use case for importing it: We re-implement html.unescape using our own definition of _charref, but we don’t want to reimpliment _replace_charref. Example can be found in our codebase.

`_replace_charref` is defined here: https://github.com/python/cpython/blob/64fab74bd7288bfa67cd7727452febdaafed4270/Lib/html/__init__.py#L91-L115

Although it’s a private attribute we have a use case for importing it: We re-implement `html.unescape` using our own definition of `_charref`, but we don’t want to reimpliment `_replace_charref`. Example can be found [in our codebase](https://github.com/alphagov/notifications-utils/blob/1eccc101a96cf120ce7bdc71528222ebc694432b/notifications_utils/formatters.py#L161-L167).
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood merged commit fb2af66 into python:main Jun 19, 2026
58 checks passed
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.

2 participants