remove ast.__version__ (closes #12273)

This commit is contained in:
Benjamin Peterson 2011-07-15 21:10:13 -05:00
parent e720725c12
commit 0bd152cd67
5 changed files with 3 additions and 44 deletions

View file

@ -900,10 +900,6 @@ class ASTModuleVisitor(PickleVisitor):
self.emit('if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return NULL;', 1)
self.emit('if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)', 1)
self.emit("return NULL;", 2)
# Value of version: "$Revision$"
self.emit('if (PyModule_AddStringConstant(m, "__version__", "%s") < 0)'
% (mod.version,), 1)
self.emit("return NULL;", 2)
for dfn in mod.dfns:
self.visit(dfn)
self.emit("return m;", 1)
@ -1124,29 +1120,6 @@ class ChainOfVisitors:
common_msg = "/* File automatically generated by %s. */\n\n"
c_file_msg = """
/*
__version__ %s.
This module must be committed separately after each AST grammar change;
The __version__ number is set to the revision number of the commit
containing the grammar change.
*/
"""
def get_file_revision(f):
"""Fish out the last change to a file in hg."""
args = ["hg", "log", "--template", "{node|short}", "--limit", "1", f]
p = subprocess.Popen(args, stdout=subprocess.PIPE)
out = p.communicate()[0]
if p.returncode:
print >> sys.stderr, "error return code from hg"
sys.exit(1)
return out
def main(srcfile):
argv0 = sys.argv[0]
components = argv0.split(os.sep)
@ -1155,7 +1128,6 @@ def main(srcfile):
mod = asdl.parse(srcfile)
if not asdl.check(mod):
sys.exit(1)
mod.version = get_file_revision(srcfile)
if INC_DIR:
p = "%s/%s-ast.h" % (INC_DIR, mod.name)
f = open(p, "w")
@ -1175,7 +1147,6 @@ def main(srcfile):
p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c")
f = open(p, "w")
f.write(auto_gen_msg)
f.write(c_file_msg % (mod.version,))
f.write('#include "Python.h"\n')
f.write('#include "%s-ast.h"\n' % mod.name)
f.write('\n')