Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/json.py @ 129:df60417d7665
The JSON scanner allows only decimal integers
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Wed, 04 Apr 2018 23:17:37 +0200 |
| parents | 95ad65c69561 |
| children | 2f2e819e8d17 |
comparison
equal
deleted
inserted
replaced
| 128:95ad65c69561 | 129:df60417d7665 |
|---|---|
| 38 def load(filename, encoding="utf-8"): | 38 def load(filename, encoding="utf-8"): |
| 39 """Load a single JSON file with name `filename` and encoding `encoding`. | 39 """Load a single JSON file with name `filename` and encoding `encoding`. |
| 40 | 40 |
| 41 .. todo:: Allow comments in JSON files | 41 .. todo:: Allow comments in JSON files |
| 42 | 42 |
| 43 .. todo:: Allow all Python integer literals as numbers | |
| 44 | |
| 45 """ | 43 """ |
| 46 with io.open(filename, mode="rt", encoding=encoding) as jsfp: | 44 with io.open(filename, mode="rt", encoding=encoding) as jsfp: |
| 45 # | |
| 46 # The scanner (not to be changed yet) does only recognize decimal | |
| 47 # integers yet. | |
| 48 # | |
| 47 kwds = { | 49 kwds = { |
| 48 "parse_int": lambda s: int(s, 0), | 50 "parse_int": lambda s: int(s, 0), |
| 49 "strict": False | 51 "strict": False |
| 50 } | 52 } |
| 51 if _with_object_pairs_hook: | 53 if _with_object_pairs_hook: |
