Jan Borsodi committed c8c96b5

Fixed parsing of default values for enum fields when numbers are used, now it searches for an enum entry with the same number.

Comments (0)

Files changed (2)

         if isinstance(self._item, Field) and self._item.message:
             def set_default_enum(sym, item):
                 if isinstance(sym.owner.message, Enum):
+                    # Compatibility with code that expects a number in item.default
+                    if isinstance(item, EnumValue):
+                        sym.owner.setDefaultValue(item.value)
+                        sym.owner.setDefaultText(str(item.value))
                     raise BuildError("Messages can't have default values")
         if current:
             while current:
                 for child in current.items:
-                    if == path[0]:
+                    num = None
+                    if isinstance(child, EnumValue):
+                        try:
+                            num = int(path[0])
+                        except ValueError:
+                            pass
+                    if == path[0] or (num is not None and child.value == num):
                         item = child
                         if path[1:]:
                             item = msg_find(item, path[1:])
         self.default = value
         self.default_object = value
+    def setDefaultValue(self, value):
+        self.default = value
     def setDefaultText(self, text):
         self.default_text = text
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.