summaryrefslogtreecommitdiffhomepage
path: root/libs/engineio/json.py
blob: b612556834376c16a3b3f0566274c9ac9e960a10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""JSON-compatible module with sane defaults."""

from json import *  # noqa: F401, F403
from json import loads as original_loads


def _safe_int(s):
    if len(s) > 100:
        raise ValueError('Integer is too large')
    return int(s)


def loads(*args, **kwargs):
    if 'parse_int' not in kwargs:  # pragma: no cover
        kwargs['parse_int'] = _safe_int
    return original_loads(*args, **kwargs)