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 to that. * 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. ---------- assignee: larry components: Extension Modules files: larry.nullable.ints.draft messages: 208740 nosy: Yury.Selivanov, brett.cannon, georg.brandl, larry, serhiy.storchaka, vajrasky, zach.ware priority: normal severity: normal stage: patch review status: open title: Argument Clinic: add "nullable ints" type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file33605/larry.nullable.ints.draft _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20341> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com