bpo-32892: Use ast.Constant instead of specific constant AST types. (GH-9445)

diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index a6a43d1..ca8096f 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -3840,9 +3840,6 @@
                         # "starred": "a = [1, 2, 3]; *a"
                         visit_Starred = bad_node
 
-                        # allow ellipsis, for now
-                        # visit_Ellipsis = bad_node
-
                     blacklist = DetectBadNodes()
                     blacklist.visit(module)
                     bad = blacklist.bad
@@ -3868,10 +3865,15 @@
                     py_default = 'None'
                     c_default = "NULL"
                 elif (isinstance(expr, ast.BinOp) or
-                    (isinstance(expr, ast.UnaryOp) and not isinstance(expr.operand, ast.Num))):
+                    (isinstance(expr, ast.UnaryOp) and
+                     not (isinstance(expr.operand, ast.Num) or
+                          (hasattr(ast, 'Constant') and
+                           isinstance(expr.operand, ast.Constant) and
+                           type(expr.operand.value) in (int, float, complex)))
+                    )):
                     c_default = kwargs.get("c_default")
                     if not (isinstance(c_default, str) and c_default):
-                        fail("When you specify an expression (" + repr(default) + ") as your default value,\nyou MUST specify a valid c_default.")
+                        fail("When you specify an expression (" + repr(default) + ") as your default value,\nyou MUST specify a valid c_default." + ast.dump(expr))
                     py_default = default
                     value = unknown
                 elif isinstance(expr, ast.Attribute):
@@ -3946,6 +3948,11 @@
         self.function.parameters[parameter_name] = p
 
     def parse_converter(self, annotation):
+        if (hasattr(ast, 'Constant') and
+            isinstance(annotation, ast.Constant) and
+            type(annotation.value) is str):
+            return annotation.value, True, {}
+
         if isinstance(annotation, ast.Str):
             return annotation.s, True, {}
 
diff --git a/Tools/parser/unparse.py b/Tools/parser/unparse.py
index 7e1cc4e..82c3c77 100644
--- a/Tools/parser/unparse.py
+++ b/Tools/parser/unparse.py
@@ -329,12 +329,6 @@
         self.leave()
 
     # expr
-    def _Bytes(self, t):
-        self.write(repr(t.s))
-
-    def _Str(self, tree):
-        self.write(repr(tree.s))
-
     def _JoinedStr(self, t):
         self.write("f")
         string = io.StringIO()
@@ -352,10 +346,6 @@
             meth = getattr(self, "_fstring_" + type(value).__name__)
             meth(value, write)
 
-    def _fstring_Str(self, t, write):
-        value = t.s.replace("{", "{{").replace("}", "}}")
-        write(value)
-
     def _fstring_Constant(self, t, write):
         assert isinstance(t.value, str)
         value = t.value.replace("{", "{{").replace("}", "}}")
@@ -384,6 +374,7 @@
 
     def _write_constant(self, value):
         if isinstance(value, (float, complex)):
+            # Substitute overflowing decimal literal for AST infinities.
             self.write(repr(value).replace("inf", INFSTR))
         else:
             self.write(repr(value))
@@ -398,16 +389,11 @@
             else:
                 interleave(lambda: self.write(", "), self._write_constant, value)
             self.write(")")
+        elif value is ...:
+            self.write("...")
         else:
             self._write_constant(t.value)
 
-    def _NameConstant(self, t):
-        self.write(repr(t.value))
-
-    def _Num(self, t):
-        # Substitute overflowing decimal literal for AST infinities.
-        self.write(repr(t.n).replace("inf", INFSTR))
-
     def _List(self, t):
         self.write("[")
         interleave(lambda: self.write(", "), self.dispatch, t.elts)
@@ -539,8 +525,7 @@
         # Special case: 3.__abs__() is a syntax error, so if t.value
         # is an integer literal then we need to either parenthesize
         # it or add an extra space to get 3 .__abs__().
-        if ((isinstance(t.value, ast.Num) and isinstance(t.value.n, int))
-           or (isinstance(t.value, ast.Constant) and isinstance(t.value.value, int))):
+        if isinstance(t.value, ast.Constant) and isinstance(t.value.value, int):
             self.write(" ")
         self.write(".")
         self.write(t.attr)