Message248277
Larry, Serhiy,
After giving this some thought I think that my initial patch is a wrong approach here -- inspect module should not be touched to fix this issue.
With this patch applied, signature object for codecs.encode would have a Parameter with a bogus default value, breaking functions like 'BoundArguments.apply_defaults()' etc. In other words, whatever AC puts in 'signature.parameters['encoding'].default' must be an object that will be accepted by the function.
codecs.encode, if implemented in Python, would look like:
def encode(obj, encoding=None, errors='strict'):
if encoding is None:
encoding = sys.getdefaultencoding()
...
And that's how the signature should be defined for the C version (because that's what is actually happening in C code as well!)
The new patch changes the AC specs from
_codecs.encode
obj: object
encoding: str(c_default="NULL") = sys.getdefaultencoding()
errors: str(c_default="NULL") = "strict"
to
_codecs.encode
obj: object
encoding: str(accept={str, NoneType}) = NULL
errors: str(c_default="NULL") = "strict"
(docstring is updated too).
This change, by the way, is in accordance with PEP 436:
The values supplied for these [default] parameters must be compatible with ast.literal_eval. |
|
Date |
User |
Action |
Args |
2015-08-08 15:48:18 | yselivanov | set | recipients:
+ yselivanov, lemburg, doerwalter, ncoghlan, larry, serhiy.storchaka |
2015-08-08 15:48:18 | yselivanov | set | messageid: <1439048898.6.0.0152873821019.issue24824@psf.upfronthosting.co.za> |
2015-08-08 15:48:18 | yselivanov | link | issue24824 messages |
2015-08-08 15:48:17 | yselivanov | create | |
|