diff -r 9d9c2b4850fc Lib/inspect.py --- a/Lib/inspect.py Fri Dec 27 14:06:15 2013 -0500 +++ b/Lib/inspect.py Wed Jan 01 19:19:12 2014 +0400 @@ -2003,7 +2003,6 @@ return cls(parameters, return_annotation=cls.empty) - @property def parameters(self): return self._parameters diff -r 9d9c2b4850fc Lib/pydoc.py --- a/Lib/pydoc.py Fri Dec 27 14:06:15 2013 -0500 +++ b/Lib/pydoc.py Wed Jan 01 19:19:12 2014 +0400 @@ -928,7 +928,7 @@ # So removing parentheses isn't truly safe. argspec = argspec[1:-1] # remove parentheses if not argspec: - argspec = '(...)' + argspec = getattr(object, '__text_signature__', '') or '(...)' decl = title + argspec + (note and self.grey( '%s' % note)) @@ -1323,7 +1323,7 @@ # So removing parentheses isn't truly safe. argspec = argspec[1:-1] # remove parentheses if not argspec: - argspec = '(...)' + argspec = getattr(object, '__text_signature__', '') or '(...)' decl = title + argspec + note if skipdocs: diff -r 9d9c2b4850fc Lib/test/test_capi.py --- a/Lib/test/test_capi.py Fri Dec 27 14:06:15 2013 -0500 +++ b/Lib/test/test_capi.py Wed Jan 01 19:19:12 2014 +0400 @@ -140,6 +140,12 @@ self.assertEqual(_testcapi.docstring_with_signature_and_extra_newlines.__text_signature__, "(parameter)") + self.assertEqual(_testcapi.docstring_with_multiline_signature.__doc__, + "This docstring has a valid signature.") + + self.assertEqual(_testcapi.docstring_with_multiline_signature.__text_signature__, + """(parameter1,\n parameter2, kwarg1='a',\n kwarg2='b') -> result""") + @unittest.skipUnless(threading, 'Threading required for this test.') class TestPendingCalls(unittest.TestCase): diff -r 9d9c2b4850fc Modules/_testcapimodule.c --- a/Modules/_testcapimodule.c Fri Dec 27 14:06:15 2013 -0500 +++ b/Modules/_testcapimodule.c Wed Jan 01 19:19:12 2014 +0400 @@ -2869,6 +2869,14 @@ "This docstring has a valid signature and some extra newlines." ); +PyDoc_STRVAR(docstring_with_multiline_signature, +"docstring_with_multiline_signature(parameter1,\n" +" parameter2, kwarg1='a',\n" +" kwarg2='b') -> result\n" +"\n" +"This docstring has a valid signature." +); + #ifdef WITH_THREAD typedef struct { PyThread_type_lock start_event; @@ -3087,6 +3095,9 @@ {"docstring_with_signature_and_extra_newlines", (PyCFunction)test_with_docstring, METH_NOARGS, docstring_with_signature_and_extra_newlines}, + {"docstring_with_multiline_signature", + (PyCFunction)test_with_docstring, METH_NOARGS, + docstring_with_multiline_signature}, #ifdef WITH_THREAD {"call_in_temporary_c_thread", call_in_temporary_c_thread, METH_O, PyDoc_STR("set_error_class(error_class) -> None")}, diff -r 9d9c2b4850fc Objects/methodobject.c --- a/Objects/methodobject.c Fri Dec 27 14:06:15 2013 -0500 +++ b/Objects/methodobject.c Wed Jan 01 19:19:12 2014 +0400 @@ -205,8 +205,17 @@ */ static const char *skip_signature(const char *trace) { - while (*trace && *trace != '\n') + int open_parens = 0; + + while (*trace && (*trace != '\n' || open_parens != 0)) { + if (*trace == '(') + open_parens++; + else if (*trace == ')') + open_parens--; + trace++; + } + return trace; }