diff options
-rw-r--r-- | ply/lex.py | 2 | ||||
-rw-r--r-- | ply/yacc.py | 2 |
2 files changed, 4 insertions, 0 deletions
@@ -1038,6 +1038,8 @@ def lex(module=None, object=None, debug=False, optimize=False, lextab='lextab', outputdir = os.path.dirname(srcfile) try: lexobj.writetab(lextab, outputdir) + if lextab in sys.modules: + del sys.modules[lextab] except IOError as e: errorlog.warning("Couldn't write lextab module %r. %s" % (lextab, e)) diff --git a/ply/yacc.py b/ply/yacc.py index 772f195..581058c 100644 --- a/ply/yacc.py +++ b/ply/yacc.py @@ -3474,6 +3474,8 @@ def yacc(method='LALR', debug=yaccdebug, module=None, tabmodule=tab_module, star if write_tables: try: lr.write_table(tabmodule, outputdir, signature) + if tabmodule in sys.modules: + del sys.modules[tabmodule] except IOError as e: errorlog.warning("Couldn't create %r. %s" % (tabmodule, e)) |