Skip to content
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

Sage allows creation of variables with empty name #9724

Closed
sagetrac-logix mannequin opened this issue Aug 11, 2010 · 8 comments
Closed

Sage allows creation of variables with empty name #9724

sagetrac-logix mannequin opened this issue Aug 11, 2010 · 8 comments

Comments

@sagetrac-logix
Copy link
Mannequin

sagetrac-logix mannequin commented Aug 11, 2010

Sage allows you to create a variable with an empty name. While this at first appears not to cause any problems, one thing it does break is reset():

sage: var(' ')
(, )
sage: whos
Variable   Type          Data/Info
----------------------------------
           Expression    
sage: reset()
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (437, 0))

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)

/usr/local/sage/local/lib/python2.6/site-packages/sage/all_cmdline.pyc in <module>()

/usr/local/sage/local/lib/python2.6/site-packages/sage/misc/reset.so in sage.misc.reset.reset (sage/misc/reset.c:838)()

IndexError: string index out of range
sage: del globals()['']
sage: reset()

Sage also allows the creation of variables with other illegal names (e.g. '1a' or '1'), but for these at least reset() still works. There are two ways to fix this, the first is to disallow the creation of such variables via var(), but then all illegal cases would have to be taken care of, and it wouldn't help if you created illegal variables manually by inserting them into globals() (but I would argue that if you do this, you're on your own anyway). The second way to fix the behaviour above would be to make reset() able to delete empty variables too. This however is only viable if these variables don't break anything else, other than the case mentioned above.

CC: @haraldschilly

Component: symbolics

Keywords: sd31

Reviewer: Volker Braun, Mariah Lenox

Issue created by migration from https://trac.sagemath.org/ticket/9724

@sagetrac-logix sagetrac-logix mannequin added this to the sage-4.7.1 milestone Aug 11, 2010
@sagetrac-logix sagetrac-logix mannequin assigned burcin Aug 11, 2010
@nexttime
Copy link
Mannequin

nexttime mannequin commented Aug 16, 2010

comment:1

Perhaps one could add a warning message giving a hint in other cases, too.

From #sage-devel (IRC):

<cousteau> weird, I can't make the notebook display the same that real LaTeX
 I have a variable which I called {m}:   var('{m}')   In real LaTeX, it nicely displays as an m, but in the notebook it keeps the braces
 same for a variable called \mu\Omega
 does the notebook just get the latex() of the variables? or does it do something else?
 var('sui', latex_name="s_{u,i}")   :'( I shoild read the manual first

@vbraun
Copy link
Member

vbraun commented Jun 18, 2011

comment:2

Fixed in the patch on #7496:

sage: var(' ')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/vbraun/opt/sage-4.7.1.alpha2/devel/sage-main/<ipython console> in <module>()

/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/calculus/var.so in sage.calculus.var.var (sage/calculus/var.c:687)()

/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/symbolic/ring.so in sage.symbolic.ring.SymbolicRing.var (sage/symbolic/ring.cpp:6276)()

/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/symbolic/ring.so in sage.symbolic.ring.SymbolicRing.var (sage/symbolic/ring.cpp:6048)()

ValueError: The name "" is not a valid Python identifier.

@vbraun
Copy link
Member

vbraun commented Jun 18, 2011

Changed keywords from variable empty name to sd31

@vbraun vbraun removed this from the sage-4.7.1 milestone Jun 18, 2011
@kcrisman
Copy link
Member

comment:3

Apparently this means this should be closed. Probably proper form is to let the release manager change the milestone, right, Jeroen? :)

I'm assuming that Mariah's comment on #7496 means she checked this out, so I'm putting her and Volker as reviewers for closing this.

@kcrisman
Copy link
Member

Reviewer: Volker Braun, Mariah Lenox

@kcrisman
Copy link
Member

Changed author from Harold Gutch to none

@kcrisman
Copy link
Member

comment:4

It does work. This is not mentioned in the patch for #7496, though, so I'm adding a doctest there.

@jdemeyer
Copy link

comment:5

Replying to @kcrisman:

Probably proper form is to let the release manager change the milestone, right, Jeroen? :)

No, it is easier if you change the milestone to "sage-duplicate/invalid/wontfix" and set to "positive_review". This gives me the best overview on http://trac.sagemath.org/sage_trac/report/40. I will then close the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants