diff options
author | David Cook <divergentdave@gmail.com> | 2017-04-05 22:46:29 -0500 |
---|---|---|
committer | David Cook <divergentdave@gmail.com> | 2017-04-05 22:46:29 -0500 |
commit | 5293c7be16426abc365e480a9f436e0f0ae26753 (patch) | |
tree | 1287e0cd584628332b647cf10ffc9478b69c7fba | |
parent | d4c866480ff18263e83df5600f017e6528e8d8ce (diff) | |
download | ply-5293c7be16426abc365e480a9f436e0f0ae26753.tar.gz |
Clear table modules from cache when overwriting
-rw-r--r-- | ply/lex.py | 2 | ||||
-rw-r--r-- | ply/yacc.py | 2 |
2 files changed, 4 insertions, 0 deletions
@@ -1041,6 +1041,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 03bd86e..0564460 100644 --- a/ply/yacc.py +++ b/ply/yacc.py @@ -3476,6 +3476,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)) |