Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#7240) Generator doesn't work with python >=2.2
Home

[Freeciv-Dev] (PR#7240) Generator doesn't work with python >=2.2

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7240) Generator doesn't work with python >=2.2
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Wed, 14 Jan 2004 05:29:16 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7240 >


You get an "maximum recursion limit exceeded" error. Python 1.5 works
fine. Thomas reported this via IRC. The attached patch replaces the RE
usage with normal string operations.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "If at first you don't succeed... well so much for skydiving."

Index: common/generate_packets.py
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/generate_packets.py,v
retrieving revision 1.6
diff -u -u -r1.6 generate_packets.py
--- common/generate_packets.py  2004/01/14 11:58:12     1.6
+++ common/generate_packets.py  2004/01/14 13:22:41
@@ -1307,13 +1307,25 @@
 '''
     return intro+body+extro
 
+def strip_c_comment(s):
+  # The obvious way:
+  #    s=re.sub(r"/\*(.|\n)*?\*/","",s)
+  # doesn't work with python version 2.2 and 2.3.
+  # Do it by hand then.
+  result=""
+  for i in filter(lambda x:x,string.split(s,"/*")):
+      l=string.split(i,"*/",1)
+      assert len(l)==2,repr(i)
+      result=result+l[1]
+  return result  
+
 # Main function. It reads and parses the input and generates the
 # various files.
 def main():
     ### parsing input
     input_name="packets.def"
     content=open(input_name).read()
-    content=re.sub(r"/\*(.|\n)*?\*/","",content)
+    content=strip_c_comment(content)
     lines=string.split(content,"\n")
     lines=map(lambda x: re.sub("#.*$","",x),lines)
     lines=map(lambda x: re.sub("//.*$","",x),lines)

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7240) Generator doesn't work with python >=2.2, Raimar Falke <=