[New-bugs-announce] [issue20341] Argument Clinic: add "nullable ints"
report at bugs.python.org
Wed Jan 22 04:18:01 CET 2014
New submission from Larry Hastings:
Attached is a *preliminary* patch for Argument Clinic that adds nullable ints. If you use the converter "int(nullable=True), then:
* The type you get back is not int but "nullable_int_t", a structure
containing three fields: "error", "is_null", and "i". "error" is 1 if
there was an error in parsing, else 0. "is_null" is 1 if None was
passed in, else 0. "i" is the integer value if an integer was
passed in, else undefined.
* You may now use a default value of None. If you do, "is_null" is 1.
* You may still use a default integer. If you do, "i" will be set
* If you use neither then obviously it's a required argument.
I'd appreciate just a preliminary review, saying something like
"this is a good idea, keep going," or
"you should change your approach," or
"this is a bad idea and should not be committed," or
"you look very handsome today Larry".
I don't remember who specifically needed the nullable ints, so I just added a bunch of Derby contestants.
Serhiy: I also added a fix for the bug you mentioned in #20294 after it was closed: the docstring for __new__ and __init__ methods now uses the class name instead of the name of the method. Note that this fix doesn't matter much; once I commit a fix for #20189, that signature will always be hidden.
components: Extension Modules
nosy: Yury.Selivanov, brett.cannon, georg.brandl, larry, serhiy.storchaka, vajrasky, zach.ware
stage: patch review
title: Argument Clinic: add "nullable ints"
versions: Python 3.4
Added file: http://bugs.python.org/file33605/larry.nullable.ints.draft
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce