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: Jörg Behrmann
Subject: bug#28499: 27.0.50; Improve python.el fallback shell completion python3 compatibility
Date: Mon, 18 Sep 2017 17:23:40 +0200

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.

In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.21)
 of 2017-09-18 built on boltzmann
Repository revision: 61a5c30e70926f48480b03b79f4f531c8d64418e
Windowing system distributor 'The X.Org Foundation', version 11.0.11903000
System Description:     Arch Linux

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --prefix=/home/drako/.devlocal'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 LIBSYSTEMD LCMS2

Important settings:
  value of $LC_COLLATE: de_DE.utf8
  value of $LC_MONETARY: de_DE.utf8
  value of $LC_NUMERIC: en_US.utf8
  value of $LC_TIME: de_DE.utf8
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: Python

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message subr-x puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils python easymenu tramp-sh tramp
tramp-compat tramp-loaddefs trampver ucs-normalize shell pcomplete
parse-time format-spec advice auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json map seq byte-opt gv bytecomp
byte-compile cconv comint ring cl-loaddefs cl-lib ansi-color elec-pair
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 224182 11719)
 (symbols 48 22573 1)
 (miscs 40 52 176)
 (strings 32 36999 1441)
 (string-bytes 1 1087109)
 (vectors 16 38977)
 (vector-slots 8 758280 10386)
 (floats 8 67 517)
 (intervals 56 468 0)
 (buffers 992 12))
>From 5f7f6d47504b53e80e6bd948aa46d77612ff8504 Mon Sep 17 00:00:00 2001
From: Joerg Behrmann <address@hidden>
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
-- 
2.14.1


reply via email to

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