Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
62af5641
Commit
62af5641
authored
Mar 12, 2011
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert ast versioning to mercurial
parent
79b38d16
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
26 deletions
+31
-26
Doc/library/ast.rst
Doc/library/ast.rst
+2
-2
Misc/NEWS
Misc/NEWS
+2
-0
Parser/Python.asdl
Parser/Python.asdl
+1
-1
Parser/asdl.py
Parser/asdl.py
+7
-16
Parser/asdl_c.py
Parser/asdl_c.py
+16
-5
Python/Python-ast.c
Python/Python-ast.c
+3
-2
No files found.
Doc/library/ast.rst
View file @
62af5641
...
@@ -96,8 +96,8 @@ Node classes
...
@@ -96,8 +96,8 @@ Node classes
Abstract Grammar
Abstract Grammar
----------------
----------------
The module defines a string constant ``__version__`` which is the
decim
al
The module defines a string constant ``__version__`` which is the
Mercuri
al
Subversion revision number
of the file shown below.
revision
of the file shown below.
The abstract grammar is currently defined as follows:
The abstract grammar is currently defined as follows:
...
...
Misc/NEWS
View file @
62af5641
...
@@ -10,6 +10,8 @@ What's New in Python 3.3 Alpha 1?
...
@@ -10,6 +10,8 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
Core and Builtins
-----------------
-----------------
- _ast.__version__ is now a Mercurial integer and hex revision.
- Issue #9856: Change object.__format__ with a non-empty format string
- Issue #9856: Change object.__format__ with a non-empty format string
to be a DeprecationWarning. In 3.2 it was a PendingDeprecationWarning.
to be a DeprecationWarning. In 3.2 it was a PendingDeprecationWarning.
In 3.4 it will be a TypeError.
In 3.4 it will be a TypeError.
...
...
Parser/Python.asdl
View file @
62af5641
-- ASDL's four builtin types are identifier, int, string, object
-- ASDL's four builtin types are identifier, int, string, object
module Python
version "$Revision$"
module Python
{
{
mod = Module(stmt* body)
mod = Module(stmt* body)
| Interactive(stmt* body)
| Interactive(stmt* body)
...
...
Parser/asdl.py
View file @
62af5641
...
@@ -114,28 +114,20 @@ class ASDLParser(spark.GenericParser, object):
...
@@ -114,28 +114,20 @@ class ASDLParser(spark.GenericParser, object):
raise
ASDLSyntaxError
(
tok
.
lineno
,
tok
)
raise
ASDLSyntaxError
(
tok
.
lineno
,
tok
)
def
p_module_0
(
self
,
info
):
def
p_module_0
(
self
,
info
):
" module ::= Id Id
version
{ } "
" module ::= Id Id { } "
module
,
name
,
version
,
_0
,
_1
=
info
module
,
name
,
_0
,
_1
=
info
if
module
.
value
!=
"module"
:
if
module
.
value
!=
"module"
:
raise
ASDLSyntaxError
(
module
.
lineno
,
raise
ASDLSyntaxError
(
module
.
lineno
,
msg
=
"expected 'module', found %s"
%
module
)
msg
=
"expected 'module', found %s"
%
module
)
return
Module
(
name
,
None
,
version
)
return
Module
(
name
,
None
)
def
p_module
(
self
,
info
):
def
p_module
(
self
,
info
):
" module ::= Id Id
version
{ definitions } "
" module ::= Id Id { definitions } "
module
,
name
,
version
,
_0
,
definitions
,
_1
=
info
module
,
name
,
_0
,
definitions
,
_1
=
info
if
module
.
value
!=
"module"
:
if
module
.
value
!=
"module"
:
raise
ASDLSyntaxError
(
module
.
lineno
,
raise
ASDLSyntaxError
(
module
.
lineno
,
msg
=
"expected 'module', found %s"
%
module
)
msg
=
"expected 'module', found %s"
%
module
)
return
Module
(
name
,
definitions
,
version
)
return
Module
(
name
,
definitions
)
def
p_version
(
self
,
info
):
"version ::= Id String"
version
,
V
=
info
if
version
.
value
!=
"version"
:
raise
ASDLSyntaxError
(
version
.
lineno
,
msg
=
"expected 'version', found %"
%
version
)
return
V
def
p_definition_0
(
self
,
definition
):
def
p_definition_0
(
self
,
definition
):
" definitions ::= definition "
" definitions ::= definition "
...
@@ -246,10 +238,9 @@ class AST(object):
...
@@ -246,10 +238,9 @@ class AST(object):
pass
# a marker class
pass
# a marker class
class
Module
(
AST
):
class
Module
(
AST
):
def
__init__
(
self
,
name
,
dfns
,
version
):
def
__init__
(
self
,
name
,
dfns
):
self
.
name
=
name
self
.
name
=
name
self
.
dfns
=
dfns
self
.
dfns
=
dfns
self
.
version
=
version
self
.
types
=
{}
# maps type name to value (from dfns)
self
.
types
=
{}
# maps type name to value (from dfns)
for
type
in
dfns
:
for
type
in
dfns
:
self
.
types
[
type
.
name
.
value
]
=
type
.
value
self
.
types
[
type
.
name
.
value
]
=
type
.
value
...
...
Parser/asdl_c.py
View file @
62af5641
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
# handle fields that have a type but no name
# handle fields that have a type but no name
import
os
,
sys
import
os
,
sys
import
subprocess
import
asdl
import
asdl
...
@@ -882,9 +883,6 @@ static int add_ast_fields(void)
...
@@ -882,9 +883,6 @@ static int add_ast_fields(void)
self
.
emit
(
"if (!%s_singleton) return 0;"
%
cons
.
name
,
1
)
self
.
emit
(
"if (!%s_singleton) return 0;"
%
cons
.
name
,
1
)
def
parse_version
(
mod
):
return
mod
.
version
.
value
[
12
:
-
3
]
class
ASTModuleVisitor
(
PickleVisitor
):
class
ASTModuleVisitor
(
PickleVisitor
):
def
visitModule
(
self
,
mod
):
def
visitModule
(
self
,
mod
):
...
@@ -904,7 +902,7 @@ class ASTModuleVisitor(PickleVisitor):
...
@@ -904,7 +902,7 @@ class ASTModuleVisitor(PickleVisitor):
self
.
emit
(
"return NULL;"
,
2
)
self
.
emit
(
"return NULL;"
,
2
)
# Value of version: "$Revision$"
# Value of version: "$Revision$"
self
.
emit
(
'if (PyModule_AddStringConstant(m, "__version__", "%s") < 0)'
self
.
emit
(
'if (PyModule_AddStringConstant(m, "__version__", "%s") < 0)'
%
parse_version
(
mod
),
1
)
%
(
mod
.
version
,
),
1
)
self
.
emit
(
"return NULL;"
,
2
)
self
.
emit
(
"return NULL;"
,
2
)
for
dfn
in
mod
.
dfns
:
for
dfn
in
mod
.
dfns
:
self
.
visit
(
dfn
)
self
.
visit
(
dfn
)
...
@@ -1137,6 +1135,18 @@ c_file_msg = """
...
@@ -1137,6 +1135,18 @@ c_file_msg = """
"""
"""
def
get_file_revision
(
f
):
"""Fish out the last change to a file in hg."""
args
=
[
"hg"
,
"log"
,
"--template"
,
"{rev}:{node|short}"
,
"--limit"
,
"1"
]
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
):
def
main
(
srcfile
):
argv0
=
sys
.
argv
[
0
]
argv0
=
sys
.
argv
[
0
]
components
=
argv0
.
split
(
os
.
sep
)
components
=
argv0
.
split
(
os
.
sep
)
...
@@ -1145,6 +1155,7 @@ def main(srcfile):
...
@@ -1145,6 +1155,7 @@ def main(srcfile):
mod
=
asdl
.
parse
(
srcfile
)
mod
=
asdl
.
parse
(
srcfile
)
if
not
asdl
.
check
(
mod
):
if
not
asdl
.
check
(
mod
):
sys
.
exit
(
1
)
sys
.
exit
(
1
)
mod
.
version
=
get_file_revision
(
srcfile
)
if
INC_DIR
:
if
INC_DIR
:
p
=
"%s/%s-ast.h"
%
(
INC_DIR
,
mod
.
name
)
p
=
"%s/%s-ast.h"
%
(
INC_DIR
,
mod
.
name
)
f
=
open
(
p
,
"w"
)
f
=
open
(
p
,
"w"
)
...
@@ -1164,7 +1175,7 @@ def main(srcfile):
...
@@ -1164,7 +1175,7 @@ def main(srcfile):
p
=
os
.
path
.
join
(
SRC_DIR
,
str
(
mod
.
name
)
+
"-ast.c"
)
p
=
os
.
path
.
join
(
SRC_DIR
,
str
(
mod
.
name
)
+
"-ast.c"
)
f
=
open
(
p
,
"w"
)
f
=
open
(
p
,
"w"
)
f
.
write
(
auto_gen_msg
)
f
.
write
(
auto_gen_msg
)
f
.
write
(
c_file_msg
%
parse_version
(
mod
))
f
.
write
(
c_file_msg
%
(
mod
.
version
,
))
f
.
write
(
'#include "Python.h"
\
n
'
)
f
.
write
(
'#include "Python.h"
\
n
'
)
f
.
write
(
'#include "%s-ast.h"
\
n
'
%
mod
.
name
)
f
.
write
(
'#include "%s-ast.h"
\
n
'
%
mod
.
name
)
f
.
write
(
'
\
n
'
)
f
.
write
(
'
\
n
'
)
...
...
Python/Python-ast.c
View file @
62af5641
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
/*
/*
__version__
82163
.
__version__
68409:c017695acf19
.
This module must be committed separately after each AST grammar change;
This module must be committed separately after each AST grammar change;
The __version__ number is set to the revision number of the commit
The __version__ number is set to the revision number of the commit
...
@@ -6739,7 +6739,8 @@ PyInit__ast(void)
...
@@ -6739,7 +6739,8 @@ PyInit__ast(void)
NULL
;
NULL
;
if
(
PyModule_AddIntConstant
(
m
,
"PyCF_ONLY_AST"
,
PyCF_ONLY_AST
)
<
0
)
if
(
PyModule_AddIntConstant
(
m
,
"PyCF_ONLY_AST"
,
PyCF_ONLY_AST
)
<
0
)
return
NULL
;
return
NULL
;
if
(
PyModule_AddStringConstant
(
m
,
"__version__"
,
"82163"
)
<
0
)
if
(
PyModule_AddStringConstant
(
m
,
"__version__"
,
"68409:c017695acf19"
)
<
0
)
return
NULL
;
return
NULL
;
if
(
PyDict_SetItemString
(
d
,
"mod"
,
(
PyObject
*
)
mod_type
)
<
0
)
return
if
(
PyDict_SetItemString
(
d
,
"mod"
,
(
PyObject
*
)
mod_type
)
<
0
)
return
NULL
;
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment