Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit c97a962

Browse files
Issue python#24824: Signatures of codecs.encode() and codecs.decode() now are
compatible with pydoc.
1 parent 83ee5a3 commit c97a962

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Core and Builtins
1515
Library
1616
-------
1717

18+
- Issue #24824: Signatures of codecs.encode() and codecs.decode() now are
19+
compatible with pydoc.
20+
1821
- Issue #24634: Importing uuid should not try to load libc on Windows
1922

2023
- Issue #24798: _msvccompiler.py doesn't properly support manifests

Modules/_codecsmodule.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ _codecs_lookup_impl(PyModuleDef *module, const char *encoding)
9191
/*[clinic input]
9292
_codecs.encode
9393
obj: object
94-
encoding: str(c_default="NULL") = sys.getdefaultencoding()
94+
encoding: str(c_default="NULL") = "utf-8"
9595
errors: str(c_default="NULL") = "strict"
9696
9797
Encodes obj using the codec registered for encoding.
9898
99-
encoding defaults to the default encoding. errors may be given to set a
99+
The default encoding is 'utf-8'. errors may be given to set a
100100
different error handling scheme. Default is 'strict' meaning that encoding
101101
errors raise a ValueError. Other possible values are 'ignore', 'replace'
102102
and 'backslashreplace' as well as any other name registered with
@@ -106,7 +106,7 @@ codecs.register_error that can handle ValueErrors.
106106
static PyObject *
107107
_codecs_encode_impl(PyModuleDef *module, PyObject *obj, const char *encoding,
108108
const char *errors)
109-
/*[clinic end generated code: output=5c073f62249c8d7c input=2440d769df020a0e]*/
109+
/*[clinic end generated code: output=5c073f62249c8d7c input=cd5b685040ff61f0]*/
110110
{
111111
if (encoding == NULL)
112112
encoding = PyUnicode_GetDefaultEncoding();
@@ -118,12 +118,12 @@ _codecs_encode_impl(PyModuleDef *module, PyObject *obj, const char *encoding,
118118
/*[clinic input]
119119
_codecs.decode
120120
obj: object
121-
encoding: str(c_default="NULL") = sys.getdefaultencoding()
121+
encoding: str(c_default="NULL") = "utf-8"
122122
errors: str(c_default="NULL") = "strict"
123123
124124
Decodes obj using the codec registered for encoding.
125125
126-
encoding defaults to the default encoding. errors may be given to set a
126+
Default encoding is 'utf-8'. errors may be given to set a
127127
different error handling scheme. Default is 'strict' meaning that encoding
128128
errors raise a ValueError. Other possible values are 'ignore', 'replace'
129129
and 'backslashreplace' as well as any other name registered with
@@ -133,7 +133,7 @@ codecs.register_error that can handle ValueErrors.
133133
static PyObject *
134134
_codecs_decode_impl(PyModuleDef *module, PyObject *obj, const char *encoding,
135135
const char *errors)
136-
/*[clinic end generated code: output=c81cbf6189a7f878 input=a351e5f5baad1544]*/
136+
/*[clinic end generated code: output=c81cbf6189a7f878 input=7702c0cc2fa1add6]*/
137137
{
138138
if (encoding == NULL)
139139
encoding = PyUnicode_GetDefaultEncoding();

Modules/clinic/_codecsmodule.c.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ _codecs_lookup(PyModuleDef *module, PyObject *arg)
4242
}
4343

4444
PyDoc_STRVAR(_codecs_encode__doc__,
45-
"encode($module, /, obj, encoding=sys.getdefaultencoding(),\n"
46-
" errors=\'strict\')\n"
45+
"encode($module, /, obj, encoding=\'utf-8\', errors=\'strict\')\n"
4746
"--\n"
4847
"\n"
4948
"Encodes obj using the codec registered for encoding.\n"
5049
"\n"
51-
"encoding defaults to the default encoding. errors may be given to set a\n"
50+
"The default encoding is \'utf-8\'. errors may be given to set a\n"
5251
"different error handling scheme. Default is \'strict\' meaning that encoding\n"
5352
"errors raise a ValueError. Other possible values are \'ignore\', \'replace\'\n"
5453
"and \'backslashreplace\' as well as any other name registered with\n"
@@ -80,13 +79,12 @@ _codecs_encode(PyModuleDef *module, PyObject *args, PyObject *kwargs)
8079
}
8180

8281
PyDoc_STRVAR(_codecs_decode__doc__,
83-
"decode($module, /, obj, encoding=sys.getdefaultencoding(),\n"
84-
" errors=\'strict\')\n"
82+
"decode($module, /, obj, encoding=\'utf-8\', errors=\'strict\')\n"
8583
"--\n"
8684
"\n"
8785
"Decodes obj using the codec registered for encoding.\n"
8886
"\n"
89-
"encoding defaults to the default encoding. errors may be given to set a\n"
87+
"Default encoding is \'utf-8\'. errors may be given to set a\n"
9088
"different error handling scheme. Default is \'strict\' meaning that encoding\n"
9189
"errors raise a ValueError. Other possible values are \'ignore\', \'replace\'\n"
9290
"and \'backslashreplace\' as well as any other name registered with\n"
@@ -1395,4 +1393,4 @@ _codecs_lookup_error(PyModuleDef *module, PyObject *arg)
13951393
#ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF
13961394
#define _CODECS_CODE_PAGE_ENCODE_METHODDEF
13971395
#endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */
1398-
/*[clinic end generated code: output=713a4081788da1bc input=a9049054013a1b77]*/
1396+
/*[clinic end generated code: output=9c9967048027c1c7 input=a9049054013a1b77]*/

0 commit comments

Comments
 (0)