New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tab-completion of cached_method in extension class crashes SageMath #31632
Comments
This comment has been minimized.
This comment has been minimized.
comment:2
This is already in 9.2 (reproduced following the instructions in the gitlab fork)
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:4
Replying to @dimpase:
Thanks for testing. I believe that it is a Python3 thing (in particular quite old). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:8
On conda (with sage 9.2) I get the error but no crash
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:11
I have also had problems with |
comment:12
You should in addition inherit from |
comment:13
Indeed this seems to have appeared at some point recent. On debian buster I can't reproduce it with sage 9.1, at least not the hard crash. The underlying problem to fetch This seems to be related #31480 (which was a blocker, because as you noted hard crashes are annoying and it had a super easy fix). This tab completion hard crash also appeared with some ipython upgrade or so that happened recently. |
comment:14
I think the mentioned workaround is also a possible solution. You cannot just cythonize a file and then except it to work completely nice with sage. It should be clear that you need to run a special cythonize function that enables the proper defaults for sage (e.g. cython aliases etc). However, I can't find such a function and I think sage should provide a customized Or at least provide the cythonize arguments somewhere... Am I making any sense? Anyway, I think this is out of scope for sage 9.3 |
comment:15
Replying to @kliem:
I see at least three problems:
I believe there is work to be done on different fronts: the |
comment:16
Ok, yes, I agree with you.
To verify that tab completion is doing too much one can do the following: Start sage fresh
Hit tab after
So tab completion does not work well with lazy imports at all. |
comment:17
Certainly unrelated: On my machine, when I do a copy/paste of a sage prompt line I also get a bunch of white spaces in the buffer. The same happened in your examples from [comment:16] (I removed the spaces manually). This behavior was not there before. |
comment:18
Replying to @kliem:
For me it is even stranger: before the tab and and after the first I still get |
comment:19
Replying to @videlec:
Yes, you are right. I got this wrong. If you tab complete |
comment:20
Note that tab completion runs in a separate thread, which previously caused trouble in #22704 |
comment:21
Not reproducible with
which prints four times
|
comment:22
Replying to @mkoeppe:
Ah, this probably explains, why it takes two times, until you see the effect. You do this effect immediatly in memory usage. Tab completion of Also tab completion of
And tab completion twice
because it is incorrectly lazily imported in
|
comment:23
In the first place, tab completion should not trigger the lazy imports... Why is it doing so? |
comment:24
I mentioned this above and agree. I don't know. For the moment (and all I'll do today), I just remarked that this is clearly wrong. If you autocomplete within a lazy imported thing as in |
comment:25
Concerning lazy imports, I think I got it. Since some recent Python3 versions, objects could be wrapped and in such case the object implements |
comment:26
Nope. That could not explain... |
comment:27
With diff --git a/src/sage/misc/lazy_import.pyx b/src/sage/misc/lazy_import.pyx
index 336567e22c..49abc0b849 100644
--- a/src/sage/misc/lazy_import.pyx
+++ b/src/sage/misc/lazy_import.pyx
@@ -325,6 +325,7 @@ cdef class LazyImport(object):
sage: my_integer.sqrt is Integer.sqrt
True
"""
+ print('getattr(attr={}) of self={}'.format(attr, self))
return getattr(self.get_object(), attr)
# We need to wrap all the slot methods, as they are not forwarded you can have a look at what is asked to your Here is what I got (up to desynchronization)
The three |
comment:28
All right, it has to do with extension class. My [comment:25] was looking in the good direction: IPython does call stuff on the object in some cases.
|
comment:29
Tab completion is now #31643 |
Tab completion on the prefix of a
cached_method
of an extension class not in Sage source code provokes of crash. See https://gitlab.com/videlec/sage_tab_completion_bug to reproduce.The bug was confirmed reproducibly on
The bug is not present on
Workaround
Compile your Cython code with
Tasks
Component: misc
Issue created by migration from https://trac.sagemath.org/ticket/31632
The text was updated successfully, but these errors were encountered: