jdtsmith / python-mls

Multi-line Shell Commands for Python REPLs in Emacs
GNU Affero General Public License v3.0
40 stars 3 forks source link

Pdb error: __PYTHON_EL_eval' is not defined. #11

Closed gety9 closed 1 year ago

gety9 commented 1 year ago

When python-mls mode is enabled, i can't debug with pdb (works fine without it).

Steps:

1, put `import pdb; pdb.set_trace()` in myfunc
2, import scripts.mydule as md
md.myfunc()
S-Enter
3, (Pdb) n (or any command, ex print(var1))
>>> NameError: name '__PYTHON_EL_eval' is not defined

Also pointer jumps all the time to from position when typing, example, i am typing 'abcdef':

(Pdb) a
(Pdb) ab
(Pdb) cab <jump
(Pdb) dcab < jump
etc...
jdtsmith commented 1 year ago

This is a generic issue with inferior-python-mode. It's trying to do completion for you, and sending background requests to its special compiled function '__PYTHON_EL_eval, which obviously isn't known in PDB. This also results in jumps. You probably have to turn off auto-completion with whatever tool (corfu, company, etc.) you have.

I have a new mode I'm hoping to release in the coming month or so targeting iPython which works with iPDB among many other things.

gety9 commented 1 year ago

@jdtsmith got it, not big deal,

could you tell why it's not doing that "It's trying to do completion for you, and sending background requests to its special compiled function" when python-mls is disabled (in regular M-x run-python)? just curious.

jdtsmith commented 1 year ago

Hmm, maybe I'm not correct about that. You should see the same problems whether or not python-mls is active. Do you have auto-completion of some kind setup?

gety9 commented 1 year ago

i have in have company-mode and global-company-mode enabled, full list:

Auto-Composition Auto-Compression Auto-Encryption
Blink-Cursor Buffer-Face Company Compilation-Shell Counsel Cua
Delete-Selection File-Name-Shadow Fixed-Pitch Font-Lock
Global-Auto-Revert Global-Company Global-Eldoc Global-Font-Lock
Global-Undo-Tree Ivy Line-Number Mouse-Wheel Override-Global Recentf
Shell-Dirtrack Show-Paren Tooltip Transient-Mark Undo-Tree Wakib-Keys
Xclip Yas Yas-Global

they seem to cause the pointer jumping issue in both regular run-python and when python-mls enabled,

but __PYTHON_EL_eval' is not defined issue is only present when python-mls is enabled

and if it's enabled turning off company-mode and global-company-mode does not solve the issue: (full list)

Auto-Composition Auto-Compression Auto-Encryption
Blink-Cursor Buffer-Face Compilation-Shell Counsel Cua
Cursor-Intangible Delete-Selection File-Name-Shadow Fixed-Pitch
Font-Lock Global-Auto-Revert Global-Eldoc Global-Font-Lock
Global-Undo-Tree Ivy Line-Number Mouse-Wheel Override-Global
Python-Mls Recentf Shell-Dirtrack Show-Paren Tooltip Transient-Mark
Undo-Tree Wakib-Keys Xclip Yas Yas-Global

but it does solve the issue of jumping pointer.

For effects to take effect (after turning on/off modes) i need to restart run-python (kill and run-python again).

I assumed that it's somehow connected to buffer path cause searching for "emacs + error" is saw that command take file as arg return __PYTHON_EL_eval(source, filename)

jdtsmith commented 1 year ago

I've just noticed that there have been many changes to python.el's command sending, with __PYTHON_EL_eval being added everywhere, even for simple single line commands. So much so that for recent versions, python-mls will be broken. I've started a conversation on emacs-devel about it, but may work around it in the meantime. I'm not sure if this is partially your issue.

Regarding your specific PDB issue, can you please be more specific? Show me the exact steps in a minimum reproducer to take with and without python-mls that work without and break with it.

jdtsmith commented 1 year ago

For your completion issues, you should probably just disable company in inferior-python buffers in your init. It doesn't know it's in PDB so will be causing problems there. If you want in-buffer popup without auto, you could try corfu (which is what I use).

jdtsmith commented 1 year ago

Also: please update to the latest python-mls version. I included a fix for the new python.el breakage.

gety9 commented 1 year ago

"Regarding your specific PDB issue, can you please be more specific? Show me the exact steps in a minimum reproducer to take with and without python-mls that work without and break with it"

That's exact steps

0, start emacs
1, put `import pdb; pdb.set_trace()` in myfunc of mymodule in folder1
2, save buffer
3, M-x run-python
4, import folder1.mymodule as md
md.myfunc()
S-Enter
5, n (or any other pdb function like s, l, print(varname), etc)
S-Enter
>>> NameError: name '__PYTHON_EL_eval' is not defined

I mean does putting import pdb; pdb.set_trace() in any function of yours and then debugging this function in python interpeter (with mls-python enabled (which is enabled by default)) using regular n/s/print(var)/etc work for you (on your side)?

jdtsmith commented 1 year ago

Again, this is company trying to run auto completion from python.el, which does not appear to know that iPDB is running. What happens here without python-mls? I'd presume the same issue occurs.

gety9 commented 1 year ago

@jdtsmith that's the thing, it works without python-mls

basically on my side using import pdb; pdb.set_trace(): -, i can debug in regular m-x run python -, can't in m-x run python with mls-python enabled -, disabling autocompletion (company) does not solve the issue (but it solves issue with char jumps)

but it's minor thing, i can leave without it, if it works on your side (or you don't use pdb - ignore the issue)

jdtsmith commented 1 year ago

"It works" vs. "it doesn't work" isn't really enough to go on. I do use PDB but not often. python-mls does not do anything special for PDB or completion, so this is surprising. Will keep an eye open and leave this open for now.