Skip to content

Commit 98cbde9

Browse files
author
mihofer
authored
provide globals dict to eval (#58)
use a globals dict in eval in Dictformstring to allow reading in *.ini files containing nans
1 parent 600564b commit 98cbde9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Generic-Parser Changelog
22

3+
## Version 1.1.1
4+
* add a dictionary to the eval in DictFromString to allow reading in *.ini with nans
5+
6+
37
## Version 1.0.8
48
* revamp of the documentation
59
* fixed a format string error when a choice is not correct for a list argument

generic_parser/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
__title__ = "generic_parser"
66
__description__ = "A parser for arguments and config-files that also allows direct python input."
77
__url__ = "https://github.com/pylhc/generic_parser"
8-
__version__ = "1.1.0"
8+
__version__ = "1.1.1"
99
__author__ = "pylhc"
1010
__author_email__ = "[email protected]"
1111
__license__ = "MIT"

generic_parser/entry_datatypes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
This module contains advanced datatypes to add as type to any entrypoint or parser.
66
"""
77
import abc
8+
from array import array
89

910
TRUE_ITEMS = ["True", "1", True, 1] # items that count as True
1011
FALSE_ITEMS = ["False", "0", False, 0] # items that count as False
@@ -68,7 +69,7 @@ def __new__(cls, s):
6869
if isinstance(s, dict):
6970
return s
7071

71-
d = eval(s)
72+
d = eval(s, {'nan': float('nan'), 'array':array})
7273
if not isinstance(d, dict):
7374
raise ValueError(f"'{s}' can't be converted to a dictionary.")
7475
return d

0 commit comments

Comments
 (0)