From 9e6629387daaee10adb18baa892b4af58d2c5a33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabi=C3=A1n=20Ezequiel=20Gallina?= Date: Thu, 17 May 2012 00:02:58 -0300 Subject: [PATCH] Eldoc integration is now compatible with python 3 --- lisp/progmodes/python.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index af441460562..739b137d566 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1413,14 +1413,19 @@ Optional argument JUSTIFY defines if the paragraph should be justified." "def __PYDOC_get_help(obj): try: import pydoc - obj = eval(obj, globals()) - return pydoc.getdoc(obj) + if hasattr(obj, 'startswith'): + obj = eval(obj, globals()) + doc = pydoc.getdoc(obj) except: - return ''" + doc = '' + try: + exec('print doc') + except SyntaxError: + print(doc)" "Python code to setup documentation retrieval.") (defvar python-eldoc-string-code - "print __PYDOC_get_help('''%s''')\n" + "__PYDOC_get_help('''%s''')\n" "Python code used to get a string with the documentation of an object.") (defun python-eldoc-setup () -- 2.39.2