From b15826ae0c0afe2900448ebea3f47aa75a399aff Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 31 Jan 2023 15:57:41 +0100 Subject: [PATCH] [matter_yamltests] Try to not convert strings that represent a variable in try_apply_yaml_unrepresentable_integer_for_javascript_fixes (#24751) --- scripts/py_matter_yamltests/matter_yamltests/fixes.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/py_matter_yamltests/matter_yamltests/fixes.py b/scripts/py_matter_yamltests/matter_yamltests/fixes.py index 4b31e5e20dc736..d9630f723d5e64 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/fixes.py +++ b/scripts/py_matter_yamltests/matter_yamltests/fixes.py @@ -53,9 +53,15 @@ def try_apply_yaml_unrepresentable_integer_for_javascript_fixes(value): JavaScript can not represent integers bigger than 9007199254740991. But some of the test may uses values that are bigger than this. The current way to workaround this limitation has been to write those numbers as strings by encapsulating them in "". + Conversion happens on a best effort basis. For example, the type of value can be a string + because a variable has been used, in which case, it would not convert to a proper int + and we would fail at runtime. ''' if type(value) is str: - value = int(value) + try: + value = int(value) + except: + pass return value