Skip to content

MAINT: Eliminate some calls to eval - #15249

Merged
mattip merged 2 commits into
numpy:masterfrom
eric-wieser:remove-eval
Jan 13, 2020
Merged

mattip merged 2 commits into
numpy:masterfrom
eric-wieser:remove-eval

Conversation

@eric-wieser

Copy link
Copy Markdown
Member
  • The instance in _internal is parsing tuples and integers, so ast.literal_eval is just fine
  • The instance in crack_fortran is just trying to lookup a function name dynamically
  • The instance in f90mod_rules is looking at the result of capi_maps.getarrdims(...)['rank'], which is always a string representation of an integer

The f2py code is still littered with eval, but the remaining cases were harder to reason about.

@mattip

mattip commented Jan 6, 2020

Copy link
Copy Markdown
Member

ast.literal_eval does not like b'(2,3)'

@eric-wieser

Copy link
Copy Markdown
Member Author

Have some local work to fix that based on #15254

* The instance in `_internal` is parsing tuples and integers, so `ast.literal_eval` is just fine
* The instance in `crack_fortran` is just trying to lookup a function name dynamically
* The instance in `f90mod_rules` is looking at the result of `capi_maps.getarrdims(...)['rank']`, which is always a string representation of an integer

The f2py code is still littered with `eval`, but the remaining cases were harder to reason about.
Comment thread numpy/f2py/crackfortran.py Outdated
@mattip
mattip merged commit ea75cf5 into numpy:master Jan 13, 2020
@mattip

mattip commented Jan 13, 2020

Copy link
Copy Markdown
Member

Thanks @eric-wieser

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants