diff options
author | Larry Hastings <larry@hastings.org> | 2013-11-23 23:37:55 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2013-11-23 23:37:55 (GMT) |
commit | 44e2eaab5491881120aab43e2838da8afe7ab70e (patch) | |
tree | 92847876fa89736ab40d027431ff27e4973409c9 /Modules | |
parent | 7fa6e1aeea111e7d954b753fb483afc18f21add0 (diff) | |
download | cpython-44e2eaab5491881120aab43e2838da8afe7ab70e.zip cpython-44e2eaab5491881120aab43e2838da8afe7ab70e.tar.gz cpython-44e2eaab5491881120aab43e2838da8afe7ab70e.tar.bz2 |
Issue #19674: inspect.signature() now produces a correct signature
for some builtins.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cursesmodule.c | 12 | ||||
-rw-r--r-- | Modules/_datetimemodule.c | 12 | ||||
-rw-r--r-- | Modules/_dbmmodule.c | 23 | ||||
-rw-r--r-- | Modules/_opcode.c | 19 | ||||
-rw-r--r-- | Modules/_testcapimodule.c | 44 | ||||
-rw-r--r-- | Modules/_weakref.c | 12 | ||||
-rw-r--r-- | Modules/posixmodule.c | 19 | ||||
-rw-r--r-- | Modules/unicodedata.c | 14 | ||||
-rw-r--r-- | Modules/zlibmodule.c | 17 |
9 files changed, 116 insertions, 56 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 6e48693..98b81fe 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -134,6 +134,12 @@ typedef chtype attr_t; /* No attr_t type is available */ #define STRICT_SYSV_CURSES #endif +/*[clinic] +module curses +class curses.window +[clinic]*/ +/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + /* Definition of exception curses.error */ static PyObject *PyCursesError; @@ -550,8 +556,6 @@ PyCursesWindow_Dealloc(PyCursesWindowObject *wo) /* Addch, Addstr, Addnstr */ /*[clinic] -module curses -class curses.window curses.window.addch @@ -580,9 +584,9 @@ current settings for the window object. [clinic]*/ PyDoc_STRVAR(curses_window_addch__doc__, +"addch([x, y,] ch, [attr])\n" "Paint character ch at (y, x) with attributes attr.\n" "\n" -"curses.window.addch([x, y,] ch, [attr])\n" " x\n" " X-coordinate.\n" " y\n" @@ -646,7 +650,7 @@ curses_window_addch(PyObject *self, PyObject *args) static PyObject * curses_window_addch_impl(PyObject *self, int group_left_1, int x, int y, PyObject *ch, int group_right_1, long attr) -/*[clinic checksum: 094d012af1019387c0219a9c0bc76e90729c833f]*/ +/*[clinic checksum: 44ed958b891cde91205e584c766e048f3999714f]*/ { PyCursesWindowObject *cwself = (PyCursesWindowObject *)self; int coordinates_group = group_left_1; diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 13c4ecc..e4dc1bf 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -16,6 +16,12 @@ #include "datetime.h" #undef Py_BUILD_CORE +/*[clinic] +module datetime +class datetime.datetime +[clinic]*/ +/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + /* We require that C int be at least 32 bits, and use int virtually * everywhere. In just a few cases we use a temp long, where a Python * API returns a C long. In such cases, we have to ensure that the @@ -4140,8 +4146,6 @@ datetime_best_possible(PyObject *cls, TM_FUNC f, PyObject *tzinfo) } /*[clinic] -module datetime -class datetime.datetime @classmethod datetime.datetime.now @@ -4155,9 +4159,9 @@ If no tz is specified, uses local timezone. [clinic]*/ PyDoc_STRVAR(datetime_datetime_now__doc__, +"now(tz=None)\n" "Returns new datetime object representing current time local to tz.\n" "\n" -"datetime.datetime.now(tz=None)\n" " tz\n" " Timezone object.\n" "\n" @@ -4188,7 +4192,7 @@ exit: static PyObject * datetime_datetime_now_impl(PyTypeObject *cls, PyObject *tz) -/*[clinic checksum: 5e61647d5d1feaf1ab096c5406ccea17bb7b061c]*/ +/*[clinic checksum: ca3d26a423b3f633b260c7622e303f0915a96f7c]*/ { PyObject *self; diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c index 10f872d..10f8fb9 100644 --- a/Modules/_dbmmodule.c +++ b/Modules/_dbmmodule.c @@ -28,6 +28,12 @@ static char *which_dbm = "Berkeley DB"; #error "No ndbm.h available!" #endif +/*[clinic] +module dbm +class dbm.dbm +[clinic]*/ +/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + typedef struct { PyObject_HEAD int di_size; /* -1 means recompute */ @@ -43,12 +49,6 @@ static PyTypeObject Dbmtype; static PyObject *DbmError; -/*[clinic] -module dbm -class dbm.dbm -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ - /*[python] class dbmobject_converter(self_converter): type = "dbmobject *" @@ -278,9 +278,8 @@ Return the value for key if present, otherwise default. [clinic]*/ PyDoc_STRVAR(dbm_dbm_get__doc__, -"Return the value for key if present, otherwise default.\n" -"\n" -"dbm.dbm.get(key, [default])"); +"get(key, [default])\n" +"Return the value for key if present, otherwise default."); #define DBM_DBM_GET_METHODDEF \ {"get", (PyCFunction)dbm_dbm_get, METH_VARARGS, dbm_dbm_get__doc__}, @@ -318,7 +317,7 @@ dbm_dbm_get(PyObject *self, PyObject *args) static PyObject * dbm_dbm_get_impl(dbmobject *dp, const char *key, Py_ssize_clean_t key_length, int group_right_1, PyObject *default_value) -/*[clinic checksum: 5b4265e66568f163ef0fc7efec09410eaf793508]*/ +/*[clinic checksum: 28cf8928811bde51e535d67ae98ea039d79df717]*/ { datum dbm_key, val; @@ -461,9 +460,9 @@ Return a database object. [clinic]*/ PyDoc_STRVAR(dbmopen__doc__, +"open(filename, flags=\'r\', mode=0o666)\n" "Return a database object.\n" "\n" -"dbm.open(filename, flags=\'r\', mode=0o666)\n" " filename\n" " The filename to open.\n" " flags\n" @@ -498,7 +497,7 @@ exit: static PyObject * dbmopen_impl(PyModuleDef *module, const char *filename, const char *flags, int mode) -/*[clinic checksum: c1f2036017ec36a43ac6f59893732751e67c19d5]*/ +/*[clinic checksum: fb265f75641553ccd963f84c143b35c11f9121fc]*/ { int iflags; diff --git a/Modules/_opcode.c b/Modules/_opcode.c index c53f0e0..55cffe1 100644 --- a/Modules/_opcode.c +++ b/Modules/_opcode.c @@ -1,10 +1,12 @@ #include "Python.h" #include "opcode.h" - /*[clinic] - module _opcode +[clinic]*/ +/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + +/*[clinic] _opcode.stack_effect -> int @@ -19,18 +21,17 @@ Compute the stack effect of the opcode. [clinic]*/ PyDoc_STRVAR(_opcode_stack_effect__doc__, -"Compute the stack effect of the opcode.\n" -"\n" -"_opcode.stack_effect(opcode, [oparg])"); +"stack_effect(opcode, [oparg])\n" +"Compute the stack effect of the opcode."); #define _OPCODE_STACK_EFFECT_METHODDEF \ {"stack_effect", (PyCFunction)_opcode_stack_effect, METH_VARARGS, _opcode_stack_effect__doc__}, static int -_opcode_stack_effect_impl(PyObject *module, int opcode, int group_right_1, int oparg); +_opcode_stack_effect_impl(PyModuleDef *module, int opcode, int group_right_1, int oparg); static PyObject * -_opcode_stack_effect(PyObject *module, PyObject *args) +_opcode_stack_effect(PyModuleDef *module, PyObject *args) { PyObject *return_value = NULL; int opcode; @@ -62,8 +63,8 @@ exit: } static int -_opcode_stack_effect_impl(PyObject *module, int opcode, int group_right_1, int oparg) -/*[clinic checksum: 2312ded40abc9bcbce718942de21f53e61a2dfd3]*/ +_opcode_stack_effect_impl(PyModuleDef *module, int opcode, int group_right_1, int oparg) +/*[clinic checksum: e880e62dc7b0de73403026eaf4f8074aa106358b]*/ { int effect; if (HAS_ARG(opcode)) { diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 3362454..9662eb8 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -2842,6 +2842,33 @@ test_pyobject_setallocators(PyObject *self) return test_setallocators(PYMEM_DOMAIN_OBJ); } +PyDoc_STRVAR(docstring_empty, +"" +); + +PyDoc_STRVAR(docstring_no_signature, +"This docstring has no signature." +); + +PyDoc_STRVAR(docstring_with_invalid_signature, +"docstring_with_invalid_signature (boo)\n" +"\n" +"This docstring has an invalid signature." +); + +PyDoc_STRVAR(docstring_with_signature, +"docstring_with_signature(sig)\n" +"This docstring has a valid signature." +); + +PyDoc_STRVAR(docstring_with_signature_and_extra_newlines, +"docstring_with_signature_and_extra_newlines(parameter)\n" +"\n" +"\n" +"\n" +"This docstring has a valid signature and some extra newlines." +); + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, {"raise_memoryerror", (PyCFunction)raise_memoryerror, METH_NOARGS}, @@ -2953,6 +2980,23 @@ static PyMethodDef TestMethods[] = { (PyCFunction)test_pymem_setallocators, METH_NOARGS}, {"test_pyobject_setallocators", (PyCFunction)test_pyobject_setallocators, METH_NOARGS}, + {"no_docstring", + (PyCFunction)test_with_docstring, METH_NOARGS}, + {"docstring_empty", + (PyCFunction)test_with_docstring, METH_NOARGS, + docstring_empty}, + {"docstring_no_signature", + (PyCFunction)test_with_docstring, METH_NOARGS, + docstring_no_signature}, + {"docstring_with_invalid_signature", + (PyCFunction)test_with_docstring, METH_NOARGS, + docstring_with_invalid_signature}, + {"docstring_with_signature", + (PyCFunction)test_with_docstring, METH_NOARGS, + docstring_with_signature}, + {"docstring_with_signature_and_extra_newlines", + (PyCFunction)test_with_docstring, METH_NOARGS, + docstring_with_signature_and_extra_newlines}, {NULL, NULL} /* sentinel */ }; diff --git a/Modules/_weakref.c b/Modules/_weakref.c index af845ff..80de5da4 100644 --- a/Modules/_weakref.c +++ b/Modules/_weakref.c @@ -5,8 +5,11 @@ ((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o)) /*[clinic] - module _weakref +[clinic]*/ +/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + +/*[clinic] _weakref.getweakrefcount -> Py_ssize_t @@ -17,9 +20,8 @@ Return the number of weak references to 'object'. [clinic]*/ PyDoc_STRVAR(_weakref_getweakrefcount__doc__, -"Return the number of weak references to \'object\'.\n" -"\n" -"_weakref.getweakrefcount(object)"); +"getweakrefcount(object)\n" +"Return the number of weak references to \'object\'."); #define _WEAKREF_GETWEAKREFCOUNT_METHODDEF \ {"getweakrefcount", (PyCFunction)_weakref_getweakrefcount, METH_O, _weakref_getweakrefcount__doc__}, @@ -43,7 +45,7 @@ exit: static Py_ssize_t _weakref_getweakrefcount_impl(PyModuleDef *module, PyObject *object) -/*[clinic checksum: 015113be0c9a0a8672d35df10c63e3642cc23da4]*/ +/*[clinic checksum: 436e8fbe0297434375f039d8c2d9fc3a9bbe773c]*/ { PyWeakReference **list; diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 9143fea..d0bd2d9 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -190,7 +190,10 @@ corresponding Unix manual entries for more information on calls."); #endif /* ! __WATCOMC__ || __QNX__ */ - +/*[clinic] +module os +[clinic]*/ +/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ #ifndef _MSC_VER @@ -2404,7 +2407,6 @@ class dir_fd_converter(CConverter): /*[python checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ /*[clinic] -module os os.stat -> object(doc_default='stat_result') @@ -2435,9 +2437,9 @@ It's an error to use dir_fd or follow_symlinks when specifying path as [clinic]*/ PyDoc_STRVAR(os_stat__doc__, +"stat(path, *, dir_fd=None, follow_symlinks=True)\n" "Perform a stat system call on the given path.\n" "\n" -"os.stat(path, *, dir_fd=None, follow_symlinks=True) -> stat_result\n" " path\n" " Path to be examined; can be string, bytes, or open-file-descriptor int.\n" " dir_fd\n" @@ -2486,7 +2488,7 @@ exit: static PyObject * os_stat_impl(PyModuleDef *module, path_t *path, int dir_fd, int follow_symlinks) -/*[clinic checksum: b08112eff0ceab3ec2c72352da95ce73f245d104]*/ +/*[clinic checksum: 85a71ad602e89f8e280118da976f70cd2f9abdf1]*/ { return posix_do_stat("stat", path, dir_fd, follow_symlinks); } @@ -2567,9 +2569,9 @@ Note that most operations will use the effective uid/gid, therefore this [clinic]*/ PyDoc_STRVAR(os_access__doc__, +"access(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True)\n" "Use the real uid/gid to test for access to a path.\n" "\n" -"os.access(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True) -> True if granted, False otherwise\n" " path\n" " Path to be tested; can be string, bytes, or open-file-descriptor int.\n" " mode\n" @@ -2587,7 +2589,6 @@ PyDoc_STRVAR(os_access__doc__, " access will examine the symbolic link itself instead of the file\n" " the link points to.\n" "\n" -"{parameters}\n" "dir_fd, effective_ids, and follow_symlinks may not be implemented\n" " on your platform. If they are unavailable, using them will raise a\n" " NotImplementedError.\n" @@ -2628,7 +2629,7 @@ exit: static PyObject * os_access_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd, int effective_ids, int follow_symlinks) -/*[clinic checksum: b9f8ececb061d31b64220c29526bfee642d1b602]*/ +/*[clinic checksum: 636e835c36562a2fc11acab75314634127fdf769]*/ { PyObject *return_value = NULL; @@ -2724,9 +2725,9 @@ Return the name of the terminal device connected to 'fd'. [clinic]*/ PyDoc_STRVAR(os_ttyname__doc__, +"ttyname(fd)\n" "Return the name of the terminal device connected to \'fd\'.\n" "\n" -"os.ttyname(fd)\n" " fd\n" " Integer file descriptor handle."); @@ -2758,7 +2759,7 @@ exit: static char * os_ttyname_impl(PyModuleDef *module, int fd) -/*[clinic checksum: 61e4e525984cb293f949ccae6ae393c0011dfe8e]*/ +/*[clinic checksum: 0f368134dc0a7f21f25185e2e6bacf7675fb473a]*/ { char *ret; diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index 62ab957..eca0054 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -17,6 +17,12 @@ #include "ucnhash.h" #include "structmember.h" +/*[clinic] +module unicodedata +class unicodedata.UCD +[clinic]*/ +/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + /* character properties */ typedef struct { @@ -108,8 +114,7 @@ static Py_UCS4 getuchar(PyUnicodeObject *obj) /* --- Module API --------------------------------------------------------- */ /*[clinic] -module unicodedata -class unicodedata.UCD + unicodedata.UCD.decimal unichr: object(type='str') @@ -124,10 +129,9 @@ not given, ValueError is raised. [clinic]*/ PyDoc_STRVAR(unicodedata_UCD_decimal__doc__, +"decimal(unichr, default=None)\n" "Converts a Unicode character into its equivalent decimal value.\n" "\n" -"unicodedata.UCD.decimal(unichr, default=None)\n" -"\n" "Returns the decimal value assigned to the Unicode character unichr\n" "as integer. If no such value is defined, default is returned, or, if\n" "not given, ValueError is raised."); @@ -157,7 +161,7 @@ exit: static PyObject * unicodedata_UCD_decimal_impl(PyObject *self, PyObject *unichr, PyObject *default_value) -/*[clinic checksum: a0980c387387287e2ac230c37d95b26f6903e0d2]*/ +/*[clinic checksum: 9576fa55f4ea0be82968af39dc9d0283e634beeb]*/ { PyUnicodeObject *v = (PyUnicodeObject *)unichr; int have_old = 0; diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index b223aa7..425de98 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -165,6 +165,7 @@ PyZlib_Free(voidpf ctx, void *ptr) } /*[clinic] + zlib.compress bytes: Py_buffer Binary data to be compressed. @@ -179,9 +180,9 @@ Returns compressed string. [clinic]*/ PyDoc_STRVAR(zlib_compress__doc__, +"compress(bytes, [level])\n" "Returns compressed string.\n" "\n" -"zlib.compress(bytes, [level])\n" " bytes\n" " Binary data to be compressed.\n" " level\n" @@ -226,7 +227,7 @@ zlib_compress(PyModuleDef *module, PyObject *args) static PyObject * zlib_compress_impl(PyModuleDef *module, Py_buffer *bytes, int group_right_1, int level) -/*[clinic checksum: 03e857836db25448d4d572da537eb7faf7695d71]*/ +/*[clinic checksum: f490708eff84be652b5ebe7fe622ab73ac12c888]*/ { PyObject *ReturnVal = NULL; Byte *input, *output = NULL; @@ -742,6 +743,7 @@ save_unconsumed_input(compobject *self, int err) } /*[clinic] + zlib.Decompress.decompress data: Py_buffer @@ -760,9 +762,9 @@ Call the flush() method to clear these buffers. [clinic]*/ PyDoc_STRVAR(zlib_Decompress_decompress__doc__, +"decompress(data, max_length=0)\n" "Return a string containing the decompressed version of the data.\n" "\n" -"zlib.Decompress.decompress(data, max_length=0)\n" " data\n" " The binary data to decompress.\n" " max_length\n" @@ -803,7 +805,7 @@ exit: static PyObject * zlib_Decompress_decompress_impl(PyObject *self, Py_buffer *data, unsigned int max_length) -/*[clinic checksum: f83e91728d327462d7ccbee95299514f26b92253]*/ +/*[clinic checksum: 4683928665a1fa6987f5c57cada4a22807a78fbb]*/ { compobject *zself = (compobject *)self; int err; @@ -1029,16 +1031,15 @@ Return a copy of the compression object. [clinic]*/ PyDoc_STRVAR(zlib_Compress_copy__doc__, -"Return a copy of the compression object.\n" -"\n" -"zlib.Compress.copy()"); +"copy()\n" +"Return a copy of the compression object."); #define ZLIB_COMPRESS_COPY_METHODDEF \ {"copy", (PyCFunction)zlib_Compress_copy, METH_NOARGS, zlib_Compress_copy__doc__}, static PyObject * zlib_Compress_copy(PyObject *self) -/*[clinic checksum: 2551952e72329f0f2beb48a1dde3780e485a220b]*/ +/*[clinic checksum: 8d30351f05defbc2b335c2a78d18f07aa367bb1d]*/ { compobject *zself = (compobject *)self; compobject *retval = NULL; |