summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cook <divergentdave@gmail.com>2017-04-05 22:46:29 -0500
committerDavid Cook <divergentdave@gmail.com>2017-04-05 22:46:29 -0500
commit5293c7be16426abc365e480a9f436e0f0ae26753 (patch)
tree1287e0cd584628332b647cf10ffc9478b69c7fba
parentd4c866480ff18263e83df5600f017e6528e8d8ce (diff)
downloadply-5293c7be16426abc365e480a9f436e0f0ae26753.tar.gz
Clear table modules from cache when overwriting
-rw-r--r--ply/lex.py2
-rw-r--r--ply/yacc.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/ply/lex.py b/ply/lex.py
index 3e240d1..99128e0 100644
--- a/ply/lex.py
+++ b/ply/lex.py
@@ -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))