From 2bee5ddb9f371ec0b17a0d79bbf51ec5e798ada5 Mon Sep 17 00:00:00 2001 From: Rathish Cholarajan Date: Tue, 5 Jul 2022 13:42:11 -0400 Subject: [PATCH] Copy of https://github.com/Qiskit/qiskit-terra/pull/8235 Co-authored-by: Matthew Treinish --- qiskit_ibm_runtime/qpy/interface.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qiskit_ibm_runtime/qpy/interface.py b/qiskit_ibm_runtime/qpy/interface.py index 9845ce3dc..76b5918b5 100644 --- a/qiskit_ibm_runtime/qpy/interface.py +++ b/qiskit_ibm_runtime/qpy/interface.py @@ -71,6 +71,7 @@ """ + "$" ) +VERSION_PATTERN_REGEX = re.compile(VERSION_PATTERN, re.VERBOSE | re.IGNORECASE) @deprecate_arguments({"circuits": "programs"}) @@ -150,7 +151,7 @@ def dump( # type: ignore[no-untyped-def] else: raise TypeError(f"'{program_type}' is not supported data type.") - version_match = re.search(VERSION_PATTERN, __version__, re.VERBOSE | re.IGNORECASE) + version_match = VERSION_PATTERN_REGEX.search(__version__) version_parts = [int(x) for x in version_match.group("release").split(".")] header = struct.pack( formats.FILE_HEADER_PACK, # type: ignore[attr-defined] @@ -233,7 +234,7 @@ def load( # type: ignore[no-untyped-def] ) if data.preface.decode(common.ENCODE) != "QISKIT": raise QiskitError("Input file is not a valid QPY file") - version_match = re.search(VERSION_PATTERN, __version__, re.VERBOSE | re.IGNORECASE) + version_match = VERSION_PATTERN_REGEX.search(__version__) version_parts = [int(x) for x in version_match.group("release").split(".")] header_version_parts = [data.major_version, data.minor_version, data.patch_version]