Skip to content

Commit 0387cc2

Browse files
committed
fix: Allowing event without transition
1 parent 0310880 commit 0387cc2

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

statemachine/io/scxml.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def __init__(
241241
state_field: str = "state",
242242
start_value: Any = None,
243243
rtc: bool = True,
244-
allow_event_without_transition: bool = False,
244+
allow_event_without_transition: bool = True,
245245
listeners: "List[object] | None" = None,
246246
):
247247
model = model if model else Model()
@@ -370,9 +370,7 @@ def _parse_state(state_elem, final=False): # noqa: C901
370370
for state_elem in scxml.findall(".//final"):
371371
_parse_state(state_elem, final=True)
372372

373-
extra_data = {
374-
"allow_event_without_transition": True,
375-
}
373+
extra_data = {}
376374

377375
# To initialize the data model, we override the SM __init__ method
378376
datamodel = scxml.find("datamodel")
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- test that an error causes the foreach to stop execution. The second piece of executable content
3+
should cause an error, so var1 should be incremented only once -->
4+
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance"
5+
initial="s0" version="1.0" datamodel="ecmascript">
6+
<datamodel>
7+
<data id="Var1" expr="0" />
8+
<data id="Var2" />
9+
<data id="Var3">
10+
[1,2,3]
11+
</data>
12+
</datamodel>
13+
<state id="s0">
14+
<onentry>
15+
<foreach item="Var2" array="Var3">
16+
<assign location="Var1" expr="Var1 + 1" />
17+
<!-- assign an illegal value to a non-existent var -->
18+
<assign location="Var5" expr="return" />
19+
</foreach>
20+
</onentry>
21+
<transition cond="Var1==1" target="pass" />
22+
<transition target="fail" />
23+
</state>
24+
<final id="pass">
25+
<onentry>
26+
<log label="Outcome" expr="'pass'" />
27+
</onentry>
28+
</final>
29+
<final id="fail">
30+
<onentry>
31+
<log label="Outcome" expr="'fail'" />
32+
</onentry>
33+
</final>
34+
</scxml>

0 commit comments

Comments
 (0)