remove ast.__version__ (closes #12273) · python/cpython@0bd152c · GitHub
Skip to content

Commit 0bd152c

Browse files
committed
remove ast.__version__ (closes #12273)
1 parent e720725 commit 0bd152c

5 files changed

Lines changed: 3 additions & 44 deletions

File tree

Doc/library/ast.rst

Lines changed: 0 additions & 3 deletions

Lib/ast.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
:license: Python License.
2626
"""
2727
from _ast import *
28-
from _ast import __version__
2928

3029

3130
def parse(source, filename='<unknown>', mode='exec'):

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #12273: Remove ast.__version__. AST changes can be accounted for by
14+
checking sys.version_info or sys._mercurial.
15+
1316
- Issue #11627: Fix segfault when __new__ on a exception returns a non-exception
1417
class.
1518

Parser/asdl_c.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -900,10 +900,6 @@ def visitModule(self, mod):
900900
self.emit('if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return NULL;', 1)
901901
self.emit('if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)', 1)
902902
self.emit("return NULL;", 2)
903-
# Value of version: "$Revision$"
904-
self.emit('if (PyModule_AddStringConstant(m, "__version__", "%s") < 0)'
905-
% (mod.version,), 1)
906-
self.emit("return NULL;", 2)
907903
for dfn in mod.dfns:
908904
self.visit(dfn)
909905
self.emit("return m;", 1)
@@ -1124,29 +1120,6 @@ def visit(self, object):
11241120

11251121
common_msg = "/* File automatically generated by %s. */\n\n"
11261122

1127-
c_file_msg = """
1128-
/*
1129-
__version__ %s.
1130-
1131-
This module must be committed separately after each AST grammar change;
1132-
The __version__ number is set to the revision number of the commit
1133-
containing the grammar change.
1134-
*/
1135-
1136-
"""
1137-
1138-
1139-
def get_file_revision(f):
1140-
"""Fish out the last change to a file in hg."""
1141-
args = ["hg", "log", "--template", "{node|short}", "--limit", "1", f]
1142-
p = subprocess.Popen(args, stdout=subprocess.PIPE)
1143-
out = p.communicate()[0]
1144-
if p.returncode:
1145-
print >> sys.stderr, "error return code from hg"
1146-
sys.exit(1)
1147-
return out
1148-
1149-
11501123
def main(srcfile):
11511124
argv0 = sys.argv[0]
11521125
components = argv0.split(os.sep)
@@ -1155,7 +1128,6 @@ def main(srcfile):
11551128
mod = asdl.parse(srcfile)
11561129
if not asdl.check(mod):
11571130
sys.exit(1)
1158-
mod.version = get_file_revision(srcfile)
11591131
if INC_DIR:
11601132
p = "%s/%s-ast.h" % (INC_DIR, mod.name)
11611133
f = open(p, "w")
@@ -1175,7 +1147,6 @@ def main(srcfile):
11751147
p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c")
11761148
f = open(p, "w")
11771149
f.write(auto_gen_msg)
1178-
f.write(c_file_msg % (mod.version,))
11791150
f.write('#include "Python.h"\n')
11801151
f.write('#include "%s-ast.h"\n' % mod.name)
11811152
f.write('\n')

Python/Python-ast.c

Lines changed: 0 additions & 11 deletions

0 commit comments

Comments
 (0)