georg.brandl
2008-07-23 15:07:12 UTC
Author: georg.brandl
Date: Wed Jul 23 17:07:12 2008
New Revision: 65197
Log:
Remove "ast" aliases from the parser module.
Modified:
python/branches/py3k/Doc/library/parser.rst
python/branches/py3k/Misc/NEWS
python/branches/py3k/Modules/parsermodule.c
Modified: python/branches/py3k/Doc/library/parser.rst
==============================================================================
--- python/branches/py3k/Doc/library/parser.rst (original)
+++ python/branches/py3k/Doc/library/parser.rst Wed Jul 23 17:07:12 2008
@@ -30,11 +30,6 @@
Syntax Tree (AST) generation and compilation stage, using the :mod:`ast`
module.
- The :mod:`parser` module exports the names documented here also with "st"
- replaced by "ast"; this is a legacy from the time when there was no other
- AST and has nothing to do with the AST found in Python 2.5. This is also the
- reason for the functions' keyword arguments being called *ast*, not *st*.
-
There are a few things to note about this module which are important to making
use of the data structures created. This is not a tutorial on editing the parse
trees for Python code, but some examples of using the :mod:`parser` module are
@@ -170,9 +165,9 @@
numbering information.
-.. function:: st2list(ast[, line_info])
+.. function:: st2list(st[, line_info])
- This function accepts an ST object from the caller in *ast* and returns a
+ This function accepts an ST object from the caller in *st* and returns a
Python list representing the equivalent parse tree. The resulting list
representation can be used for inspection or the creation of a new parse tree in
list form. This function does not fail so long as memory is available to build
@@ -188,9 +183,9 @@
This information is omitted if the flag is false or omitted.
-.. function:: st2tuple(ast[, line_info])
+.. function:: st2tuple(st[, line_info])
- This function accepts an ST object from the caller in *ast* and returns a
+ This function accepts an ST object from the caller in *st* and returns a
Python tuple representing the equivalent parse tree. Other than returning a
tuple instead of a list, this function is identical to :func:`st2list`.
@@ -199,7 +194,7 @@
information is omitted if the flag is false or omitted.
-.. function:: compilest(ast[, filename='<syntax-tree>'])
+.. function:: compilest(st[, filename='<syntax-tree>'])
.. index::
builtin: exec
@@ -208,7 +203,7 @@
The Python byte compiler can be invoked on an ST object to produce code objects
which can be used as part of a call to the built-in :func:`exec` or :func:`eval`
functions. This function provides the interface to the compiler, passing the
- internal parse tree from *ast* to the parser, using the source file name
+ internal parse tree from *st* to the parser, using the source file name
specified by the *filename* parameter. The default value supplied for *filename*
indicates that the source was an ST object.
@@ -233,22 +228,22 @@
:func:`suite` or from a parse tree via :func:`sequence2st`.
-.. function:: isexpr(ast)
+.. function:: isexpr(st)
.. index:: builtin: compile
- When *ast* represents an ``'eval'`` form, this function returns true, otherwise
+ When *st* represents an ``'eval'`` form, this function returns true, otherwise
it returns false. This is useful, since code objects normally cannot be queried
for this information using existing built-in functions. Note that the code
objects created by :func:`compilest` cannot be queried like this either, and
are identical to those created by the built-in :func:`compile` function.
-.. function:: issuite(ast)
+.. function:: issuite(st)
This function mirrors :func:`isexpr` in that it reports whether an ST object
represents an ``'exec'`` form, commonly known as a "suite." It is not safe to
- assume that this function is equivalent to ``not isexpr(ast)``, as additional
+ assume that this function is equivalent to ``not isexpr(st)``, as additional
syntactic fragments may be supported in the future.
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Wed Jul 23 17:07:12 2008
@@ -34,6 +34,8 @@
Library
-------
+- Removed "ast" function aliases from the parser module.
+
- Issue #3313: Fixed a crash when a failed dlopen() call does not set
a valid dlerror() message.
Modified: python/branches/py3k/Modules/parsermodule.c
==============================================================================
--- python/branches/py3k/Modules/parsermodule.c (original)
+++ python/branches/py3k/Modules/parsermodule.c Wed Jul 23 17:07:12 2008
@@ -322,7 +322,7 @@
PyObject *res = 0;
int ok;
- static char *keywords[] = {"ast", "line_info", "col_info", NULL};
+ static char *keywords[] = {"st", "line_info", "col_info", NULL};
if (self == NULL || PyModule_Check(self)) {
ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|OO:st2tuple", keywords,
@@ -366,7 +366,7 @@
PyObject *res = 0;
int ok;
- static char *keywords[] = {"ast", "line_info", "col_info", NULL};
+ static char *keywords[] = {"st", "line_info", "col_info", NULL};
if (self == NULL || PyModule_Check(self))
ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|OO:st2list", keywords,
@@ -408,7 +408,7 @@
char* str = "<syntax-tree>";
int ok;
- static char *keywords[] = {"ast", "filename", NULL};
+ static char *keywords[] = {"st", "filename", NULL};
if (self == NULL || PyModule_Check(self))
ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|s:compilest", keywords,
@@ -437,7 +437,7 @@
PyObject* res = 0;
int ok;
- static char *keywords[] = {"ast", NULL};
+ static char *keywords[] = {"st", NULL};
if (self == NULL || PyModule_Check(self))
ok = PyArg_ParseTupleAndKeywords(args, kw, "O!:isexpr", keywords,
@@ -460,7 +460,7 @@
PyObject* res = 0;
int ok;
- static char *keywords[] = {"ast", NULL};
+ static char *keywords[] = {"st", NULL};
if (self == NULL || PyModule_Check(self))
ok = PyArg_ParseTupleAndKeywords(args, kw, "O!:issuite", keywords,
@@ -3011,12 +3011,6 @@
* inheritance.
*/
static PyMethodDef parser_functions[] = {
- {"ast2tuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates a tuple-tree representation of an ST.")},
- {"ast2list", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates a list-tree representation of an ST.")},
- {"compileast", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Compiles an ST object into a code object.")},
{"compilest", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE,
PyDoc_STR("Compiles an ST object into a code object.")},
{"expr", (PyCFunction)parser_expr, PUBLIC_METHOD_TYPE,
@@ -3027,16 +3021,12 @@
PyDoc_STR("Determines if an ST object was created from a suite.")},
{"suite", (PyCFunction)parser_suite, PUBLIC_METHOD_TYPE,
PyDoc_STR("Creates an ST object from a suite.")},
- {"sequence2ast", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates an ST object from a tree representation.")},
{"sequence2st", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
PyDoc_STR("Creates an ST object from a tree representation.")},
{"st2tuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE,
PyDoc_STR("Creates a tuple-tree representation of an ST.")},
{"st2list", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE,
PyDoc_STR("Creates a list-tree representation of an ST.")},
- {"tuple2ast", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates an ST object from a tree representation.")},
{"tuple2st", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
PyDoc_STR("Creates an ST object from a tree representation.")},
@@ -3090,8 +3080,6 @@
return NULL;
Py_INCREF(&PyST_Type);
- PyModule_AddObject(module, "ASTType", (PyObject*)&PyST_Type);
- Py_INCREF(&PyST_Type);
PyModule_AddObject(module, "STType", (PyObject*)&PyST_Type);
PyModule_AddStringConstant(module, "__copyright__",
Date: Wed Jul 23 17:07:12 2008
New Revision: 65197
Log:
Remove "ast" aliases from the parser module.
Modified:
python/branches/py3k/Doc/library/parser.rst
python/branches/py3k/Misc/NEWS
python/branches/py3k/Modules/parsermodule.c
Modified: python/branches/py3k/Doc/library/parser.rst
==============================================================================
--- python/branches/py3k/Doc/library/parser.rst (original)
+++ python/branches/py3k/Doc/library/parser.rst Wed Jul 23 17:07:12 2008
@@ -30,11 +30,6 @@
Syntax Tree (AST) generation and compilation stage, using the :mod:`ast`
module.
- The :mod:`parser` module exports the names documented here also with "st"
- replaced by "ast"; this is a legacy from the time when there was no other
- AST and has nothing to do with the AST found in Python 2.5. This is also the
- reason for the functions' keyword arguments being called *ast*, not *st*.
-
There are a few things to note about this module which are important to making
use of the data structures created. This is not a tutorial on editing the parse
trees for Python code, but some examples of using the :mod:`parser` module are
@@ -170,9 +165,9 @@
numbering information.
-.. function:: st2list(ast[, line_info])
+.. function:: st2list(st[, line_info])
- This function accepts an ST object from the caller in *ast* and returns a
+ This function accepts an ST object from the caller in *st* and returns a
Python list representing the equivalent parse tree. The resulting list
representation can be used for inspection or the creation of a new parse tree in
list form. This function does not fail so long as memory is available to build
@@ -188,9 +183,9 @@
This information is omitted if the flag is false or omitted.
-.. function:: st2tuple(ast[, line_info])
+.. function:: st2tuple(st[, line_info])
- This function accepts an ST object from the caller in *ast* and returns a
+ This function accepts an ST object from the caller in *st* and returns a
Python tuple representing the equivalent parse tree. Other than returning a
tuple instead of a list, this function is identical to :func:`st2list`.
@@ -199,7 +194,7 @@
information is omitted if the flag is false or omitted.
-.. function:: compilest(ast[, filename='<syntax-tree>'])
+.. function:: compilest(st[, filename='<syntax-tree>'])
.. index::
builtin: exec
@@ -208,7 +203,7 @@
The Python byte compiler can be invoked on an ST object to produce code objects
which can be used as part of a call to the built-in :func:`exec` or :func:`eval`
functions. This function provides the interface to the compiler, passing the
- internal parse tree from *ast* to the parser, using the source file name
+ internal parse tree from *st* to the parser, using the source file name
specified by the *filename* parameter. The default value supplied for *filename*
indicates that the source was an ST object.
@@ -233,22 +228,22 @@
:func:`suite` or from a parse tree via :func:`sequence2st`.
-.. function:: isexpr(ast)
+.. function:: isexpr(st)
.. index:: builtin: compile
- When *ast* represents an ``'eval'`` form, this function returns true, otherwise
+ When *st* represents an ``'eval'`` form, this function returns true, otherwise
it returns false. This is useful, since code objects normally cannot be queried
for this information using existing built-in functions. Note that the code
objects created by :func:`compilest` cannot be queried like this either, and
are identical to those created by the built-in :func:`compile` function.
-.. function:: issuite(ast)
+.. function:: issuite(st)
This function mirrors :func:`isexpr` in that it reports whether an ST object
represents an ``'exec'`` form, commonly known as a "suite." It is not safe to
- assume that this function is equivalent to ``not isexpr(ast)``, as additional
+ assume that this function is equivalent to ``not isexpr(st)``, as additional
syntactic fragments may be supported in the future.
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Wed Jul 23 17:07:12 2008
@@ -34,6 +34,8 @@
Library
-------
+- Removed "ast" function aliases from the parser module.
+
- Issue #3313: Fixed a crash when a failed dlopen() call does not set
a valid dlerror() message.
Modified: python/branches/py3k/Modules/parsermodule.c
==============================================================================
--- python/branches/py3k/Modules/parsermodule.c (original)
+++ python/branches/py3k/Modules/parsermodule.c Wed Jul 23 17:07:12 2008
@@ -322,7 +322,7 @@
PyObject *res = 0;
int ok;
- static char *keywords[] = {"ast", "line_info", "col_info", NULL};
+ static char *keywords[] = {"st", "line_info", "col_info", NULL};
if (self == NULL || PyModule_Check(self)) {
ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|OO:st2tuple", keywords,
@@ -366,7 +366,7 @@
PyObject *res = 0;
int ok;
- static char *keywords[] = {"ast", "line_info", "col_info", NULL};
+ static char *keywords[] = {"st", "line_info", "col_info", NULL};
if (self == NULL || PyModule_Check(self))
ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|OO:st2list", keywords,
@@ -408,7 +408,7 @@
char* str = "<syntax-tree>";
int ok;
- static char *keywords[] = {"ast", "filename", NULL};
+ static char *keywords[] = {"st", "filename", NULL};
if (self == NULL || PyModule_Check(self))
ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|s:compilest", keywords,
@@ -437,7 +437,7 @@
PyObject* res = 0;
int ok;
- static char *keywords[] = {"ast", NULL};
+ static char *keywords[] = {"st", NULL};
if (self == NULL || PyModule_Check(self))
ok = PyArg_ParseTupleAndKeywords(args, kw, "O!:isexpr", keywords,
@@ -460,7 +460,7 @@
PyObject* res = 0;
int ok;
- static char *keywords[] = {"ast", NULL};
+ static char *keywords[] = {"st", NULL};
if (self == NULL || PyModule_Check(self))
ok = PyArg_ParseTupleAndKeywords(args, kw, "O!:issuite", keywords,
@@ -3011,12 +3011,6 @@
* inheritance.
*/
static PyMethodDef parser_functions[] = {
- {"ast2tuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates a tuple-tree representation of an ST.")},
- {"ast2list", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates a list-tree representation of an ST.")},
- {"compileast", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Compiles an ST object into a code object.")},
{"compilest", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE,
PyDoc_STR("Compiles an ST object into a code object.")},
{"expr", (PyCFunction)parser_expr, PUBLIC_METHOD_TYPE,
@@ -3027,16 +3021,12 @@
PyDoc_STR("Determines if an ST object was created from a suite.")},
{"suite", (PyCFunction)parser_suite, PUBLIC_METHOD_TYPE,
PyDoc_STR("Creates an ST object from a suite.")},
- {"sequence2ast", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates an ST object from a tree representation.")},
{"sequence2st", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
PyDoc_STR("Creates an ST object from a tree representation.")},
{"st2tuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE,
PyDoc_STR("Creates a tuple-tree representation of an ST.")},
{"st2list", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE,
PyDoc_STR("Creates a list-tree representation of an ST.")},
- {"tuple2ast", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates an ST object from a tree representation.")},
{"tuple2st", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
PyDoc_STR("Creates an ST object from a tree representation.")},
@@ -3090,8 +3080,6 @@
return NULL;
Py_INCREF(&PyST_Type);
- PyModule_AddObject(module, "ASTType", (PyObject*)&PyST_Type);
- Py_INCREF(&PyST_Type);
PyModule_AddObject(module, "STType", (PyObject*)&PyST_Type);
PyModule_AddStringConstant(module, "__copyright__",