web.safeunicode#12520
Conversation
for more information, see https://pre-commit.ci
|
Thank you for the contribution, @acaligac! 🤖 Copilot has been assigned for an initial review. @RayBB is assigned to this PR and currently has:
PR triage checklist (maintainers / Pam)
Note This comment was automatically generated by Pam, Open Library's Project AI Manager, on behalf of @mekarpeles. Pam is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting. |
There was a problem hiding this comment.
Pull request overview
This PR modernizes the codebase by removing uses of web.safeunicode(...) (a legacy web.py unicode helper) in favor of Python’s built-in str(...), aligning with Python 3 string handling and reducing reliance on deprecated web.py utilities.
Changes:
- Replaced
web.safeunicode(...)withstr(...)across the remaining occurrences in the OpenLibrary codebase. - Simplified a couple of dict comprehensions while performing the replacement.
- Updated URL redirect and table-of-contents normalization paths to use
str(...).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| openlibrary/utils/olmemcache.py | Uses str(...) for memcache multi-get result keys instead of web.safeunicode(...). |
| openlibrary/plugins/upstream/utils.py | Replaces web.safeunicode(...) with str(...) in HTML and upstream memcache key handling. |
| openlibrary/plugins/upstream/merge_authors.py | Uses str(...) when normalizing table-of-contents row titles. |
| openlibrary/plugins/ol_infobase.py | Uses str(...) when fixing table-of-contents row titles during JSON processing. |
| openlibrary/core/processors/readableurls.py | Uses str(...) for redirect URL concatenation and readable URL path components. |
RayBB
left a comment
There was a problem hiding this comment.
Thanks for opening the PR here and no worries about the last one.
This has no functional changes since the code is equal but to be safe anyway I pulled it down and ran locally and deployed to testing. Didn't hit any errors. Also for sanity asked AI to triple check and confirmed it's all good.
Closes #12513
replaces web.safeunicode w str()
(sorry for the crazy amount of edits the first time around, pre commit added soo many extra fixes when i ran it :))
Stakeholders