summaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-09-14 12:24:05 +0300
committerGitHub <noreply@github.com>2019-09-14 12:24:05 +0300
commit279f44678c8b84a183f9eeb85e0b086228154497 (patch)
tree9cacd41975bf15ab7a94fc5ba6a2df57f8e02ee5 /Tools
parentd057b896f97e6d7447b9bf9246770c41cf205299 (diff)
downloadcpython-git-279f44678c8b84a183f9eeb85e0b086228154497.tar.gz
bpo-37206: Unrepresentable default values no longer represented as None. (GH-13933)
In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values (like in the optional third parameter of getattr). "None" should be used if None is accepted as argument and passing None has the same effect as not passing the argument at all.
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/clinic/clinic.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index cec7c5392d..c5edc7c933 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -43,9 +43,6 @@ NoneType = type(None)
version = '1'
-_empty = inspect._empty
-_void = inspect._void
-
NoneType = type(None)
class Unspecified:
@@ -2175,7 +2172,7 @@ class Function:
def __init__(self, parameters=None, *, name,
module, cls=None, c_basename=None,
full_name=None,
- return_converter, return_annotation=_empty,
+ return_converter, return_annotation=inspect.Signature.empty,
docstring=None, kind=CALLABLE, coexist=False,
docstring_only=False):
self.parameters = parameters or collections.OrderedDict()
@@ -2253,8 +2250,8 @@ class Parameter:
Mutable duck type of inspect.Parameter.
"""
- def __init__(self, name, kind, *, default=_empty,
- function, converter, annotation=_empty,
+ def __init__(self, name, kind, *, default=inspect.Parameter.empty,
+ function, converter, annotation=inspect.Parameter.empty,
docstring=None, group=0):
self.name = name
self.kind = kind
@@ -3231,6 +3228,8 @@ class str_converter(CConverter):
# sorry, clinic can't support preallocated buffers
# for es# and et#
self.c_default = "NULL"
+ if NoneType in accept and self.c_default == "Py_None":
+ self.c_default = "NULL"
def cleanup(self):
if self.encoding:
@@ -4433,7 +4432,7 @@ class DSLParser:
# mild hack: explicitly support NULL as a default value
if isinstance(expr, ast.Name) and expr.id == 'NULL':
value = NULL
- py_default = 'None'
+ py_default = '<unrepresentable>'
c_default = "NULL"
elif (isinstance(expr, ast.BinOp) or
(isinstance(expr, ast.UnaryOp) and