Commits

larry committed b3b844c

Fixed all tests, such as they are.

  • Participants
  • Parent commits 1939d20

Comments (0)

Files changed (5)

Modules/_cursesmodule.c

 /*[clinic checksum: d8356bece150cf73bc9fb2232bbc2d82e4ac663e]*/
 {
     PyCursesWindowObject *cwself = (PyCursesWindowObject *)self;
-    int coordinates_group = group_0;
-    int attr_group = group_2;
+    int coordinates_group = group_left_1;
+    int attr_group = group_right_1;
     int rtn;
     int type;
     chtype cch;

Modules/_weakref.c

         return 0;
     
     list = GET_WEAKREFS_LISTPTR(object);
-    return _PyWeakref_GetWeakrefCount(*list));
+    return _PyWeakref_GetWeakrefCount(*list);
 }
 
 

Modules/unicodedata.c

 unicodedata_decimal_impl(PyObject *self, PyObject *unichr, int group_right_1, PyObject *default_value)
 /*[clinic checksum: 50e03f3d417ba06c8da629739d08f8680a608e05]*/
 {
-    PyUnicodeObject *v = unichr;
+    PyUnicodeObject *v = (PyUnicodeObject *)unichr;
     int have_old = 0;
     long rc;
     Py_UCS4 c;
 
-    if (!group_1)
+    if (!group_right_1)
         default_value = NULL;
 
     c = getuchar(v);
 
 
 #
+# handle functions with zero arguments (zlibmodule copy)
+#
+# convert exit to a linear_format()
+# * generate without it and grep through the
+#   text to see if there is a "goto exit"
+# * if there is one, regenerate
+#
 # convert the N separate arrays of M object in CRenderData
 # into a single array of M objects that each support N properties?
 #
-# 
-
 
 _empty = inspect._empty
 _void = inspect._void
     def format_docstring(self):
         f = self.function
 
-        add, output = text_accumulator()
+        text, add, output = _text_accumulator()
         parameters = list(f.parameters.values())
 
         ##
             add(' -> ')
             add(f.return_converter.doc_default)
 
-        add('\n\n')
-
         docstring_first_line = output()
 
         # now fix up the places where the brackets look wrong
-        for old, new in (
-            (', ]', ',] '),
-            ):
-            docstring_first_line = docstring_first_line.replace(old, new)
+        docstring_first_line = docstring_first_line.replace(', ]', ',] ')
 
         # okay.  now we're officially building the
         # "prototype" section.
         for p in parameters:
             if not p.docstring.strip():
                 continue
+            add('\n')
             add("  ")
             add(p.name)
             add('\n')
                 add("    ")
                 add(line.rstrip())
                 add('\n')
+            text.pop()
         prototype = output()
 
-
         ##
         ## docstring body
         ##
         # http://mail.python.org/pipermail/python-dev/2013-June/127110.html
 
         # either the whole thing is empty, or the first line is non-blank
-        assert lines or (not lines[0])
-        if len(lines) >= 2 and lines[1]:
-            fail("Docstring for " + f.full_name + " does not have a summary line!\n" + 
-                "Every non-blank function docstring must start with\n" +
-                "a single line summary followed by an empty line.")
+        assert (not lines) or (lines[0])
+        if len(lines) >= 2:
+            if lines[1]:
+                fail("Docstring for " + f.full_name + " does not have a summary line!\n" + 
+                    "Every non-blank function docstring must start with\n" +
+                    "a single line summary followed by an empty line.")
+        else:
+            # the docstring is only one line right now, the summary line.
+            # add an empty line after the summary line so we have space
+            # between it and the {prototype} we're about to add.
+            lines.append('') # blank line after
 
         # ensure {prototype} is specified at most once
         # and add {prototype} to the front if it wasn't specified at all
         docstring = output()
 
         docstring = linear_format(docstring, prototype=prototype)
+        docstring = docstring.rstrip()
 
         return docstring
 
                 last_parameter = next(reversed(list(values)))
                 no_parameter_after_star = last_parameter.kind != inspect.Parameter.KEYWORD_ONLY
             if no_parameter_after_star: 
-                fail("Function " + clinic.name + " specifies '*' without any parameters afterwards.")
+                fail("Function " + self.function.name + " specifies '*' without any parameters afterwards.")
 
         # remove trailing whitespace from all parameter docstrings
         for name, value in self.function.parameters.items():
+import builtins
 import clinic
 from clinic import DSLParser
 import collections
 import unittest
 from unittest import TestCase
 
-
 class FakeConverter:
     def __init__(self, name, args):
         self.name = name
     def test_param_docstring(self):
         function = self.parse_function("""
 module os            
-os.stat as os_stat_fn -> None(default='stat_result')
+os.stat as os_stat_fn -> object(doc_default='stat_result')
 
    path: str
        Path to be examined""")
         p = function.parameters['path']
         self.assertEqual("Path to be examined", p.docstring)
-        self.assertEqual(function.return_converter.default, 'stat_result')
+        self.assertEqual(function.return_converter.doc_default, 'stat_result')
 
     def test_function_docstring(self):
         function = self.parse_function("""
 
 Perform a stat system call on the given path.""")
         self.assertEqual("""
+Perform a stat system call on the given path.
+
 os.stat(path)
   path
     Path to be examined
-
-Perform a stat system call on the given path.
 """.strip(), function.docstring)
 
     def test_explicit_parameters_in_docstring(self):
 
 This is the documentation for foo.
 
-    {parameters}
+    {prototype}
 
 Okay, we're done here.
 """)
         self.assertEqual("""
-foo.bar(x, y)
 This is the documentation for foo.
 
-    x
-      Documentation for x.
+    foo.bar(x, y)
+      x
+        Documentation for x.
 
 Okay, we're done here.
 """.strip(), function.docstring)
     path: str
 This/used to break Clinic!
 """)
+        with open('/home/larry/src/python/clinic/ZZZ.txt', 'w') as f:
+            print("x", file=f)
+        sys.exit("function.docstring:", repr(function.docstring))
         self.assertEqual("os.stat(path)\n\nThis/used to break Clinic!", function.docstring)
 
     def test_c_name(self):
 Docstring
 
 """)
-        self.assertEqual("foo.bar()\n\nDocstring", function.docstring)
+        self.assertEqual("Docstring\n\nfoo.bar()", function.docstring)
         self.assertEqual(0, len(function.parameters))
 
     def test_single_star(self):
   Not at column 0!
 """)
         self.assertEqual("""
+Not at column 0!
+
 foo.bar(x, *, y)
   x
     Nested docstring here, goeth.
-
-Not at column 0!
 """.strip(), function.docstring)
 
     def test_parser_regression_special_character_in_parameter_column_of_docstring_first_line(self):
     path: str
 This/used to break Clinic!
 """)
-        self.assertEqual("os.stat(path)\n\nThis/used to break Clinic!", function.docstring)
+        self.assertEqual("This/used to break Clinic!\n\nos.stat(path)", function.docstring)
 
     def test_directive(self):
         c = FakeClinic()