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
Crash when using %macros in sqlite-history branch #287
Comments
It seems that, when you run a macro, both the command calling the macro and the macro itself are stored in history. The database expects a unique line number for each entry, but these are passed with the same line number ( Nearer to release, it probably makes sense for store_inputs to catch IntegrityError so that it can fail more gracefully. I've left it uncaught for now so that we can pick up on errors like this one. |
It might be best for the prefilter mechanism to expand Macro objects explicitly instead of using the IPyAutocall mechanism. Then the history will contain both the raw macro execution and the expanded macro implementation automatically. |
That's not a bad idea. I'll look into it tomorrow. |
It's working a bit. The trouble is that IPython determines that a cell contains a single block before it does the prefiltering. So the macro command gets expanded, but then compiled in single line mode, and only the first line of the macro is executed. Is there an easy way round this, or would it involve substantial changes to IPython's execution machinery? |
It looks like a lot of the logic for prefiltering and transformation has been split up (or simply duplicated) between the PrefilterManager and the InputSplitter. I wouldn't be surprised if there's a bunch of dead code in the prefilter module. I'll think on it. |
The original bug is fixed, and the contents of a macro are now displayed in the translated version of the history. There may well still be duplicate code in prefilter.py and inputsplitter.py - I didn't try to audit them. |
I get the following crash when executing a %macro:
When I try to view the history using %hist immediately after this, I get a full IPython crash with an IntegrityError in the same place.
The text was updated successfully, but these errors were encountered: