Skip to content
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

tools, tools.web: rework web.decode() to use modern stdlib #2205

Merged
merged 3 commits into from
Dec 16, 2021

Conversation

dgw
Copy link
Member

@dgw dgw commented Nov 1, 2021

Description

This fixes #2203 for 8.0. (The patch for 7.1.6 is a separate PR against the maintenance branch, #2204.)

Python 3.4 added the html.unescape() function to its standard library, and current versions of Python have MUCH better HTML-entity-replacement implementations than ours. Let's just use the included batteries.

This patch deprecates tools.web.entity() and the associated constant r_entity. tools.web.decode() no longer uses them, and in fact should probably be considered for deprecation itself. (Not done yet; deciding that will come separately, along with its siblings' TODO comments.)

Note that the import of web in tools/__init__.py had to be moved below the definition of tools.deprecated() to avoid causing a circular dependency error. Might as well do it now, since we'll probably mark more stuff in tools.web as deprecated during Sopel 8's dev cycle.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
  • I have tested the functionality of the things this change touches

dgw added 2 commits October 29, 2021 22:14
Python 3.4 added the `html.unescape()` function to its standard library,
and current versions of Python have MUCH better HTML-entity-replacement
implementations than ours. Let's just use the included batteries.

This patch deprecates `tools.web.entity()` and the associated constant
`r_entity`. `tools.web.decode()` no longer uses them, and in fact should
probably be considered for deprecation itself. (Not done yet; deciding
that will come separately, along with its siblings' TODO comments.)

Note that the import of `web` in `tools/__init__.py` had to be moved
below the definition of `tools.deprecated()` to avoid causing a circular
dependency error. Might as well do it now, since we'll probably mark
more stuff in `tools.web` as deprecated during Sopel 8's dev cycle.
Found some warnings that it "will be" removed, but it already has been.
@dgw dgw added the Housekeeping Code cleanup, removal of deprecated stuff, etc. label Nov 1, 2021
@dgw dgw added this to the 8.0.0 milestone Nov 1, 2021
@dgw dgw requested a review from a team November 1, 2021 03:14
Co-authored-by: Florian Strzelecki <[email protected]>
@dgw dgw requested a review from Exirel November 1, 2021 19:30
Copy link
Contributor

@Exirel Exirel left a comment

Choose a reason for hiding this comment

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

🚢

@dgw dgw merged commit 0078d5c into master Dec 16, 2021
@dgw dgw deleted the web.decode-cleanup branch December 16, 2021 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Housekeeping Code cleanup, removal of deprecated stuff, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"You[apos]re" result from Sopel's URL parser
2 participants