diff options
author | David Beazley <dave@dabeaz.com> | 2017-04-13 06:50:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-13 06:50:03 -0500 |
commit | 43fe6fc76e5cf2003a36e4053b13ac425f2634d6 (patch) | |
tree | f92993db921293f219eb4cb3c73c94a430b4c37e | |
parent | 2da92886817ed637932daa7de09518421b0e5ef1 (diff) | |
parent | 5293c7be16426abc365e480a9f436e0f0ae26753 (diff) | |
download | ply-43fe6fc76e5cf2003a36e4053b13ac425f2634d6.tar.gz |
Merge pull request #119 from divergentdave/clear-modules-cache
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
@@ -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)) |