Skip to content

Commit

Permalink
gh-35610: Check for empty string before trying to evaluate in _elemen…
Browse files Browse the repository at this point in the history
…t_constructor

    
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->
<!-- For example, instead of "Fixes #12345", use "Add a new method to
multiply two integers" -->

### 📚 Description

<!-- Describe your changes here in detail. -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
Fixes #35607
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35610
Reported by: nbruin
Reviewer(s): Matthias Köppe
  • Loading branch information
Release Manager committed May 27, 2023
2 parents 733d3bc + d32725b commit 72bd42e
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 72bd42e

Please sign in to comment.