@@ -316,15 +316,17 @@ def parse_struct(
316316 field_type = parse_type (tokens , __cls__ , __byte_order__ , offset )
317317 vname = tokens .pop ()
318318 if vname in fields_types :
319- raise ParserError ("Duplicate member '{}'" .format (vname ))
319+ raise ParserError (f"Duplicate member '{ vname } '" )
320+ if vname in dir (__cls__ ):
321+ raise ParserError (f"Invalid reserved member name '{ vname } '" )
320322 # anonymous nested union
321323 if vname == ';' and field_type .ref is not None and (__is_union__ or field_type .ref .__is_union__ ):
322324 # add the anonymous struct fields to the parent
323325 for nested_field_name , nested_field_type in field_type .ref .__fields_types__ .items ():
324326 if nested_field_name in fields_types :
325- raise ParserError ("Duplicate member '{}'" . format ( nested_field_name ) )
327+ raise ParserError (f "Duplicate member '{ nested_field_name } '" )
326328 fields_types [nested_field_name ] = nested_field_type
327- vname = "__anonymous{}" . format ( anonymous )
329+ vname = f "__anonymous{ anonymous } "
328330 anonymous += 1
329331 tokens .push (';' )
330332 fields_types [vname ] = field_type
@@ -336,7 +338,7 @@ def parse_struct(
336338 offset = field_type .offset + field_type .vsize
337339 t = tokens .pop ()
338340 if t != ';' :
339- raise ParserError ("; expected but {} found" . format ( t ) )
341+ raise ParserError (f "; expected but { t } found" )
340342
341343 if __is_union__ : # C union
342344 # Calculate the sizeof union as size of its largest element
0 commit comments