]> granicus.if.org Git - python/commitdiff
remove ast.__version__ (closes #12273)
authorBenjamin Peterson <benjamin@python.org>
Sat, 16 Jul 2011 02:10:13 +0000 (21:10 -0500)
committerBenjamin Peterson <benjamin@python.org>
Sat, 16 Jul 2011 02:10:13 +0000 (21:10 -0500)
Doc/library/ast.rst
Lib/ast.py
Misc/NEWS
Parser/asdl_c.py
Python/Python-ast.c

index 85081be39911a8116587ea3d5a7b7a1d5f20403c..16de3ca09723c713153b8bf0bc23e992cf19d1f1 100644 (file)
@@ -96,9 +96,6 @@ Node classes
 Abstract Grammar
 ----------------
 
-The module defines a string constant ``__version__`` which is the Mercurial
-revision of the file shown below.
-
 The abstract grammar is currently defined as follows:
 
 .. literalinclude:: ../../Parser/Python.asdl
index fb5adac8fd9ae8b6a990797fbf20e2647e5456ea..13f59f9dfa2ca2248f94bab4bafcfe31883b5e93 100644 (file)
@@ -25,7 +25,6 @@
     :license: Python License.
 """
 from _ast import *
-from _ast import __version__
 
 
 def parse(source, filename='<unknown>', mode='exec'):
index e75de01c3db0b33cf4b0ff8a0ef76ccb74aae4bf..dd40d40a02e42968da80e8a85034a9ddbb2bd485 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
 Core and Builtins
 -----------------
 
+- Issue #12273: Remove ast.__version__. AST changes can be accounted for by
+  checking sys.version_info or sys._mercurial.
+
 - Issue #11627: Fix segfault when __new__ on a exception returns a non-exception
   class.
 
index cdce5a3f032514ec5a810630db39078c1f8dfbe1..22ef3d0af1b4ccc36c4b8958f56a0972f031f563 100755 (executable)
@@ -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')
index b5976264635facafab9473f9b7ae6499e2acb876..96c6bf83fc7e5fc4555e293ef3651b01119d7acb 100644 (file)
@@ -1,14 +1,5 @@
 /* File automatically generated by Parser/asdl_c.py. */
 
-
-/*
-   __version__ e0e663132363.
-
-   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.
-*/
-
 #include "Python.h"
 #include "Python-ast.h"
 
@@ -6750,8 +6741,6 @@ PyInit__ast(void)
             NULL;
         if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
                 return NULL;
-        if (PyModule_AddStringConstant(m, "__version__", "e0e663132363") < 0)
-                return NULL;
         if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return
             NULL;
         if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)