diff --git a/pytket/conanfile.py b/pytket/conanfile.py index 1847139704..9e69328491 100644 --- a/pytket/conanfile.py +++ b/pytket/conanfile.py @@ -32,7 +32,7 @@ def package(self): cmake.install() def requirements(self): - self.requires("tket/1.2.95@tket/stable") + self.requires("tket/1.2.96@tket/stable") self.requires("tklog/0.3.3@tket/stable") self.requires("tkrng/0.3.3@tket/stable") self.requires("tkassert/0.3.4@tket/stable") diff --git a/pytket/tests/circuit_test.py b/pytket/tests/circuit_test.py index 0999dfafe6..7692de9c38 100644 --- a/pytket/tests/circuit_test.py +++ b/pytket/tests/circuit_test.py @@ -1439,6 +1439,38 @@ def test_add_circbox_with_mixed_registers() -> None: ) +def test_deserialization_from_junk() -> None: + # https://github.com/CQCL/tket/issues/1243 + with pytest.raises(RuntimeError): + Circuit.from_dict( + { + "phase": "1.9999999999999998", + "qubits": [("q", (20057, 24021, 112, 9628, 79))], + "bits": [("c", (128, 3, 384))], + "implicit_permutation": [ + (("c", (1174437931,)), ("q", (0,))), + (("c", (25199232,)), ("c", (29697, 126852352))), + ], + "commands": [ + { + "op": { + "type": "CCX", + "conditional": { + "op": {"type": "CCX"}, + "width": 3, + "value": 2, + }, + }, + "args": [], + } + ], + "name": "รบ\x19", + "created_qubits": [("c", (0,))], + "discarded_qubits": [("c", (0,))], + } + ) + + if __name__ == "__main__": test_circuit_gen() test_symbolic_ops() diff --git a/tket/conanfile.py b/tket/conanfile.py index a78e09d56d..a9bfdc2851 100644 --- a/tket/conanfile.py +++ b/tket/conanfile.py @@ -23,7 +23,7 @@ class TketConan(ConanFile): name = "tket" - version = "1.2.95" + version = "1.2.96" package_type = "library" license = "Apache 2" homepage = "https://github.com/CQCL/tket" diff --git a/tket/src/Circuit/CommandJson.cpp b/tket/src/Circuit/CommandJson.cpp index 55ec10ed79..9dcdc95f88 100644 --- a/tket/src/Circuit/CommandJson.cpp +++ b/tket/src/Circuit/CommandJson.cpp @@ -31,7 +31,7 @@ void to_json(nlohmann::json& j, const Command& com) { const unit_vector_t& args = com.get_args(); if (sig.size() != args.size()) { - JsonError("Number of args does not match signature of op."); + throw JsonError("Number of args does not match signature of op."); } nlohmann::json j_args; @@ -72,7 +72,7 @@ void from_json(const nlohmann::json& j, Command& com) { const nlohmann::json& j_args = j.at("args"); if (sig.size() != j_args.size()) { - JsonError("Number of args does not match signature of op."); + throw JsonError("Number of args does not match signature of op."); } unit_vector_t args; for (std::size_t i = 0; i < sig.size(); i++) {