From 4b7d5d3de4a031869c255a22c73cc2fd56ca544d Mon Sep 17 00:00:00 2001 From: boukeversteegh Date: Mon, 25 May 2020 22:23:39 +0200 Subject: [PATCH] #53 Crash when field has the same name as a system type --- .../namespace_builtin_types.json | 16 ++++++++ .../namespace_builtin_types.proto | 37 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 betterproto/tests/inputs/namespace_builtin_types/namespace_builtin_types.json create mode 100644 betterproto/tests/inputs/namespace_builtin_types/namespace_builtin_types.proto diff --git a/betterproto/tests/inputs/namespace_builtin_types/namespace_builtin_types.json b/betterproto/tests/inputs/namespace_builtin_types/namespace_builtin_types.json new file mode 100644 index 0000000..8200032 --- /dev/null +++ b/betterproto/tests/inputs/namespace_builtin_types/namespace_builtin_types.json @@ -0,0 +1,16 @@ +{ + "int": "value-for-int", + "float": "value-for-float", + "complex": "value-for-complex", + "list": "value-for-list", + "tuple": "value-for-tuple", + "range": "value-for-range", + "str": "value-for-str", + "bytearray": "value-for-bytearray", + "bytes": "value-for-bytes", + "memoryview": "value-for-memoryview", + "set": "value-for-set", + "frozenset": "value-for-frozenset", + "map": "value-for-map", + "bool": "value-for-bool" +} \ No newline at end of file diff --git a/betterproto/tests/inputs/namespace_builtin_types/namespace_builtin_types.proto b/betterproto/tests/inputs/namespace_builtin_types/namespace_builtin_types.proto new file mode 100644 index 0000000..5f7ab22 --- /dev/null +++ b/betterproto/tests/inputs/namespace_builtin_types/namespace_builtin_types.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +// Tests that messages may contain fields with names that are python types + +message Test { + // https://docs.python.org/2/library/stdtypes.html#numeric-types-int-float-long-complex + string int = 1; + string float = 2; + string complex = 3; + + // https://docs.python.org/3/library/stdtypes.html#generator-types + string list = 10; + string tuple = 11; + string range = 12; + + // https://docs.python.org/3/library/stdtypes.html#str + string str = 21; + + // https://docs.python.org/3/library/stdtypes.html#bytearray-objects + string bytearray = 22; + + // https://docs.python.org/3/library/stdtypes.html#bytes-and-bytearray-operations + string bytes = 23; + + // https://docs.python.org/3/library/stdtypes.html#memory-views + string memoryview = 24; + + // https://docs.python.org/3/library/stdtypes.html#set-types-set-frozenset + string set = 25; + string frozenset = 26; + + // https://docs.python.org/3/library/stdtypes.html#dict + string map = 27; + + // https://docs.python.org/3/library/stdtypes.html#boolean-values + string bool = 28; +} \ No newline at end of file