Skip to content

Commit

Permalink
Check for empty string before trying to evaluate in _element_constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
nbruin authored May 4, 2023
1 parent 4140517 commit d32725b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/sage/rings/complex_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ class ComplexField_class(sage.rings.abc.ComplexField):
x = x.replace('j', 'I')
x = x.replace('E', 'e')
allowed = '+-.*0123456789Ie'
if not all(letter in allowed for letter in x):
if len(x) == 0 or not all(letter in allowed for letter in x):
raise ValueError(f'given string {x!r} is not a complex number')
# This should rather use a proper parser to validate input.
# TODO: this is probably not the best and most
Expand Down

0 comments on commit d32725b

Please sign in to comment.