1. Larry Hastings
  2. python-clinic

Commits

Larry Hastings  committed a25fc3b

Restore Clinic's adding of ":<function_name>" to format strings.
Also fixed a minor formatting issue with docstring default arguments.

  • Participants
  • Parent commits 681ab4b
  • Branches default

Comments (0)

Files changed (5)

File Modules/_cursesmodule.c

View file
  • Ignore whitespace
 
     switch (PyTuple_Size(args)) {
         case 1:
-            if (!PyArg_ParseTuple(args, "O", &ch))
+            if (!PyArg_ParseTuple(args, "O:addch", &ch))
                 return NULL;
             break;
         case 2:
-            if (!PyArg_ParseTuple(args, "Ol", &ch, &attr))
+            if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr))
                 return NULL;
             attr_group = 1;
             break;
         case 3:
-            if (!PyArg_ParseTuple(args, "iiO", &x, &y, &ch))
+            if (!PyArg_ParseTuple(args, "iiO:addch", &x, &y, &ch))
                 return NULL;
             coordinates_group = 1;
             break;
         case 4:
-            if (!PyArg_ParseTuple(args, "iiOl", &x, &y, &ch, &attr))
+            if (!PyArg_ParseTuple(args, "iiOl:addch", &x, &y, &ch, &attr))
                 return NULL;
             coordinates_group = 1;
             attr_group = 1;
 
 static PyObject *
 curses_window_addch_impl(PyObject *self, int coordinates_group, int x, int y, PyObject *ch, int attr_group, long attr)
-/*[clinic end:be19ed7b4af4d1c41369a634a55e26e63c78c6b1]*/
+/*[clinic end:355e50ee04fc6675476cbe9baa1a06ff14450c03]*/
 {
     PyCursesWindowObject *cwself = (PyCursesWindowObject *)self;
     int rtn;

File Modules/_dbmmodule.c

View file
  • Ignore whitespace
     static char *_keywords[] = {"filename", "flags", "mode", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
-        "s|si", _keywords,
+        "s|si:open", _keywords,
         &filename, &flags, &mode))
         return NULL;
 
 
 static PyObject *
 dbmopen_impl(PyObject *self, const char *filename, const char *flags, int mode)
-/*[clinic end:eddc886e542945d959b44b483258bf038acf8872]*/
+/*[clinic end:e9fbed95f33e75b6955f97a464ce47252def3624]*/
 {
     int iflags;
 

File Modules/posixmodule.c

View file
  • Ignore whitespace
     static char *_keywords[] = {"path", "dir_fd", "follow_symlinks", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
-        "O&|$O&p", _keywords,
+        "O&|$O&p:stat", _keywords,
         path_converter, &path, OS_STAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks))
         return NULL;
 
 
 static PyObject *
 os_stat_impl(PyObject *self, path_t path, int dir_fd, int follow_symlinks)
-/*[clinic end:e68699739e4a08c6bd90c929e81d1ecb8ce75880]*/
+/*[clinic end:f3e6b328245207c240825782d908d3ff3a9c11c0]*/
 {
     PyObject *return_value = posix_do_stat("stat", &path, dir_fd, follow_symlinks);
     path_cleanup(&path);
     static char *_keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
-        "O&i|$O&pp", _keywords,
+        "O&i|$O&pp:access", _keywords,
         path_converter, &path, &mode, OS_ACCESS_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks))
         return NULL;
 
 
 static PyObject *
 os_access_impl(PyObject *self, path_t path, int mode, int dir_fd, int effective_ids, int follow_symlinks)
-/*[clinic end:1e4ada5759cb3a96018b35e4e9e353055cd0a52f]*/
+/*[clinic end:fc0d31ac4162e46966d2493cae19efdea34f583e]*/
 {
     PyObject *return_value = NULL;
 

File Modules/zlibmodule.c

View file
  • Ignore whitespace
 [clinic]*/
 
 PyDoc_STRVAR(zlib_decompress__doc__,
-"zlib.decompress(data[, max_length='0'])\n"
+"zlib.decompress(data[, max_length=0])\n"
 "\n"
 "  data\n"
 "        The binary data to decompress.\n"
     static char *_keywords[] = {"data", "max_length", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
-        "y*|i", _keywords,
+        "y*|i:decompress", _keywords,
         &data, &max_length))
         return NULL;
 
 
 static PyObject *
 zlib_decompress_impl(PyObject *self, Py_buffer data, int max_length)
-/*[clinic end:17e6c9039e8ea71e92f2287695f69abb5743b185]*/
+/*[clinic end:34d5ee75a33ac2c40a8c72f44fdfa5cc13bfd010]*/
 {
     compobject *zself = (compobject *)self;
     int err;

File clinic.py

View file
  • Ignore whitespace
 		# used by .format(**locals())
 		module_name = self.module_name
 		name = self.name
+		# for names which are themselves dotted
+		last_name = name.rpartition('.')[2]
 
 		is_optional = False
 		is_keyword_only = False
 		print()
 
 		# the methoddef define!
-		name_last = name.rpartition('.')[2]
 		meth_keywords = " | METH_KEYWORDS" if not self.flag('positional-only') else ''
 		print('#define {prototype_name_upper}_METHODDEF    \\'.format(**locals()))
-		print('    {{"{name_last}", (PyCFunction){prototype_name}, METH_VARARGS{meth_keywords}, {prototype_name}__doc__}}'.format(**locals()))
+		print('    {{"{last_name}", (PyCFunction){prototype_name}, METH_VARARGS{meth_keywords}, {prototype_name}__doc__}}'.format(**locals()))
 		print()
 
 		# the prototype!
 			for a in self.arguments:
 				format_units += a.format_unit()
 				parse_arguments.extend(a.parse_argument())
+			format_units += ':' + last_name
 
 			# "keywords" array for PyArg_ParseTupleAndKeywords
 			quoted_names = self.argument_list('keyword')
 						for a in group_to_arguments[group]:
 							print(a.format_unit(), end='')
 							parse_arguments.extend(a.parse_argument())
-					print('",', ", ".join(parse_arguments) + "))")
+					print(':' + last_name + '", ', end='')
+					print(", ".join(parse_arguments) + "))")
 					print("                return NULL;")
 					for group in bundle:
 						if group is not None: