First time here? Check out the FAQ!

Ask Your Question
2

Preparser not working if cell starts with a comment

asked 4 years ago

Florentin Jaffredo gravatar image

Some of my code stopped working after I upgraded from version 9.0 to 9.3beta4. I tracked it to the following bug:

sage: preparse('1 # Comment \n 1.5^2')
"Integer(1) # Comment \n RealNumber('1.5')**Integer(2)"

sage: preparse('# Comment \n 1.5^2')
'# Comment \n 1.5^2'

The code is not getting preparsed if it starts with a comment. In practice it looks like this:

image description

This seems like a big issue, and I would be surprised if it went unnoticed until now. Could it be caused by my Sage installation? (Compiled from source on WSL2 Ubuntu 20.04, which is not officially supported, but I didn't notice anything weird).
Can someone try this?

Preview: (hide)

Comments

I confirm the issue with Sage 9.3.beta4. With Sage 9.2, the bug appears only the console: everything is fine in the Jupyter notebook.

eric_g gravatar imageeric_g ( 4 years ago )

Thanks Eric for the quick reply. The same is true for Sage 9.0. I wonder what changed, and how was it working previously.

Florentin Jaffredo gravatar imageFlorentin Jaffredo ( 4 years ago )

Looking at the code for preparse, it starts with

L = line.lstrip()
if len(L) > 0 and L[0] in ['#', '!']:
    return line

That code has been there since at least 2014, and perfectly explains the first observation. An easy fix would probably be to check here for a line break, but that doesn't explain why it was working before.

Florentin Jaffredo gravatar imageFlorentin Jaffredo ( 4 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 4 years ago

slelievre gravatar image
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 4 years ago

Seen: 254 times

Last updated: Dec 27 '20