Browse Source

makepanda: Make version parsing in CreatePandaVersionFiles more robust

rdb 2 years ago
parent
commit
dcc96a60b1
1 changed files with 12 additions and 5 deletions
  1. 12 5
      makepanda/makepanda.py

+ 12 - 5
makepanda/makepanda.py

@@ -3038,11 +3038,18 @@ END
 #endif"""
 
 def CreatePandaVersionFiles():
-    version1=int(VERSION.split(".")[0])
-    version2=int(VERSION.split(".")[1])
-    version3=int(VERSION.split(".")[2])
-    nversion=version1*1000000+version2*1000+version3
-    if (DISTRIBUTOR != "cmu"):
+    parts = VERSION.split(".", 2)
+    version1 = int(parts[0])
+    version2 = int(parts[1])
+    version3 = 0
+    if len(parts) > 2:
+        for c in parts[2]:
+            if c.isdigit():
+                version3 = version3 * 10 + ord(c) - 48
+            else:
+                break
+    nversion = version1 * 1000000 + version2 * 1000 + version3
+    if DISTRIBUTOR != "cmu":
         # Subtract 1 if we are not an official version.
         nversion -= 1