Skip to content

Commit 6320a0a

Browse files
allow byte and utf8 strings in strict mode
1 parent 946ca9f commit 6320a0a

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

pydsdl/_parser.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,9 @@ def visit_type_primitive_boolean(self, _n: _Node, _c: _Children) -> _serializabl
270270
return _serializable.BooleanType()
271271

272272
def visit_type_primitive_byte(self, _n: _Node, _c: _Children) -> _serializable.PrimitiveType:
273-
if self._strict:
274-
raise _error.InvalidDefinitionError("byte is a non-standard extension unavailable in strict mode")
275273
return _serializable.ByteType()
276274

277275
def visit_type_primitive_utf8(self, _n: _Node, _c: _Children) -> _serializable.PrimitiveType:
278-
if self._strict:
279-
raise _error.InvalidDefinitionError("utf8 is a non-standard extension unavailable in strict mode")
280276
return _serializable.UTF8Type()
281277

282278
def visit_type_primitive_truncated(self, _n: _Node, children: _Children) -> _serializable.PrimitiveType:

pydsdl/_test.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pathlib import Path
1212
from textwrap import dedent
1313
import pytest # This is only safe to import in test files!
14-
from . import _data_type_builder, InvalidDefinitionError
14+
from . import InvalidDefinitionError
1515
from . import _expression
1616
from . import _error
1717
from . import _parser
@@ -1989,22 +1989,6 @@ def _unittest_dsdl_parser_utf8_bytes(wrkspc: Workspace) -> None:
19891989
assert t.string_like
19901990

19911991

1992-
def _unittest_dsdl_parser_strict_mode(wrkspc: Workspace) -> None:
1993-
from pytest import raises
1994-
1995-
name = "ns/A.1.0.dsdl"
1996-
src = dedent(
1997-
r"""
1998-
byte[<=10] a
1999-
utf8[<=10] b
2000-
@sealed
2001-
"""
2002-
)
2003-
_ = parse_definition(wrkspc.parse_new(name, src), []) # success by default
2004-
with raises(InvalidDefinitionError, match="(?i).*strict.*"):
2005-
parse_definition(wrkspc.parse_new(name, src), [], strict=True)
2006-
2007-
20081992
def _unittest_dsdl_parser_expressions(wrkspc: Workspace) -> None:
20091993
from pytest import raises
20101994

0 commit comments

Comments
 (0)