'' in CC fails

28 views
Skip to first unread message

G. M.-S.

unread,
May 3, 2023, 11:11:25 AM5/3/23
to sage-s...@googlegroups.com

This works:

sage: for i in [ZZ,QQ,RR]:

....:     print('empty string in',i,':','' in i)

....: 

empty string in Integer Ring : False

empty string in Rational Field : False

empty string in Real Field with 53 bits of precision : False


This gives an error:

sage: '' in CC

[…]

    

    ^

SyntaxError: invalid syntax


Why?

TIA,

Guillermo

Nils Bruin

unread,
May 3, 2023, 11:51:45 AM5/3/23
to sage-support
On Wednesday, 3 May 2023 at 08:11:25 UTC-7 G. M.-S. wrote:

This gives an error:

sage: '' in CC

[…]

    

    ^

SyntaxError: invalid syntax


It looks like this error comes from the fact that "eval('')" raises this.  Apparently an empty string is not valid python for the parser. It is a little strange that an empty string is getting parsed to test for membership in CC. Many non-empty strings that are invalid python code do return "False", so it looks like the empty string ends up in a wrong code path somewhere. Worth a bug report, I'd say.

G. M.-S.

unread,
May 3, 2023, 12:38:45 PM5/3/23
to sage-s...@googlegroups.com

Thanks Nils.
This is now

Guillermo
Reply all
Reply to author
Forward
0 new messages