Elpy: Error from python-shell-completion-at-point

Created on 13 Feb 2018  路  14Comments  路  Source: jorgenschaefer/elpy

Hi,

The following error appears in the *Python* buffer when it tries any autocompletion.
In [2]: ne
After typing one or two words, this error is shown:

Company: An error occurred in auto-begin
Company: backend (company-capf :with company-yasnippet) error "Invalid search bound (wrong side of point)" with args (prefix)

Any idea how to deal with this issue?
Thanks

Most helpful comment

I reopen this issue in order to provide a most robust solution according to
https://github.com/company-mode/company-mode/issues/759
I also changed the title for a better reference.

All 14 comments

Hi,

I got the same error some months ago.
In my case, it os apparently due to a bug in company, that modify the cursor position before calling python-shell-completion-at-point.

A possible workaround that works for me:

(defadvice python-shell-completion-at-point (before fix-company-bug activate)
  "Fix a bug in company, modifying the current point"
  (goto-char (point-max)))

For a more sustainable solution, you will have to report this to company and/or python.

@galaunay
Yes, the workaround works. Thank you.
I reported it in company-mode.
What is the official place (repo) to report it in python?

Happy that the workaround works for you too,
this shows that there is indeed a problem.

Python-mode is part of Emacs,
so problems with python-mode should be reported directly to emacs.

The best way to do it is by using report-emacs-bug.
You can have more infos on how to properly report an issue by doing report-emacs-bug-info.

If I were you, I'll wait for an answer from company before reporting to emacs.

Thank you.
Ok. I will follow your advice.

Alright,
Thank you for reporting this.

I reopen this issue in order to provide a most robust solution according to
https://github.com/company-mode/company-mode/issues/759
I also changed the title for a better reference.

Thanks for the feedback,
their solution is way better than mine.

I made a PR to be sure this won't bug anyone else.

Thank you for answering my very first question, that gave me the opportunity not only to learn but also to explore possible solutions and alternatives.

@galaunay
Hi, I updated elpy in order to test your fix https://github.com/jorgenschaefer/elpy/pull/1301/commits/da2bfaf387d5b176f33a11905f5894d0e3879668
Two important conclusions:

  • I found a scenario where it fails again: when using company-yasnippet as backend. I needed to come back again to the advice funci贸n.
  • I played a lot this weekend with my emacs configuration and for any reason company stopped showing candidates in the python-shell buffer . The point is that I did not change my python related configuration.
Elpy Configuration
Virtualenv........: None
RPC Python........: 3.5.4 (c:/Anaconda3/envs/py35/pythonw.exe)
Interactive Python: ipython (c:/Anaconda3/envs/py35/Scripts/ipython.exe)
Emacs.............: 25.3.1
Elpy..............: 1.18.0
Jedi..............: 0.11.1
Rope..............: 0.10.7
Autopep8..........: 1.3.4
Yapf..............: 0.20.2
Syntax checker....: flake8.exe (c:/Anaconda3/envs/py35/Scripts/flake8.exe)

Question: Is your python-shell-completion-at-point still working after your fixe? Bellow my company configuration.

(use-package company
  :ensure t
  :demand
  :preface
  ;;----------------------------------------------------------------------------
  ;;;  Add yasnippet to all company backends
  ;;----------------------------------------------------------------------------
  (defun company-mode/backend-with-yas (backend)
    "Add BACKEND to jasnippet."
    (if (and (listp backend) (member 'company-yasnippet backend))
        backend
      (append (if (consp backend) backend (list backend))
              '(:with company-yasnippet))))
  (eval-after-load "yasnippet"
    '(progn
       (setq company-backends
             (mapcar #'company-mode/backend-with-yas company-backends))))
  ;;----------------------------------------------------------------------------
  :bind
  (:map company-active-map
        ("C-n" . company-select-next)
        ("C-p" . company-select-previous)
        ("RET" . company-complete-common)
        ("<tab>" . company-complete-selection))
  :bind ("C-<tab>" . company-manual-begin)
  :config
  (setq company-minimum-prefix-length 1
        ;;company-tooltip-align-annotations t
        company-idle-delay 0
        company-transformers '(company-sort-by-occurrence)
        )
  (global-company-mode 1))

I could not reproduce the issue for company-yasnippet, even with your company configuration.
Is it the same error than before ?

python-shell-completion-at-point works for me after the patch.
Does it give you a reason for the failure ?

python-shell-completion-at-point works for me after the patch.
Does it give you a reason for the failure ?

No, I even started emacs as (runemacs -Q) and made several tests with different computers and different emacs versions (25,26 including pre-tests and my own build versions) but unfortunately the Shell native completion is disabled. I have already reported that issue.

Question: Which version of emacs, python (Anaconda or any other) and the operating system are you using?

Thanks.

Emacs 25.3.1,
Python 3.6.4,
on Arch (Linux 4.14).

Does any of the computer you made your tests on is on Linux ?

Does any of the computer you made your tests on is on Linux ?

The problem is just my Windows machines. In Linux it works fine.

Unfortunately, I have no experience in using python-mode on windows.
Hope the guys from python-mode will be more helpful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SergiyKolesnikov picture SergiyKolesnikov  路  3Comments

dschrempf picture dschrempf  路  6Comments

SirSharpest picture SirSharpest  路  6Comments

Arseny-N picture Arseny-N  路  4Comments

kapilsh picture kapilsh  路  3Comments