bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#28499: 27.0.50; Improve python.el fallback shell completion python3


From: Noam Postavsky
Subject: bug#28499: 27.0.50; Improve python.el fallback shell completion python3 compatibility
Date: Fri, 22 Sep 2017 20:20:53 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux)

tags 28499 + patch
quit

Jörg Behrmann <behrmann@physik.fu-berlin.de> writes:

> When using IPython as the python-shell-interpreter using
>
> (setq python-shell-interpreter "ipython"
>       python-shell-interpreter-args "-i --simple-prompt")
>
> the fallback shell completion is used. When this IPython is using the
> python3-interpreter upon resting point on a function name some
> information is shown using eldoc, but also 
>
> /usr/sbin/ipython:21: DeprecationWarning: inspect.getargspec() is deprecated, 
> use inspect.signature() or inspect.getfullargspec()
>
> This can be easily fixed by customizing python-eldoc-setup-code to not
> only account for the differing str_type between python2 and python3, but
> to also either set inspect.getargspec or inspect.getfullargspec as
> inspection function.

Thank!  Have you assigned copyright to Emacs?  (The patch is small
enough to install regardless, I only ask to know whether it should be
marked as copyright exempt or not.)

>>From 5f7f6d47504b53e80e6bd948aa46d77612ff8504 Mon Sep 17 00:00:00 2001
> From: Joerg Behrmann <behrmann@physik.fu-berlin.de>
> Date: Mon, 18 Sep 2017 16:59:49 +0200
> Subject: [PATCH] Improve python3-compatibility of fallback completion
>
> * lisp/progmodes/python.el (python-eldoc-setup-code):
>   Use inspect.getfullargspec instead of inspect.getargspec to avoid
>   a deprecation warning on every usage of eldoc in python-mode
> ---
>  lisp/progmodes/python.el | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index f3513ced4b..365191c56b 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -4271,8 +4271,10 @@ python-eldoc-setup-code
>          import inspect
>          try:
>              str_type = basestring
> +            argspec_function = inspect.getargspec
>          except NameError:
>              str_type = str
> +            argspec_function = inspect.getfullargspec
>          if isinstance(obj, str_type):
>              obj = eval(obj, globals())
>          doc = inspect.getdoc(obj)
> @@ -4285,9 +4287,7 @@ python-eldoc-setup-code
>                  target = obj
>                  objtype = 'def'
>              if target:
> -                args = inspect.formatargspec(
> -                    *inspect.getargspec(target)
> -                )
> +                args = inspect.formatargspec(*argspec_function(target))
>                  name = obj.__name__
>                  doc = '{objtype} {name}{args}'.format(
>                      objtype=objtype, name=name, args=args





reply via email to

[Prev in Thread] Current Thread [Next in Thread]