No bug: Fix ply being dumb. r=ted
authorKyle Huey <>
Tue, 13 Mar 2012 10:22:14 -0700
changeset 90144 466c118c3e4417504b74f2199b758d1e43170f0f
parent 90143 cf4978c2e32c340987a9258fe064e9a191d8a639
child 90145 b6627f28b7ec17e1b46a594df0f780d3a40847e4
push idunknown
push userunknown
push dateunknown
No bug: Fix ply being dumb. r=ted
--- a/xpcom/idl-parser/
+++ b/xpcom/idl-parser/
@@ -35,17 +35,17 @@
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 # ***** END LICENSE BLOCK *****
 """Print a C++ header file for the IDL files specified on the command line"""
-import sys, os.path, re, xpidl, itertools
+import sys, os.path, re, xpidl, itertools, glob
 printdoccomments = False
 if printdoccomments:
     def printComments(fd, clist, indent):
         for c in clist:
             fd.write("%s%s\n" % (indent, c))
@@ -494,23 +494,31 @@ if __name__ == '__main__':
     options, args = o.parse_args()
     file = args[0] if args else None
     if options.cachedir is not None:
         if not os.path.isdir(options.cachedir):
-    # Instantiate the parser.
-    p = xpidl.IDLParser(outputdir=options.cachedir)
     # The only thing special about a regen is that there are no input files.
     if options.regen:
         if options.cachedir is None:
             print >>sys.stderr, "--regen useless without --cachedir"
+        # Delete the lex/yacc files.  Ply is too stupid to regenerate them
+        # properly
+        deadfiles = os.path.join(options.cachedir, "*.py*")
+        for filename in glob.glob(deadfiles):
+            print filename
+            os.remove(filename)
+    # Instantiate the parser.
+    p = xpidl.IDLParser(outputdir=options.cachedir)
+    if options.regen:
     if options.depfile is not None and options.outfile is None:
         print >>sys.stderr, "-d requires -o"
     if options.outfile is not None:
         outfd = open(options.outfile, 'w')