Skip to content

gh-55531: Implement normalize_encoding in C #136643

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Little fixes
  • Loading branch information
StanFromIreland committed Jul 14, 2025
commit b5f3df3a44dff71ea9795e12e510fd0de9eafdcb
2 changes: 1 addition & 1 deletion Lib/encodings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
class CodecRegistryError(LookupError, SystemError):
pass

def normalize_encoding(encoding, /):
def normalize_encoding(encoding):

""" Normalize an encoding name.

Expand Down
6 changes: 2 additions & 4 deletions Modules/_codecsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,17 +1027,15 @@ extern int _Py_normalize_encoding(const char *, char *, size_t, int);
/*[clinic input]
_codecs._normalize_encoding
encoding: str(encoding='ascii')
/

Normalize an encoding name *encoding*.

Used for encodings.normalize_encoding.
Does not convert to lower case (to_lower == 1).
Used for encodings.normalize_encoding. Does not convert to lower case.
[clinic start generated code]*/

static PyObject *
_codecs__normalize_encoding_impl(PyObject *module, char *encoding)
/*[clinic end generated code: output=d5e3a4b5266fbe96 input=ca002bbc262228f1]*/
/*[clinic end generated code: output=d5e3a4b5266fbe96 input=cdb53c013b2400e3]*/
{
size_t len = strlen(encoding);
if (len > PY_SSIZE_T_MAX) {
Expand Down
42 changes: 36 additions & 6 deletions Modules/clinic/_codecsmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3588,7 +3588,7 @@ PyUnicode_FromEncodedObject(PyObject *obj,
}

/* Normalize an encoding name like encodings.normalize_encoding()
Optionally covert convert to lowercase by setting *to_lower* to 1.
but allow to convert to lowercase if *to_lower* is true.
Return 1 on success, or 0 on error (encoding is longer than lower_len-1). */
int
_Py_normalize_encoding(const char *encoding,
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy