Python-checkins
Threads by month
- ----- 2025 -----
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
June 2016
- 5 participants
- 774 discussions

June 2, 2016
https://hg.python.org/cpython/rev/42356e44af23
changeset: 101603:42356e44af23
branch: 2.7
parent: 101597:b0b463760b45
user: Benjamin Peterson <benjamin(a)python.org>
date: Thu Jun 02 11:35:59 2016 -0700
summary:
note that Py_VISIT handles NULL (closes #27183)
files:
Doc/c-api/gcsupport.rst | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Doc/c-api/gcsupport.rst b/Doc/c-api/gcsupport.rst
--- a/Doc/c-api/gcsupport.rst
+++ b/Doc/c-api/gcsupport.rst
@@ -137,9 +137,10 @@
.. c:function:: void Py_VISIT(PyObject *o)
- Call the *visit* callback, with arguments *o* and *arg*. If *visit* returns
- a non-zero value, then return it. Using this macro, :c:member:`~PyTypeObject.tp_traverse`
- handlers look like::
+ If *o* is not *NULL*, call the *visit* callback, with arguments *o*
+ and *arg*. If *visit* returns a non-zero value, then return it.
+ Using this macro, :c:member:`~PyTypeObject.tp_traverse` handlers
+ look like::
static int
my_traverse(Noddy *self, visitproc visit, void *arg)
--
Repository URL: https://hg.python.org/cpython
1
0

cpython: replace custom validation logic in the parse module with a simple DFA validator
by benjamin.peterson June 2, 2016
by benjamin.peterson June 2, 2016
June 2, 2016
https://hg.python.org/cpython/rev/4a9159ea2536
changeset: 101601:4a9159ea2536
user: Benjamin Peterson <benjamin(a)python.org>
date: Thu Jun 02 11:30:18 2016 -0700
summary:
replace custom validation logic in the parse module with a simple DFA validator (closes #26526)
Patch from A. Skrobov.
files:
Misc/NEWS | 3 +
Modules/parsermodule.c | 2545 +--------------------------
2 files changed, 96 insertions(+), 2452 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,9 @@
Library
-------
+- Issue #26526: Replace custom parse tree validation in the parser
+ module with a simple DFA validator.
+
- Issue #27114: Fix SSLContext._load_windows_store_certs fails with
PermissionError
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -670,9 +670,75 @@
static node* build_node_tree(PyObject *tuple);
-static int validate_expr_tree(node *tree);
-static int validate_file_input(node *tree);
-static int validate_encoding_decl(node *tree);
+
+static int
+validate_node(node *tree)
+{
+ int type = TYPE(tree);
+ int nch = NCH(tree);
+ dfa *nt_dfa;
+ state *dfa_state;
+ int pos, arc;
+
+ assert(ISNONTERMINAL(type));
+ type -= NT_OFFSET;
+ if (type >= _PyParser_Grammar.g_ndfas) {
+ PyErr_Format(parser_error, "Unrecognized node type %d.", TYPE(tree));
+ return 0;
+ }
+ nt_dfa = &_PyParser_Grammar.g_dfa[type];
+ REQ(tree, nt_dfa->d_type);
+
+ /* Run the DFA for this nonterminal. */
+ dfa_state = &nt_dfa->d_state[nt_dfa->d_initial];
+ for (pos = 0; pos < nch; ++pos) {
+ node *ch = CHILD(tree, pos);
+ int ch_type = TYPE(ch);
+ for (arc = 0; arc < dfa_state->s_narcs; ++arc) {
+ short a_label = dfa_state->s_arc[arc].a_lbl;
+ assert(a_label < _PyParser_Grammar.g_ll.ll_nlabels);
+ if (_PyParser_Grammar.g_ll.ll_label[a_label].lb_type == ch_type) {
+ /* The child is acceptable; if non-terminal, validate it recursively. */
+ if (ISNONTERMINAL(ch_type) && !validate_node(ch))
+ return 0;
+
+ /* Update the state, and move on to the next child. */
+ dfa_state = &nt_dfa->d_state[dfa_state->s_arc[arc].a_arrow];
+ goto arc_found;
+ }
+ }
+ /* What would this state have accepted? */
+ {
+ short a_label = dfa_state->s_arc->a_lbl;
+ int next_type;
+ if (!a_label) /* Wouldn't accept any more children */
+ goto illegal_num_children;
+
+ next_type = _PyParser_Grammar.g_ll.ll_label[a_label].lb_type;
+ if (ISNONTERMINAL(next_type))
+ PyErr_Format(parser_error, "Expected node type %d, got %d.",
+ next_type, ch_type);
+ else
+ PyErr_Format(parser_error, "Illegal terminal: expected %s.",
+ _PyParser_TokenNames[next_type]);
+ return 0;
+ }
+
+arc_found:
+ continue;
+ }
+ /* Are we in a final state? If so, return 1 for successful validation. */
+ for (arc = 0; arc < dfa_state->s_narcs; ++arc) {
+ if (!dfa_state->s_arc[arc].a_lbl) {
+ return 1;
+ }
+ }
+
+illegal_num_children:
+ PyErr_Format(parser_error,
+ "Illegal number of children for %s node.", nt_dfa->d_name);
+ return 0;
+}
/* PyObject* parser_tuple2st(PyObject* self, PyObject* args)
*
@@ -681,7 +747,7 @@
* tuple can be validated. It does this by checking the first code of the
* tuple, and, if acceptable, builds the internal representation. If this
* step succeeds, the internal representation is validated as fully as
- * possible with the various validate_*() routines defined below.
+ * possible with the recursive validate_node() routine defined above.
*
* This function must be changed if support is to be added for PyST_FRAGMENT
* ST objects.
@@ -710,33 +776,35 @@
*/
tree = build_node_tree(tuple);
if (tree != 0) {
- int start_sym = TYPE(tree);
- if (start_sym == eval_input) {
+ node *validation_root = tree;
+ int tree_type = 0;
+ switch (TYPE(tree)) {
+ case eval_input:
/* Might be an eval form. */
- if (validate_expr_tree(tree))
- st = parser_newstobject(tree, PyST_EXPR);
- else
- PyNode_Free(tree);
- }
- else if (start_sym == file_input) {
+ tree_type = PyST_EXPR;
+ break;
+ case encoding_decl:
+ /* This looks like an encoding_decl so far. */
+ if (NCH(tree) != 1)
+ err_string("Error Parsing encoding_decl");
+ validation_root = CHILD(tree, 0);
+ /* Fall through */
+ case file_input:
/* This looks like an exec form so far. */
- if (validate_file_input(tree))
- st = parser_newstobject(tree, PyST_SUITE);
- else
- PyNode_Free(tree);
- }
- else if (start_sym == encoding_decl) {
- /* This looks like an encoding_decl so far. */
- if (validate_encoding_decl(tree))
- st = parser_newstobject(tree, PyST_SUITE);
- else
- PyNode_Free(tree);
- }
- else {
+
+ tree_type = PyST_SUITE;
+ break;
+ default:
/* This is a fragment, at best. */
PyNode_Free(tree);
err_string("parse tree does not use a valid start symbol");
+ return (0);
}
+
+ if (validate_node(validation_root))
+ st = parser_newstobject(tree, tree_type);
+ else
+ PyNode_Free(tree);
}
/* Make sure we raise an exception on all errors. We should never
* get this, but we'd do well to be sure something is done.
@@ -981,2433 +1049,6 @@
}
-/*
- * Validation routines used within the validation section:
- */
-static int validate_terminal(node *terminal, int type, const char *string);
-
-#define validate_ampersand(ch) validate_terminal(ch, AMPER, "&")
-#define validate_circumflex(ch) validate_terminal(ch, CIRCUMFLEX, "^")
-#define validate_colon(ch) validate_terminal(ch, COLON, ":")
-#define validate_comma(ch) validate_terminal(ch, COMMA, ",")
-#define validate_dedent(ch) validate_terminal(ch, DEDENT, "")
-#define validate_equal(ch) validate_terminal(ch, EQUAL, "=")
-#define validate_indent(ch) validate_terminal(ch, INDENT, (char*)NULL)
-#define validate_lparen(ch) validate_terminal(ch, LPAR, "(")
-#define validate_newline(ch) validate_terminal(ch, NEWLINE, (char*)NULL)
-#define validate_rparen(ch) validate_terminal(ch, RPAR, ")")
-#define validate_semi(ch) validate_terminal(ch, SEMI, ";")
-#define validate_star(ch) validate_terminal(ch, STAR, "*")
-#define validate_vbar(ch) validate_terminal(ch, VBAR, "|")
-#define validate_doublestar(ch) validate_terminal(ch, DOUBLESTAR, "**")
-#define validate_dot(ch) validate_terminal(ch, DOT, ".")
-#define validate_at(ch) validate_terminal(ch, AT, "@")
-#define validate_rarrow(ch) validate_terminal(ch, RARROW, "->")
-#define validate_name(ch, str) validate_terminal(ch, NAME, str)
-
-#define VALIDATER(n) static int validate_##n(node *tree)
-
-VALIDATER(node); VALIDATER(small_stmt);
-VALIDATER(class); VALIDATER(node);
-VALIDATER(parameters); VALIDATER(suite);
-VALIDATER(testlist); VALIDATER(varargslist);
-VALIDATER(vfpdef);
-VALIDATER(stmt); VALIDATER(simple_stmt);
-VALIDATER(expr_stmt); VALIDATER(power);
-VALIDATER(del_stmt);
-VALIDATER(return_stmt); VALIDATER(raise_stmt);
-VALIDATER(import_stmt); VALIDATER(import_stmt);
-VALIDATER(import_name); VALIDATER(yield_stmt);
-VALIDATER(global_stmt); VALIDATER(nonlocal_stmt);
-VALIDATER(assert_stmt);
-VALIDATER(compound_stmt); VALIDATER(test_or_star_expr);
-VALIDATER(while); VALIDATER(for);
-VALIDATER(try); VALIDATER(except_clause);
-VALIDATER(test); VALIDATER(and_test);
-VALIDATER(not_test); VALIDATER(comparison);
-VALIDATER(comp_op);
-VALIDATER(star_expr); VALIDATER(expr);
-VALIDATER(xor_expr); VALIDATER(and_expr);
-VALIDATER(shift_expr); VALIDATER(arith_expr);
-VALIDATER(term); VALIDATER(factor);
-VALIDATER(atom); VALIDATER(lambdef);
-VALIDATER(trailer); VALIDATER(subscript);
-VALIDATER(subscriptlist); VALIDATER(sliceop);
-VALIDATER(exprlist); VALIDATER(dictorsetmaker);
-VALIDATER(arglist); VALIDATER(argument);
-VALIDATER(comp_for);
-VALIDATER(comp_iter); VALIDATER(comp_if);
-VALIDATER(testlist_comp); VALIDATER(yield_expr);
-VALIDATER(or_test);
-VALIDATER(test_nocond); VALIDATER(lambdef_nocond);
-VALIDATER(yield_arg);
-VALIDATER(async_funcdef); VALIDATER(async_stmt);
-VALIDATER(atom_expr);
-
-#undef VALIDATER
-
-#define is_even(n) (((n) & 1) == 0)
-#define is_odd(n) (((n) & 1) == 1)
-
-
-static int
-validate_ntype(node *n, int t)
-{
- if (TYPE(n) != t) {
- PyErr_Format(parser_error, "Expected node type %d, got %d.",
- t, TYPE(n));
- return 0;
- }
- return 1;
-}
-
-
-/* Verifies that the number of child nodes is exactly 'num', raising
- * an exception if it isn't. The exception message does not indicate
- * the exact number of nodes, allowing this to be used to raise the
- * "right" exception when the wrong number of nodes is present in a
- * specific variant of a statement's syntax. This is commonly used
- * in that fashion.
- */
-static int
-validate_numnodes(node *n, int num, const char *const name)
-{
- if (NCH(n) != num) {
- PyErr_Format(parser_error,
- "Illegal number of children for %s node.", name);
- return 0;
- }
- return 1;
-}
-
-
-static int
-validate_terminal(node *terminal, int type, const char *string)
-{
- int res = (validate_ntype(terminal, type)
- && ((string == 0) || (strcmp(string, STR(terminal)) == 0)));
-
- if (!res && !PyErr_Occurred()) {
- PyErr_Format(parser_error,
- "Illegal terminal: expected \"%s\"", string);
- }
- return (res);
-}
-
-/* X (',' X) [','] */
-static int
-validate_repeating_list_variable(node *tree,
- int list_node_type,
- int (*validate_child_func_inc)(node *, int *),
- int *pos,
- const char *const list_node_type_name)
-{
- int nch = NCH(tree);
- int res = (nch && validate_ntype(tree, list_node_type));
-
- if (!res && !PyErr_Occurred()) {
- /* Unconditionally raise. */
- (void) validate_numnodes(tree, 1, list_node_type_name);
- }
- else {
- for ( ; res && *pos < nch; ) {
- res = validate_child_func_inc(tree, pos);
- if (!res || *pos >= nch)
- break;
- res = validate_comma(CHILD(tree, (*pos)++));
- }
- }
- return res;
-}
-
-/* X (',' X) [','] */
-static int
-validate_repeating_list(node *tree,
- int list_node_type,
- int (*validate_child_func)(node *),
- const char *const list_node_type_name)
-{
- int nch = NCH(tree);
- int res = (nch && validate_ntype(tree, list_node_type));
- int pos = 0;
-
- if (!res && !PyErr_Occurred()) {
- /* Unconditionally raise. */
- (void) validate_numnodes(tree, 1, list_node_type_name);
- }
- else {
- for ( ; res && pos < nch; ) {
- res = validate_child_func(CHILD(tree, pos++));
- if (!res || pos >= nch)
- break;
- res = validate_comma(CHILD(tree, pos++));
- }
- }
- return res;
-}
-
-
-/* validate_class()
- *
- * classdef:
- * 'class' NAME ['(' testlist ')'] ':' suite
- */
-static int
-validate_class(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, classdef) &&
- ((nch == 4) || (nch == 6) || (nch == 7)));
-
- if (res) {
- res = (validate_name(CHILD(tree, 0), "class")
- && validate_ntype(CHILD(tree, 1), NAME)
- && validate_colon(CHILD(tree, nch - 2))
- && validate_suite(CHILD(tree, nch - 1)));
- }
- else {
- (void) validate_numnodes(tree, 4, "class");
- }
-
- if (res) {
- if (nch == 7) {
- res = ((validate_lparen(CHILD(tree, 2)) &&
- validate_arglist(CHILD(tree, 3)) &&
- validate_rparen(CHILD(tree, 4))));
- }
- else if (nch == 6) {
- res = (validate_lparen(CHILD(tree,2)) &&
- validate_rparen(CHILD(tree,3)));
- }
- }
- return (res);
-}
-
-
-/* if_stmt:
- * 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
- */
-static int
-validate_if(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, if_stmt)
- && (nch >= 4)
- && validate_name(CHILD(tree, 0), "if")
- && validate_test(CHILD(tree, 1))
- && validate_colon(CHILD(tree, 2))
- && validate_suite(CHILD(tree, 3)));
-
- if (res && ((nch % 4) == 3)) {
- /* ... 'else' ':' suite */
- res = (validate_name(CHILD(tree, nch - 3), "else")
- && validate_colon(CHILD(tree, nch - 2))
- && validate_suite(CHILD(tree, nch - 1)));
- nch -= 3;
- }
- else if (!res && !PyErr_Occurred())
- (void) validate_numnodes(tree, 4, "if");
- if ((nch % 4) != 0)
- /* Will catch the case for nch < 4 */
- res = validate_numnodes(tree, 0, "if");
- else if (res && (nch > 4)) {
- /* ... ('elif' test ':' suite)+ ... */
- int j = 4;
- while ((j < nch) && res) {
- res = (validate_name(CHILD(tree, j), "elif")
- && validate_colon(CHILD(tree, j + 2))
- && validate_test(CHILD(tree, j + 1))
- && validate_suite(CHILD(tree, j + 3)));
- j += 4;
- }
- }
- return (res);
-}
-
-
-/* parameters:
- * '(' [varargslist] ')'
- *
- */
-static int
-validate_parameters(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, parameters) && ((nch == 2) || (nch == 3));
-
- if (res) {
- res = (validate_lparen(CHILD(tree, 0))
- && validate_rparen(CHILD(tree, nch - 1)));
- if (res && (nch == 3))
- res = validate_varargslist(CHILD(tree, 1));
- }
- else {
- (void) validate_numnodes(tree, 2, "parameters");
- }
- return (res);
-}
-
-
-/* validate_suite()
- *
- * suite:
- * simple_stmt
- * | NEWLINE INDENT stmt+ DEDENT
- */
-static int
-validate_suite(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, suite) && ((nch == 1) || (nch >= 4)));
-
- if (res && (nch == 1))
- res = validate_simple_stmt(CHILD(tree, 0));
- else if (res) {
- /* NEWLINE INDENT stmt+ DEDENT */
- res = (validate_newline(CHILD(tree, 0))
- && validate_indent(CHILD(tree, 1))
- && validate_stmt(CHILD(tree, 2))
- && validate_dedent(CHILD(tree, nch - 1)));
-
- if (res && (nch > 4)) {
- int i = 3;
- --nch; /* forget the DEDENT */
- for ( ; res && (i < nch); ++i)
- res = validate_stmt(CHILD(tree, i));
- }
- else if (nch < 4)
- res = validate_numnodes(tree, 4, "suite");
- }
- return (res);
-}
-
-
-static int
-validate_testlist(node *tree)
-{
- return (validate_repeating_list(tree, testlist,
- validate_test, "testlist"));
-}
-
-static int
-validate_testlist_star_expr(node *tl)
-{
- return (validate_repeating_list(tl, testlist_star_expr, validate_test_or_star_expr,
- "testlist"));
-}
-
-
-/* validate either vfpdef or tfpdef.
- * vfpdef: NAME
- * tfpdef: NAME [':' test]
- */
-static int
-validate_vfpdef(node *tree)
-{
- int nch = NCH(tree);
- if (TYPE(tree) == vfpdef) {
- return nch == 1 && validate_name(CHILD(tree, 0), NULL);
- }
- else if (TYPE(tree) == tfpdef) {
- if (nch == 1) {
- return validate_name(CHILD(tree, 0), NULL);
- }
- else if (nch == 3) {
- return validate_name(CHILD(tree, 0), NULL) &&
- validate_colon(CHILD(tree, 1)) &&
- validate_test(CHILD(tree, 2));
- }
- }
- return 0;
-}
-
-/* '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef
- * ..or tfpdef in place of vfpdef. vfpdef: NAME; tfpdef: NAME [':' test]
- */
-static int
-validate_varargslist_trailer(node *tree, int start)
-{
- int nch = NCH(tree);
- int res = 0;
-
- if (nch <= start) {
- err_string("expected variable argument trailer for varargslist");
- return 0;
- }
- if (TYPE(CHILD(tree, start)) == STAR) {
- /*
- * '*' [vfpdef]
- */
- res = validate_star(CHILD(tree, start++));
- if (res && start < nch && (TYPE(CHILD(tree, start)) == vfpdef ||
- TYPE(CHILD(tree, start)) == tfpdef))
- res = validate_vfpdef(CHILD(tree, start++));
- /*
- * (',' vfpdef ['=' test])*
- */
- while (res && start + 1 < nch && (
- TYPE(CHILD(tree, start + 1)) == vfpdef ||
- TYPE(CHILD(tree, start + 1)) == tfpdef)) {
- res = (validate_comma(CHILD(tree, start++))
- && validate_vfpdef(CHILD(tree, start++)));
- if (res && start + 1 < nch && TYPE(CHILD(tree, start)) == EQUAL)
- res = (validate_equal(CHILD(tree, start++))
- && validate_test(CHILD(tree, start++)));
- }
- /*
- * [',' '**' vfpdef]
- */
- if (res && start + 2 < nch && TYPE(CHILD(tree, start+1)) == DOUBLESTAR)
- res = (validate_comma(CHILD(tree, start++))
- && validate_doublestar(CHILD(tree, start++))
- && validate_vfpdef(CHILD(tree, start++)));
- }
- else if (TYPE(CHILD(tree, start)) == DOUBLESTAR) {
- /*
- * '**' vfpdef
- */
- if (start + 1 < nch)
- res = (validate_doublestar(CHILD(tree, start++))
- && validate_vfpdef(CHILD(tree, start++)));
- else {
- res = 0;
- err_string("expected vfpdef after ** in varargslist trailer");
- }
- }
- else {
- res = 0;
- err_string("expected * or ** in varargslist trailer");
- }
-
- if (res && start != nch) {
- res = 0;
- err_string("unexpected extra children in varargslist trailer");
- }
- return res;
-}
-
-
-/* validate_varargslist()
- *
- * Validate typedargslist or varargslist.
- *
- * typedargslist: ((tfpdef ['=' test] ',')*
- * ('*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] |
- * '**' tfpdef)
- * | tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
- * tfpdef: NAME [':' test]
- * varargslist: ((vfpdef ['=' test] ',')*
- * ('*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] |
- * '**' vfpdef)
- * | vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
- * vfpdef: NAME
- *
- */
-static int
-validate_varargslist(node *tree)
-{
- int nch = NCH(tree);
- int res = (TYPE(tree) == varargslist ||
- TYPE(tree) == typedargslist) &&
- (nch != 0);
- int sym;
- node *ch;
- int i = 0;
-
- if (!res)
- return 0;
- if (nch < 1) {
- err_string("varargslist missing child nodes");
- return 0;
- }
- while (i < nch) {
- ch = CHILD(tree, i);
- sym = TYPE(ch);
- if (sym == vfpdef || sym == tfpdef) {
- /* validate (vfpdef ['=' test] ',')+ */
- res = validate_vfpdef(ch);
- ++i;
- if (res && (i+2 <= nch) && TYPE(CHILD(tree, i)) == EQUAL) {
- res = (validate_equal(CHILD(tree, i))
- && validate_test(CHILD(tree, i+1)));
- if (res)
- i += 2;
- }
- if (res && i < nch) {
- res = validate_comma(CHILD(tree, i));
- ++i;
- }
- } else if (sym == DOUBLESTAR || sym == STAR) {
- res = validate_varargslist_trailer(tree, i);
- break;
- } else {
- res = 0;
- err_string("illegal formation for varargslist");
- }
- }
- return res;
-}
-
-
-/* comp_iter: comp_for | comp_if
- */
-static int
-validate_comp_iter(node *tree)
-{
- int res = (validate_ntype(tree, comp_iter)
- && validate_numnodes(tree, 1, "comp_iter"));
- if (res && TYPE(CHILD(tree, 0)) == comp_for)
- res = validate_comp_for(CHILD(tree, 0));
- else
- res = validate_comp_if(CHILD(tree, 0));
-
- return res;
-}
-
-/* comp_for: 'for' exprlist 'in' test [comp_iter]
- */
-static int
-validate_comp_for(node *tree)
-{
- int nch = NCH(tree);
- int res;
-
- if (nch == 5)
- res = validate_comp_iter(CHILD(tree, 4));
- else
- res = validate_numnodes(tree, 4, "comp_for");
-
- if (res)
- res = (validate_name(CHILD(tree, 0), "for")
- && validate_exprlist(CHILD(tree, 1))
- && validate_name(CHILD(tree, 2), "in")
- && validate_or_test(CHILD(tree, 3)));
-
- return res;
-}
-
-/* comp_if: 'if' test_nocond [comp_iter]
- */
-static int
-validate_comp_if(node *tree)
-{
- int nch = NCH(tree);
- int res;
-
- if (nch == 3)
- res = validate_comp_iter(CHILD(tree, 2));
- else
- res = validate_numnodes(tree, 2, "comp_if");
-
- if (res)
- res = (validate_name(CHILD(tree, 0), "if")
- && validate_test_nocond(CHILD(tree, 1)));
-
- return res;
-}
-
-
-/* simple_stmt | compound_stmt
- *
- */
-static int
-validate_stmt(node *tree)
-{
- int res = (validate_ntype(tree, stmt)
- && validate_numnodes(tree, 1, "stmt"));
-
- if (res) {
- tree = CHILD(tree, 0);
-
- if (TYPE(tree) == simple_stmt)
- res = validate_simple_stmt(tree);
- else
- res = validate_compound_stmt(tree);
- }
- return (res);
-}
-
-
-/* small_stmt (';' small_stmt)* [';'] NEWLINE
- *
- */
-static int
-validate_simple_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, simple_stmt)
- && (nch >= 2)
- && validate_small_stmt(CHILD(tree, 0))
- && validate_newline(CHILD(tree, nch - 1)));
-
- if (nch < 2)
- res = validate_numnodes(tree, 2, "simple_stmt");
- --nch; /* forget the NEWLINE */
- if (res && is_even(nch))
- res = validate_semi(CHILD(tree, --nch));
- if (res && (nch > 2)) {
- int i;
-
- for (i = 1; res && (i < nch); i += 2)
- res = (validate_semi(CHILD(tree, i))
- && validate_small_stmt(CHILD(tree, i + 1)));
- }
- return (res);
-}
-
-
-static int
-validate_small_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_numnodes(tree, 1, "small_stmt");
-
- if (res) {
- int ntype = TYPE(CHILD(tree, 0));
-
- if ( (ntype == expr_stmt)
- || (ntype == del_stmt)
- || (ntype == pass_stmt)
- || (ntype == flow_stmt)
- || (ntype == import_stmt)
- || (ntype == global_stmt)
- || (ntype == nonlocal_stmt)
- || (ntype == assert_stmt))
- res = validate_node(CHILD(tree, 0));
- else {
- res = 0;
- err_string("illegal small_stmt child type");
- }
- }
- else if (nch == 1) {
- res = 0;
- PyErr_Format(parser_error,
- "Unrecognized child node of small_stmt: %d.",
- TYPE(CHILD(tree, 0)));
- }
- return (res);
-}
-
-
-/* compound_stmt:
- * if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
- */
-static int
-validate_compound_stmt(node *tree)
-{
- int res = (validate_ntype(tree, compound_stmt)
- && validate_numnodes(tree, 1, "compound_stmt"));
- int ntype;
-
- if (!res)
- return (0);
-
- tree = CHILD(tree, 0);
- ntype = TYPE(tree);
- if ( (ntype == if_stmt)
- || (ntype == while_stmt)
- || (ntype == for_stmt)
- || (ntype == try_stmt)
- || (ntype == with_stmt)
- || (ntype == funcdef)
- || (ntype == async_stmt)
- || (ntype == classdef)
- || (ntype == decorated))
- res = validate_node(tree);
- else {
- res = 0;
- PyErr_Format(parser_error,
- "Illegal compound statement type: %d.", TYPE(tree));
- }
- return (res);
-}
-
-static int
-validate_yield_or_testlist(node *tree, int tse)
-{
- if (TYPE(tree) == yield_expr) {
- return validate_yield_expr(tree);
- }
- else {
- if (tse)
- return validate_testlist_star_expr(tree);
- else
- return validate_testlist(tree);
- }
-}
-
-static int
-validate_expr_stmt(node *tree)
-{
- int j;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, expr_stmt)
- && is_odd(nch)
- && validate_testlist_star_expr(CHILD(tree, 0)));
-
- if (res && nch == 3
- && TYPE(CHILD(tree, 1)) == augassign) {
- res = validate_numnodes(CHILD(tree, 1), 1, "augassign")
- && validate_yield_or_testlist(CHILD(tree, 2), 0);
-
- if (res) {
- char *s = STR(CHILD(CHILD(tree, 1), 0));
-
- res = (strcmp(s, "+=") == 0
- || strcmp(s, "-=") == 0
- || strcmp(s, "*=") == 0
- || strcmp(s, "/=") == 0
- || strcmp(s, "//=") == 0
- || strcmp(s, "%=") == 0
- || strcmp(s, "&=") == 0
- || strcmp(s, "|=") == 0
- || strcmp(s, "^=") == 0
- || strcmp(s, "<<=") == 0
- || strcmp(s, ">>=") == 0
- || strcmp(s, "**=") == 0);
- if (!res)
- err_string("illegal augmented assignment operator");
- }
- }
- else {
- for (j = 1; res && (j < nch); j += 2)
- res = validate_equal(CHILD(tree, j))
- && validate_yield_or_testlist(CHILD(tree, j + 1), 1);
- }
- return (res);
-}
-
-
-static int
-validate_del_stmt(node *tree)
-{
- return (validate_numnodes(tree, 2, "del_stmt")
- && validate_name(CHILD(tree, 0), "del")
- && validate_exprlist(CHILD(tree, 1)));
-}
-
-
-static int
-validate_return_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, return_stmt)
- && ((nch == 1) || (nch == 2))
- && validate_name(CHILD(tree, 0), "return"));
-
- if (res && (nch == 2))
- res = validate_testlist(CHILD(tree, 1));
-
- return (res);
-}
-
-
-/*
- * raise_stmt:
- *
- * 'raise' [test ['from' test]]
- */
-static int
-validate_raise_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, raise_stmt)
- && ((nch == 1) || (nch == 2) || (nch == 4)));
-
- if (!res && !PyErr_Occurred())
- (void) validate_numnodes(tree, 2, "raise");
-
- if (res) {
- res = validate_name(CHILD(tree, 0), "raise");
- if (res && (nch >= 2))
- res = validate_test(CHILD(tree, 1));
- if (res && (nch == 4)) {
- res = (validate_name(CHILD(tree, 2), "from")
- && validate_test(CHILD(tree, 3)));
- }
- }
- return (res);
-}
-
-
-/* yield_expr: 'yield' [yield_arg]
- */
-static int
-validate_yield_expr(node *tree)
-{
- int nch = NCH(tree);
- if (nch < 1 || nch > 2)
- return 0;
- if (!validate_ntype(tree, yield_expr))
- return 0;
- if (!validate_name(CHILD(tree, 0), "yield"))
- return 0;
- if (nch == 2) {
- if (!validate_yield_arg(CHILD(tree, 1)))
- return 0;
- }
- return 1;
-}
-
-/* yield_arg: 'from' test | testlist
- */
-static int
-validate_yield_arg(node *tree)
-{
- int nch = NCH(tree);
- if (!validate_ntype(tree, yield_arg))
- return 0;
- switch (nch) {
- case 1:
- if (!validate_testlist(CHILD(tree, nch - 1)))
- return 0;
- break;
- case 2:
- if (!validate_name(CHILD(tree, 0), "from"))
- return 0;
- if (!validate_test(CHILD(tree, 1)))
- return 0;
- break;
- default:
- return 0;
- }
- return 1;
-}
-
-/* yield_stmt: yield_expr
- */
-static int
-validate_yield_stmt(node *tree)
-{
- return (validate_ntype(tree, yield_stmt)
- && validate_numnodes(tree, 1, "yield_stmt")
- && validate_yield_expr(CHILD(tree, 0)));
-}
-
-
-static int
-validate_import_as_name(node *tree)
-{
- int nch = NCH(tree);
- int ok = validate_ntype(tree, import_as_name);
-
- if (ok) {
- if (nch == 1)
- ok = validate_name(CHILD(tree, 0), NULL);
- else if (nch == 3)
- ok = (validate_name(CHILD(tree, 0), NULL)
- && validate_name(CHILD(tree, 1), "as")
- && validate_name(CHILD(tree, 2), NULL));
- else
- ok = validate_numnodes(tree, 3, "import_as_name");
- }
- return ok;
-}
-
-
-/* dotted_name: NAME ("." NAME)*
- */
-static int
-validate_dotted_name(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, dotted_name)
- && is_odd(nch)
- && validate_name(CHILD(tree, 0), NULL));
- int i;
-
- for (i = 1; res && (i < nch); i += 2) {
- res = (validate_dot(CHILD(tree, i))
- && validate_name(CHILD(tree, i+1), NULL));
- }
- return res;
-}
-
-
-/* dotted_as_name: dotted_name [NAME NAME]
- */
-static int
-validate_dotted_as_name(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, dotted_as_name);
-
- if (res) {
- if (nch == 1)
- res = validate_dotted_name(CHILD(tree, 0));
- else if (nch == 3)
- res = (validate_dotted_name(CHILD(tree, 0))
- && validate_name(CHILD(tree, 1), "as")
- && validate_name(CHILD(tree, 2), NULL));
- else {
- res = 0;
- err_string("illegal number of children for dotted_as_name");
- }
- }
- return res;
-}
-
-
-/* dotted_as_name (',' dotted_as_name)* */
-static int
-validate_dotted_as_names(node *tree)
-{
- int nch = NCH(tree);
- int res = is_odd(nch) && validate_dotted_as_name(CHILD(tree, 0));
- int i;
-
- for (i = 1; res && (i < nch); i += 2)
- res = (validate_comma(CHILD(tree, i))
- && validate_dotted_as_name(CHILD(tree, i + 1)));
- return (res);
-}
-
-
-/* import_as_name (',' import_as_name)* [','] */
-static int
-validate_import_as_names(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_import_as_name(CHILD(tree, 0));
- int i;
-
- for (i = 1; res && (i + 1 < nch); i += 2)
- res = (validate_comma(CHILD(tree, i))
- && validate_import_as_name(CHILD(tree, i + 1)));
- return (res);
-}
-
-
-/* 'import' dotted_as_names */
-static int
-validate_import_name(node *tree)
-{
- return (validate_ntype(tree, import_name)
- && validate_numnodes(tree, 2, "import_name")
- && validate_name(CHILD(tree, 0), "import")
- && validate_dotted_as_names(CHILD(tree, 1)));
-}
-
-/* Helper function to count the number of leading dots (or ellipsis tokens) in
- * 'from ...module import name'
- */
-static int
-count_from_dots(node *tree)
-{
- int i;
- for (i = 1; i < NCH(tree); i++)
- if (TYPE(CHILD(tree, i)) != DOT && TYPE(CHILD(tree, i)) != ELLIPSIS)
- break;
- return i - 1;
-}
-
-/* import_from: ('from' ('.'* dotted_name | '.'+)
- * 'import' ('*' | '(' import_as_names ')' | import_as_names))
- */
-static int
-validate_import_from(node *tree)
-{
- int nch = NCH(tree);
- int ndots = count_from_dots(tree);
- int havename = (TYPE(CHILD(tree, ndots + 1)) == dotted_name);
- int offset = ndots + havename;
- int res = validate_ntype(tree, import_from)
- && (offset >= 1)
- && (nch >= 3 + offset)
- && validate_name(CHILD(tree, 0), "from")
- && (!havename || validate_dotted_name(CHILD(tree, ndots + 1)))
- && validate_name(CHILD(tree, offset + 1), "import");
-
- if (res && TYPE(CHILD(tree, offset + 2)) == LPAR)
- res = ((nch == offset + 5)
- && validate_lparen(CHILD(tree, offset + 2))
- && validate_import_as_names(CHILD(tree, offset + 3))
- && validate_rparen(CHILD(tree, offset + 4)));
- else if (res && TYPE(CHILD(tree, offset + 2)) != STAR)
- res = validate_import_as_names(CHILD(tree, offset + 2));
- return (res);
-}
-
-
-/* import_stmt: import_name | import_from */
-static int
-validate_import_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_numnodes(tree, 1, "import_stmt");
-
- if (res) {
- int ntype = TYPE(CHILD(tree, 0));
-
- if (ntype == import_name || ntype == import_from)
- res = validate_node(CHILD(tree, 0));
- else {
- res = 0;
- err_string("illegal import_stmt child type");
- }
- }
- else if (nch == 1) {
- res = 0;
- PyErr_Format(parser_error,
- "Unrecognized child node of import_stmt: %d.",
- TYPE(CHILD(tree, 0)));
- }
- return (res);
-}
-
-
-/* global_stmt:
- *
- * 'global' NAME (',' NAME)*
- */
-static int
-validate_global_stmt(node *tree)
-{
- int j;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, global_stmt)
- && is_even(nch) && (nch >= 2));
-
- if (!res && !PyErr_Occurred())
- err_string("illegal global statement");
-
- if (res)
- res = (validate_name(CHILD(tree, 0), "global")
- && validate_ntype(CHILD(tree, 1), NAME));
- for (j = 2; res && (j < nch); j += 2)
- res = (validate_comma(CHILD(tree, j))
- && validate_ntype(CHILD(tree, j + 1), NAME));
-
- return (res);
-}
-
-/* nonlocal_stmt:
- *
- * 'nonlocal' NAME (',' NAME)*
- */
-static int
-validate_nonlocal_stmt(node *tree)
-{
- int j;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, nonlocal_stmt)
- && is_even(nch) && (nch >= 2));
-
- if (!res && !PyErr_Occurred())
- err_string("illegal nonlocal statement");
-
- if (res)
- res = (validate_name(CHILD(tree, 0), "nonlocal")
- && validate_ntype(CHILD(tree, 1), NAME));
- for (j = 2; res && (j < nch); j += 2)
- res = (validate_comma(CHILD(tree, j))
- && validate_ntype(CHILD(tree, j + 1), NAME));
-
- return res;
-}
-
-/* assert_stmt:
- *
- * 'assert' test [',' test]
- */
-static int
-validate_assert_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, assert_stmt)
- && ((nch == 2) || (nch == 4))
- && (validate_name(CHILD(tree, 0), "assert"))
- && validate_test(CHILD(tree, 1)));
-
- if (!res && !PyErr_Occurred())
- err_string("illegal assert statement");
- if (res && (nch > 2))
- res = (validate_comma(CHILD(tree, 2))
- && validate_test(CHILD(tree, 3)));
-
- return (res);
-}
-
-
-static int
-validate_while(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, while_stmt)
- && ((nch == 4) || (nch == 7))
- && validate_name(CHILD(tree, 0), "while")
- && validate_test(CHILD(tree, 1))
- && validate_colon(CHILD(tree, 2))
- && validate_suite(CHILD(tree, 3)));
-
- if (res && (nch == 7))
- res = (validate_name(CHILD(tree, 4), "else")
- && validate_colon(CHILD(tree, 5))
- && validate_suite(CHILD(tree, 6)));
-
- return (res);
-}
-
-
-static int
-validate_for(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, for_stmt)
- && ((nch == 6) || (nch == 9))
- && validate_name(CHILD(tree, 0), "for")
- && validate_exprlist(CHILD(tree, 1))
- && validate_name(CHILD(tree, 2), "in")
- && validate_testlist(CHILD(tree, 3))
- && validate_colon(CHILD(tree, 4))
- && validate_suite(CHILD(tree, 5)));
-
- if (res && (nch == 9))
- res = (validate_name(CHILD(tree, 6), "else")
- && validate_colon(CHILD(tree, 7))
- && validate_suite(CHILD(tree, 8)));
-
- return (res);
-}
-
-
-/* try_stmt:
- * 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite]
- ['finally' ':' suite]
- * | 'try' ':' suite 'finally' ':' suite
- *
- */
-static int
-validate_try(node *tree)
-{
- int nch = NCH(tree);
- int pos = 3;
- int res = (validate_ntype(tree, try_stmt)
- && (nch >= 6) && ((nch % 3) == 0));
-
- if (res)
- res = (validate_name(CHILD(tree, 0), "try")
- && validate_colon(CHILD(tree, 1))
- && validate_suite(CHILD(tree, 2))
- && validate_colon(CHILD(tree, nch - 2))
- && validate_suite(CHILD(tree, nch - 1)));
- else if (!PyErr_Occurred()) {
- const char* name = "except";
- if (TYPE(CHILD(tree, nch - 3)) != except_clause)
- name = STR(CHILD(tree, nch - 3));
-
- PyErr_Format(parser_error,
- "Illegal number of children for try/%s node.", name);
- }
- /* Handle try/finally statement */
- if (res && (TYPE(CHILD(tree, pos)) == NAME) &&
- (strcmp(STR(CHILD(tree, pos)), "finally") == 0)) {
- res = (validate_numnodes(tree, 6, "try/finally")
- && validate_colon(CHILD(tree, 4))
- && validate_suite(CHILD(tree, 5)));
- return (res);
- }
- /* try/except statement: skip past except_clause sections */
- while (res && pos < nch && (TYPE(CHILD(tree, pos)) == except_clause)) {
- res = (validate_except_clause(CHILD(tree, pos))
- && validate_colon(CHILD(tree, pos + 1))
- && validate_suite(CHILD(tree, pos + 2)));
- pos += 3;
- }
- /* skip else clause */
- if (res && pos < nch && (TYPE(CHILD(tree, pos)) == NAME) &&
- (strcmp(STR(CHILD(tree, pos)), "else") == 0)) {
- res = (validate_colon(CHILD(tree, pos + 1))
- && validate_suite(CHILD(tree, pos + 2)));
- pos += 3;
- }
- if (res && pos < nch) {
- /* last clause must be a finally */
- res = (validate_name(CHILD(tree, pos), "finally")
- && validate_numnodes(tree, pos + 3, "try/except/finally")
- && validate_colon(CHILD(tree, pos + 1))
- && validate_suite(CHILD(tree, pos + 2)));
- }
- return (res);
-}
-
-
-static int
-validate_except_clause(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, except_clause)
- && ((nch == 1) || (nch == 2) || (nch == 4))
- && validate_name(CHILD(tree, 0), "except"));
-
- if (res && (nch > 1))
- res = validate_test(CHILD(tree, 1));
- if (res && (nch == 4))
- res = (validate_name(CHILD(tree, 2), "as")
- && validate_ntype(CHILD(tree, 3), NAME));
-
- return (res);
-}
-
-
-static int
-validate_test(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, test) && is_odd(nch);
-
- if (res && (TYPE(CHILD(tree, 0)) == lambdef))
- res = ((nch == 1)
- && validate_lambdef(CHILD(tree, 0)));
- else if (res) {
- res = validate_or_test(CHILD(tree, 0));
- res = (res && (nch == 1 || (nch == 5 &&
- validate_name(CHILD(tree, 1), "if") &&
- validate_or_test(CHILD(tree, 2)) &&
- validate_name(CHILD(tree, 3), "else") &&
- validate_test(CHILD(tree, 4)))));
- }
- return (res);
-}
-
-static int
-validate_test_nocond(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, test_nocond) && (nch == 1);
-
- if (res && (TYPE(CHILD(tree, 0)) == lambdef_nocond))
- res = (validate_lambdef_nocond(CHILD(tree, 0)));
- else if (res) {
- res = (validate_or_test(CHILD(tree, 0)));
- }
- return (res);
-}
-
-static int
-validate_or_test(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, or_test) && is_odd(nch);
-
- if (res) {
- int pos;
- res = validate_and_test(CHILD(tree, 0));
- for (pos = 1; res && (pos < nch); pos += 2)
- res = (validate_name(CHILD(tree, pos), "or")
- && validate_and_test(CHILD(tree, pos + 1)));
- }
- return (res);
-}
-
-
-static int
-validate_and_test(node *tree)
-{
- int pos;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, and_test)
- && is_odd(nch)
- && validate_not_test(CHILD(tree, 0)));
-
- for (pos = 1; res && (pos < nch); pos += 2)
- res = (validate_name(CHILD(tree, pos), "and")
- && validate_not_test(CHILD(tree, 0)));
-
- return (res);
-}
-
-
-static int
-validate_not_test(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, not_test) && ((nch == 1) || (nch == 2));
-
- if (res) {
- if (nch == 2)
- res = (validate_name(CHILD(tree, 0), "not")
- && validate_not_test(CHILD(tree, 1)));
- else if (nch == 1)
- res = validate_comparison(CHILD(tree, 0));
- }
- return (res);
-}
-
-
-static int
-validate_comparison(node *tree)
-{
- int pos;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, comparison)
- && is_odd(nch)
- && validate_expr(CHILD(tree, 0)));
-
- for (pos = 1; res && (pos < nch); pos += 2)
- res = (validate_comp_op(CHILD(tree, pos))
- && validate_expr(CHILD(tree, pos + 1)));
-
- return (res);
-}
-
-
-static int
-validate_comp_op(node *tree)
-{
- int res = 0;
- int nch = NCH(tree);
-
- if (!validate_ntype(tree, comp_op))
- return (0);
- if (nch == 1) {
- /*
- * Only child will be a terminal with a well-defined symbolic name
- * or a NAME with a string of either 'is' or 'in'
- */
- tree = CHILD(tree, 0);
- switch (TYPE(tree)) {
- case LESS:
- case GREATER:
- case EQEQUAL:
- case EQUAL:
- case LESSEQUAL:
- case GREATEREQUAL:
- case NOTEQUAL:
- res = 1;
- break;
- case NAME:
- res = ((strcmp(STR(tree), "in") == 0)
- || (strcmp(STR(tree), "is") == 0));
- if (!res) {
- PyErr_Format(parser_error,
- "illegal operator '%s'", STR(tree));
- }
- break;
- default:
- err_string("illegal comparison operator type");
- break;
- }
- }
- else if ((res = validate_numnodes(tree, 2, "comp_op")) != 0) {
- res = (validate_ntype(CHILD(tree, 0), NAME)
- && validate_ntype(CHILD(tree, 1), NAME)
- && (((strcmp(STR(CHILD(tree, 0)), "is") == 0)
- && (strcmp(STR(CHILD(tree, 1)), "not") == 0))
- || ((strcmp(STR(CHILD(tree, 0)), "not") == 0)
- && (strcmp(STR(CHILD(tree, 1)), "in") == 0))));
- if (!res && !PyErr_Occurred())
- err_string("unknown comparison operator");
- }
- return (res);
-}
-
-
-static int
-validate_star_expr(node *tree)
-{
- int res = validate_ntype(tree, star_expr);
- if (!res) return res;
- if (!validate_numnodes(tree, 2, "star_expr"))
- return 0;
- return validate_ntype(CHILD(tree, 0), STAR) && \
- validate_expr(CHILD(tree, 1));
-}
-
-
-static int
-validate_expr(node *tree)
-{
- int j;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, expr)
- && is_odd(nch)
- && validate_xor_expr(CHILD(tree, 0)));
-
- for (j = 2; res && (j < nch); j += 2)
- res = (validate_xor_expr(CHILD(tree, j))
- && validate_vbar(CHILD(tree, j - 1)));
-
- return (res);
-}
-
-
-static int
-validate_xor_expr(node *tree)
-{
- int j;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, xor_expr)
- && is_odd(nch)
- && validate_and_expr(CHILD(tree, 0)));
-
- for (j = 2; res && (j < nch); j += 2)
- res = (validate_circumflex(CHILD(tree, j - 1))
- && validate_and_expr(CHILD(tree, j)));
-
- return (res);
-}
-
-
-static int
-validate_and_expr(node *tree)
-{
- int pos;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, and_expr)
- && is_odd(nch)
- && validate_shift_expr(CHILD(tree, 0)));
-
- for (pos = 1; res && (pos < nch); pos += 2)
- res = (validate_ampersand(CHILD(tree, pos))
- && validate_shift_expr(CHILD(tree, pos + 1)));
-
- return (res);
-}
-
-
-static int
-validate_chain_two_ops(node *tree, int (*termvalid)(node *), int op1, int op2)
- {
- int pos = 1;
- int nch = NCH(tree);
- int res = (is_odd(nch)
- && (*termvalid)(CHILD(tree, 0)));
-
- for ( ; res && (pos < nch); pos += 2) {
- if (TYPE(CHILD(tree, pos)) != op1)
- res = validate_ntype(CHILD(tree, pos), op2);
- if (res)
- res = (*termvalid)(CHILD(tree, pos + 1));
- }
- return (res);
-}
-
-
-static int
-validate_shift_expr(node *tree)
-{
- return (validate_ntype(tree, shift_expr)
- && validate_chain_two_ops(tree, validate_arith_expr,
- LEFTSHIFT, RIGHTSHIFT));
-}
-
-
-static int
-validate_arith_expr(node *tree)
-{
- return (validate_ntype(tree, arith_expr)
- && validate_chain_two_ops(tree, validate_term, PLUS, MINUS));
-}
-
-
-static int
-validate_term(node *tree)
-{
- int pos = 1;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, term)
- && is_odd(nch)
- && validate_factor(CHILD(tree, 0)));
-
- for ( ; res && (pos < nch); pos += 2)
- res = (((TYPE(CHILD(tree, pos)) == STAR)
- || (TYPE(CHILD(tree, pos)) == SLASH)
- || (TYPE(CHILD(tree, pos)) == DOUBLESLASH)
- || (TYPE(CHILD(tree, pos)) == PERCENT))
- && validate_factor(CHILD(tree, pos + 1)));
-
- return (res);
-}
-
-
-/* factor:
- *
- * factor: ('+'|'-'|'~') factor | power
- */
-static int
-validate_factor(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, factor)
- && (((nch == 2)
- && ((TYPE(CHILD(tree, 0)) == PLUS)
- || (TYPE(CHILD(tree, 0)) == MINUS)
- || (TYPE(CHILD(tree, 0)) == TILDE))
- && validate_factor(CHILD(tree, 1)))
- || ((nch == 1)
- && validate_power(CHILD(tree, 0)))));
- return (res);
-}
-
-
-/* power:
- *
- * power: atom_expr trailer* ['**' factor]
- */
-static int
-validate_power(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, power) && (nch >= 1)
- && validate_atom_expr(CHILD(tree, 0)));
-
- if (nch > 1) {
- if (nch != 3) {
- err_string("illegal number of nodes for 'power'");
- return (0);
- }
- res = (validate_doublestar(CHILD(tree, 1))
- && validate_factor(CHILD(tree, 2)));
- }
-
- return (res);
-}
-
-
-/* atom_expr:
- *
- * atom_expr: [AWAIT] atom trailer*
- */
-static int
-validate_atom_expr(node *tree)
-{
- int start = 0;
- int nch = NCH(tree);
- int res;
- int pos;
-
- res = validate_ntype(tree, atom_expr) && (nch >= 1);
- if (!res) {
- return (res);
- }
-
- if (TYPE(CHILD(tree, 0)) == AWAIT) {
- start = 1;
- if (nch < 2) {
- err_string("illegal number of nodes for 'atom_expr'");
- return (0);
- }
- }
-
- res = validate_atom(CHILD(tree, start));
- if (res) {
- pos = start + 1;
- while (res && (pos < nch) && (TYPE(CHILD(tree, pos)) == trailer))
- res = validate_trailer(CHILD(tree, pos++));
- }
-
- return (res);
-}
-
-
-static int
-validate_atom(node *tree)
-{
- int pos;
- int nch = NCH(tree);
- int res = validate_ntype(tree, atom);
-
- if (res && nch < 1)
- res = validate_numnodes(tree, nch+1, "atom");
- if (res) {
- switch (TYPE(CHILD(tree, 0))) {
- case LPAR:
- res = ((nch <= 3)
- && (validate_rparen(CHILD(tree, nch - 1))));
-
- if (res && (nch == 3)) {
- if (TYPE(CHILD(tree, 1))==yield_expr)
- res = validate_yield_expr(CHILD(tree, 1));
- else
- res = validate_testlist_comp(CHILD(tree, 1));
- }
- break;
- case LSQB:
- if (nch == 2)
- res = validate_ntype(CHILD(tree, 1), RSQB);
- else if (nch == 3)
- res = (validate_testlist_comp(CHILD(tree, 1))
- && validate_ntype(CHILD(tree, 2), RSQB));
- else {
- res = 0;
- err_string("illegal list display atom");
- }
- break;
- case LBRACE:
- res = ((nch <= 3)
- && validate_ntype(CHILD(tree, nch - 1), RBRACE));
-
- if (res && (nch == 3))
- res = validate_dictorsetmaker(CHILD(tree, 1));
- break;
- case NAME:
- case NUMBER:
- case ELLIPSIS:
- res = (nch == 1);
- break;
- case STRING:
- for (pos = 1; res && (pos < nch); ++pos)
- res = validate_ntype(CHILD(tree, pos), STRING);
- break;
- default:
- res = 0;
- break;
- }
- }
- return (res);
-}
-
-
-/* testlist_comp:
- * (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
- */
-static int
-validate_testlist_comp(node *tree)
-{
- int nch = NCH(tree);
- int ok;
-
- if (nch == 0) {
- err_string("missing child nodes of testlist_comp");
- return 0;
- }
-
- if (nch == 2 && TYPE(CHILD(tree, 1)) == comp_for) {
- ok = (validate_test(CHILD(tree, 0))
- && validate_comp_for(CHILD(tree, 1)));
- }
- else {
- ok = validate_repeating_list(tree,
- testlist_comp,
- validate_test_or_star_expr,
- "testlist_comp");
- }
- return ok;
-}
-
-/* decorator:
- * '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
- */
-static int
-validate_decorator(node *tree)
-{
- int ok;
- int nch = NCH(tree);
- ok = (validate_ntype(tree, decorator) &&
- (nch == 3 || nch == 5 || nch == 6) &&
- validate_at(CHILD(tree, 0)) &&
- validate_dotted_name(CHILD(tree, 1)) &&
- validate_newline(RCHILD(tree, -1)));
-
- if (ok && nch != 3) {
- ok = (validate_lparen(CHILD(tree, 2)) &&
- validate_rparen(RCHILD(tree, -2)));
-
- if (ok && nch == 6)
- ok = validate_arglist(CHILD(tree, 3));
- }
-
- return ok;
-}
-
-/* decorators:
- * decorator+
- */
-static int
-validate_decorators(node *tree)
-{
- int i, nch, ok;
- nch = NCH(tree);
- ok = validate_ntype(tree, decorators) && nch >= 1;
-
- for (i = 0; ok && i < nch; ++i)
- ok = validate_decorator(CHILD(tree, i));
-
- return ok;
-}
-
-/* with_item:
- * test ['as' expr]
- */
-static int
-validate_with_item(node *tree)
-{
- int nch = NCH(tree);
- int ok = (validate_ntype(tree, with_item)
- && (nch == 1 || nch == 3)
- && validate_test(CHILD(tree, 0)));
- if (ok && nch == 3)
- ok = (validate_name(CHILD(tree, 1), "as")
- && validate_expr(CHILD(tree, 2)));
- return ok;
-}
-
-/* with_stmt:
- * 0 1 ... -2 -1
- * 'with' with_item (',' with_item)* ':' suite
- */
-static int
-validate_with_stmt(node *tree)
-{
- int i;
- int nch = NCH(tree);
- int ok = (validate_ntype(tree, with_stmt)
- && (nch % 2 == 0)
- && validate_name(CHILD(tree, 0), "with")
- && validate_colon(RCHILD(tree, -2))
- && validate_suite(RCHILD(tree, -1)));
- for (i = 1; ok && i < nch - 2; i += 2)
- ok = validate_with_item(CHILD(tree, i));
- return ok;
-}
-
-/* funcdef: 'def' NAME parameters ['->' test] ':' suite */
-
-static int
-validate_funcdef(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, funcdef);
- if (res) {
- if (nch == 5) {
- res = (validate_name(CHILD(tree, 0), "def")
- && validate_ntype(CHILD(tree, 1), NAME)
- && validate_parameters(CHILD(tree, 2))
- && validate_colon(CHILD(tree, 3))
- && validate_suite(CHILD(tree, 4)));
- }
- else if (nch == 7) {
- res = (validate_name(CHILD(tree, 0), "def")
- && validate_ntype(CHILD(tree, 1), NAME)
- && validate_parameters(CHILD(tree, 2))
- && validate_rarrow(CHILD(tree, 3))
- && validate_test(CHILD(tree, 4))
- && validate_colon(CHILD(tree, 5))
- && validate_suite(CHILD(tree, 6)));
- }
- else {
- res = 0;
- err_string("illegal number of children for funcdef");
- }
- }
- return res;
-}
-
-/* async_funcdef: ASYNC funcdef */
-
-static int
-validate_async_funcdef(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, async_funcdef);
- if (res) {
- if (nch == 2) {
- res = (validate_ntype(CHILD(tree, 0), ASYNC)
- && validate_funcdef(CHILD(tree, 1)));
- }
- else {
- res = 0;
- err_string("illegal number of children for async_funcdef");
- }
- }
- return res;
-}
-
-
-/* async_stmt: ASYNC (funcdef | with_stmt | for_stmt) */
-
-static int
-validate_async_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, async_stmt)
- && validate_ntype(CHILD(tree, 0), ASYNC));
-
- if (nch != 2) {
- res = 0;
- err_string("illegal number of children for async_stmt");
- } else {
- if (TYPE(CHILD(tree, 1)) == funcdef) {
- res = validate_funcdef(CHILD(tree, 1));
- }
- else if (TYPE(CHILD(tree, 1)) == with_stmt) {
- res = validate_with_stmt(CHILD(tree, 1));
- }
- else if (TYPE(CHILD(tree, 1)) == for_stmt) {
- res = validate_for(CHILD(tree, 1));
- }
- }
-
- return res;
-}
-
-
-
-/* decorated
- * decorators (classdef | funcdef)
- */
-static int
-validate_decorated(node *tree)
-{
- int nch = NCH(tree);
- int ok = (validate_ntype(tree, decorated)
- && (nch == 2)
- && validate_decorators(RCHILD(tree, -2)));
- if (TYPE(RCHILD(tree, -1)) == funcdef)
- ok = ok && validate_funcdef(RCHILD(tree, -1));
- else
- ok = ok && validate_class(RCHILD(tree, -1));
- return ok;
-}
-
-static int
-validate_lambdef(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, lambdef)
- && ((nch == 3) || (nch == 4))
- && validate_name(CHILD(tree, 0), "lambda")
- && validate_colon(CHILD(tree, nch - 2))
- && validate_test(CHILD(tree, nch - 1)));
-
- if (res && (nch == 4))
- res = validate_varargslist(CHILD(tree, 1));
- else if (!res && !PyErr_Occurred())
- (void) validate_numnodes(tree, 3, "lambdef");
-
- return (res);
-}
-
-
-static int
-validate_lambdef_nocond(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, lambdef_nocond)
- && ((nch == 3) || (nch == 4))
- && validate_name(CHILD(tree, 0), "lambda")
- && validate_colon(CHILD(tree, nch - 2))
- && validate_test(CHILD(tree, nch - 1)));
-
- if (res && (nch == 4))
- res = validate_varargslist(CHILD(tree, 1));
- else if (!res && !PyErr_Occurred())
- (void) validate_numnodes(tree, 3, "lambdef_nocond");
-
- return (res);
-}
-
-
-/* arglist:
- *
- * (argument ',')* (argument [','] | '*' test [',' '**' test] | '**' test)
- */
-static int
-validate_arglist(node *tree)
-{
- int nch = NCH(tree);
- int i = 0;
- int ok = 1;
-
- if (nch <= 0)
- /* raise the right error from having an invalid number of children */
- return validate_numnodes(tree, nch + 1, "arglist");
-
- if (nch > 1) {
- for (i=0; i<nch; i++) {
- if (TYPE(CHILD(tree, i)) == argument) {
- node *ch = CHILD(tree, i);
- if (NCH(ch) == 2 && TYPE(CHILD(ch, 1)) == comp_for) {
- err_string("need '(', ')' for generator expression");
- return 0;
- }
- }
- }
- }
-
- while (ok && nch-i >= 2) {
- /* skip leading (argument ',') */
- ok = (validate_argument(CHILD(tree, i))
- && validate_comma(CHILD(tree, i+1)));
- if (ok)
- i += 2;
- else
- PyErr_Clear();
- }
- ok = 1;
- if (nch-i > 0) {
- int sym = TYPE(CHILD(tree, i));
-
- if (sym == argument) {
- ok = validate_argument(CHILD(tree, i));
- if (ok && i+1 != nch) {
- err_string("illegal arglist specification"
- " (extra stuff on end)");
- ok = 0;
- }
- }
- else {
- err_string("illegal arglist specification");
- ok = 0;
- }
- }
- return (ok);
-}
-
-
-
-/* argument: ( test [comp_for] |
- * test '=' test |
- * '**' test |
- * '*' test )
- */
-static int
-validate_argument(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, argument)
- && ((nch == 1) || (nch == 2) || (nch == 3)));
-
- if (res) {
- if (TYPE(CHILD(tree, 0)) == DOUBLESTAR) {
- res = validate_test(CHILD(tree, 1));
- }
- else if (TYPE(CHILD(tree, 0)) == STAR) {
- res = validate_test(CHILD(tree, 1));
- }
- else if (nch == 1) {
- res = validate_test(CHILD(tree, 0));
- }
- else if (nch == 2) {
- res = (validate_test(CHILD(tree, 0))
- && validate_comp_for(CHILD(tree, 1)));
- }
- else if (res && (nch == 3)) {
- res = (validate_test(CHILD(tree, 0))
- && validate_equal(CHILD(tree, 1))
- && validate_test(CHILD(tree, 2)));
- }
- }
- return (res);
-}
-
-
-
-/* trailer:
- *
- * '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
- */
-static int
-validate_trailer(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, trailer) && ((nch == 2) || (nch == 3));
-
- if (res) {
- switch (TYPE(CHILD(tree, 0))) {
- case LPAR:
- res = validate_rparen(CHILD(tree, nch - 1));
- if (res && (nch == 3))
- res = validate_arglist(CHILD(tree, 1));
- break;
- case LSQB:
- res = (validate_numnodes(tree, 3, "trailer")
- && validate_subscriptlist(CHILD(tree, 1))
- && validate_ntype(CHILD(tree, 2), RSQB));
- break;
- case DOT:
- res = (validate_numnodes(tree, 2, "trailer")
- && validate_ntype(CHILD(tree, 1), NAME));
- break;
- default:
- res = 0;
- break;
- }
- }
- else {
- (void) validate_numnodes(tree, 2, "trailer");
- }
- return (res);
-}
-
-
-/* subscriptlist:
- *
- * subscript (',' subscript)* [',']
- */
-static int
-validate_subscriptlist(node *tree)
-{
- return (validate_repeating_list(tree, subscriptlist,
- validate_subscript, "subscriptlist"));
-}
-
-
-/* subscript:
- *
- * '.' '.' '.' | test | [test] ':' [test] [sliceop]
- */
-static int
-validate_subscript(node *tree)
-{
- int offset = 0;
- int nch = NCH(tree);
- int res = validate_ntype(tree, subscript) && (nch >= 1) && (nch <= 4);
-
- if (!res) {
- if (!PyErr_Occurred())
- err_string("invalid number of arguments for subscript node");
- return (0);
- }
- if (TYPE(CHILD(tree, 0)) == DOT)
- /* take care of ('.' '.' '.') possibility */
- return (validate_numnodes(tree, 3, "subscript")
- && validate_dot(CHILD(tree, 0))
- && validate_dot(CHILD(tree, 1))
- && validate_dot(CHILD(tree, 2)));
- if (nch == 1) {
- if (TYPE(CHILD(tree, 0)) == test)
- res = validate_test(CHILD(tree, 0));
- else
- res = validate_colon(CHILD(tree, 0));
- return (res);
- }
- /* Must be [test] ':' [test] [sliceop],
- * but at least one of the optional components will
- * be present, but we don't know which yet.
- */
- if ((TYPE(CHILD(tree, 0)) != COLON) || (nch == 4)) {
- res = validate_test(CHILD(tree, 0));
- offset = 1;
- }
- if (res)
- res = validate_colon(CHILD(tree, offset));
- if (res) {
- int rem = nch - ++offset;
- if (rem) {
- if (TYPE(CHILD(tree, offset)) == test) {
- res = validate_test(CHILD(tree, offset));
- ++offset;
- --rem;
- }
- if (res && rem)
- res = validate_sliceop(CHILD(tree, offset));
- }
- }
- return (res);
-}
-
-
-static int
-validate_sliceop(node *tree)
-{
- int nch = NCH(tree);
- int res = ((nch == 1) || validate_numnodes(tree, 2, "sliceop"))
- && validate_ntype(tree, sliceop);
- if (!res && !PyErr_Occurred()) {
- res = validate_numnodes(tree, 1, "sliceop");
- }
- if (res)
- res = validate_colon(CHILD(tree, 0));
- if (res && (nch == 2))
- res = validate_test(CHILD(tree, 1));
-
- return (res);
-}
-
-
-static int
-validate_test_or_star_expr(node *n)
-{
- if (TYPE(n) == test)
- return validate_test(n);
- return validate_star_expr(n);
-}
-
-static int
-validate_expr_or_star_expr(node *n)
-{
- if (TYPE(n) == expr)
- return validate_expr(n);
- return validate_star_expr(n);
-}
-
-
-static int
-validate_exprlist(node *tree)
-{
- return (validate_repeating_list(tree, exprlist,
- validate_expr_or_star_expr, "exprlist"));
-}
-
-/* Incrementing validate functions returns nonzero iff success (like other
- * validate functions, and advance *i by the length of the matched pattern. */
-
-/* test ':' test */
-static int
-validate_test_colon_test_inc(node *tree, int *i)
-{
- return (validate_test(CHILD(tree, (*i)++))
- && validate_colon(CHILD(tree, (*i)++))
- && validate_test(CHILD(tree, (*i)++)));
-}
-
-/* test ':' test | '**' expr */
-static int
-validate_dict_element_inc(node *tree, int *i)
-{
- int nch = NCH(tree);
- int res = 0;
- if (nch - *i >= 2) {
- if (TYPE(CHILD(tree, *i+1)) == COLON) {
- /* test ':' test */
- res = validate_test_colon_test_inc(tree, i);
- } else {
- /* '**' expr */
- res = (validate_doublestar(CHILD(tree, (*i)++))
- && validate_expr(CHILD(tree, (*i)++)));
- }
- }
- return res;
-}
-
-/*
- * dictorsetmaker:
- *
- * ( ((test ':' test | '**' expr)
- * (comp_for | (',' (test ':' test | '**' expr))* [','])) |
- * ((test | '*' test)
- * (comp_for | (',' (test | '*' test))* [','])) )
- */
-static int
-validate_dictorsetmaker(node *tree)
-{
- int nch = NCH(tree);
- int res;
- int i = 0;
-
- res = validate_ntype(tree, dictorsetmaker);
- if (!res)
- return 0;
-
- if (nch - i < 1) {
- /* Unconditionally raise. */
- (void) validate_numnodes(tree, 1, "dictorsetmaker");
- return 0;
- }
-
- if (nch - i >= 2
- && ((TYPE(CHILD(tree, i+1)) == COLON) ||
- (TYPE(CHILD(tree, i)) == DOUBLESTAR))) {
- /* Dictionary display or dictionary comprehension. */
- if (nch - i >= 4 && TYPE(CHILD(tree, i+3)) == comp_for) {
- /* Dictionary comprehension. */
- res = (validate_test_colon_test_inc(tree, &i)
- && validate_comp_for(CHILD(tree, i++)));
- if (!res)
- return 0;
- } else {
- /* Dictionary display. */
- return validate_repeating_list_variable(
- tree,
- dictorsetmaker,
- validate_dict_element_inc,
- &i,
- "dictorsetmaker");
- }
- } else {
- /* Set display or set comprehension. */
- if (nch - i >= 2 && TYPE(CHILD(tree, i + 1)) == comp_for) {
- /* Set comprehension. */
- res = (validate_test(CHILD(tree, i++))
- && validate_comp_for(CHILD(tree, i++)));
- if (!res)
- return 0;
- } else {
- /* Set display. */
- return validate_repeating_list(tree,
- dictorsetmaker,
- validate_test_or_star_expr,
- "dictorsetmaker");
- }
- }
-
- if (nch - i > 0) {
- err_string("Illegal trailing nodes for dictorsetmaker.");
- return 0;
- }
-
- return 1;
-}
-
-
-static int
-validate_eval_input(node *tree)
-{
- int pos;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, eval_input)
- && (nch >= 2)
- && validate_testlist(CHILD(tree, 0))
- && validate_ntype(CHILD(tree, nch - 1), ENDMARKER));
-
- for (pos = 1; res && (pos < (nch - 1)); ++pos)
- res = validate_ntype(CHILD(tree, pos), NEWLINE);
-
- return (res);
-}
-
-
-static int
-validate_node(node *tree)
-{
- int nch = 0; /* num. children on current node */
- int res = 1; /* result value */
- node* next = 0; /* node to process after this one */
-
- while (res && (tree != 0)) {
- nch = NCH(tree);
- next = 0;
- switch (TYPE(tree)) {
- /*
- * Definition nodes.
- */
- case async_funcdef:
- res = validate_async_funcdef(tree);
- break;
- case async_stmt:
- res = validate_async_stmt(tree);
- break;
- case funcdef:
- res = validate_funcdef(tree);
- break;
- case with_stmt:
- res = validate_with_stmt(tree);
- break;
- case classdef:
- res = validate_class(tree);
- break;
- case decorated:
- res = validate_decorated(tree);
- break;
- /*
- * "Trivial" parse tree nodes.
- * (Why did I call these trivial?)
- */
- case stmt:
- res = validate_stmt(tree);
- break;
- case small_stmt:
- /*
- * expr_stmt | del_stmt | pass_stmt | flow_stmt |
- * import_stmt | global_stmt | nonlocal_stmt | assert_stmt
- */
- res = validate_small_stmt(tree);
- break;
- case flow_stmt:
- res = (validate_numnodes(tree, 1, "flow_stmt")
- && ((TYPE(CHILD(tree, 0)) == break_stmt)
- || (TYPE(CHILD(tree, 0)) == continue_stmt)
- || (TYPE(CHILD(tree, 0)) == yield_stmt)
- || (TYPE(CHILD(tree, 0)) == return_stmt)
- || (TYPE(CHILD(tree, 0)) == raise_stmt)));
- if (res)
- next = CHILD(tree, 0);
- else if (nch == 1)
- err_string("illegal flow_stmt type");
- break;
- case yield_stmt:
- res = validate_yield_stmt(tree);
- break;
- /*
- * Compound statements.
- */
- case simple_stmt:
- res = validate_simple_stmt(tree);
- break;
- case compound_stmt:
- res = validate_compound_stmt(tree);
- break;
- /*
- * Fundamental statements.
- */
- case expr_stmt:
- res = validate_expr_stmt(tree);
- break;
- case del_stmt:
- res = validate_del_stmt(tree);
- break;
- case pass_stmt:
- res = (validate_numnodes(tree, 1, "pass")
- && validate_name(CHILD(tree, 0), "pass"));
- break;
- case break_stmt:
- res = (validate_numnodes(tree, 1, "break")
- && validate_name(CHILD(tree, 0), "break"));
- break;
- case continue_stmt:
- res = (validate_numnodes(tree, 1, "continue")
- && validate_name(CHILD(tree, 0), "continue"));
- break;
- case return_stmt:
- res = validate_return_stmt(tree);
- break;
- case raise_stmt:
- res = validate_raise_stmt(tree);
- break;
- case import_stmt:
- res = validate_import_stmt(tree);
- break;
- case import_name:
- res = validate_import_name(tree);
- break;
- case import_from:
- res = validate_import_from(tree);
- break;
- case global_stmt:
- res = validate_global_stmt(tree);
- break;
- case nonlocal_stmt:
- res = validate_nonlocal_stmt(tree);
- break;
- case assert_stmt:
- res = validate_assert_stmt(tree);
- break;
- case if_stmt:
- res = validate_if(tree);
- break;
- case while_stmt:
- res = validate_while(tree);
- break;
- case for_stmt:
- res = validate_for(tree);
- break;
- case try_stmt:
- res = validate_try(tree);
- break;
- case suite:
- res = validate_suite(tree);
- break;
- /*
- * Expression nodes.
- */
- case testlist:
- res = validate_testlist(tree);
- break;
- case yield_expr:
- res = validate_yield_expr(tree);
- break;
- case test:
- res = validate_test(tree);
- break;
- case and_test:
- res = validate_and_test(tree);
- break;
- case not_test:
- res = validate_not_test(tree);
- break;
- case comparison:
- res = validate_comparison(tree);
- break;
- case exprlist:
- res = validate_exprlist(tree);
- break;
- case comp_op:
- res = validate_comp_op(tree);
- break;
- case expr:
- res = validate_expr(tree);
- break;
- case xor_expr:
- res = validate_xor_expr(tree);
- break;
- case and_expr:
- res = validate_and_expr(tree);
- break;
- case shift_expr:
- res = validate_shift_expr(tree);
- break;
- case arith_expr:
- res = validate_arith_expr(tree);
- break;
- case term:
- res = validate_term(tree);
- break;
- case factor:
- res = validate_factor(tree);
- break;
- case power:
- res = validate_power(tree);
- break;
- case atom:
- res = validate_atom(tree);
- break;
-
- default:
- /* Hopefully never reached! */
- err_string("unrecognized node type");
- res = 0;
- break;
- }
- tree = next;
- }
- return (res);
-}
-
-
-static int
-validate_expr_tree(node *tree)
-{
- int res = validate_eval_input(tree);
-
- if (!res && !PyErr_Occurred())
- err_string("could not validate expression tuple");
-
- return (res);
-}
-
-
-/* file_input:
- * (NEWLINE | stmt)* ENDMARKER
- */
-static int
-validate_file_input(node *tree)
-{
- int j;
- int nch = NCH(tree) - 1;
- int res = ((nch >= 0)
- && validate_ntype(CHILD(tree, nch), ENDMARKER));
-
- for (j = 0; res && (j < nch); ++j) {
- if (TYPE(CHILD(tree, j)) == stmt)
- res = validate_stmt(CHILD(tree, j));
- else
- res = validate_newline(CHILD(tree, j));
- }
- /* This stays in to prevent any internal failures from getting to the
- * user. Hopefully, this won't be needed. If a user reports getting
- * this, we have some debugging to do.
- */
- if (!res && !PyErr_Occurred())
- err_string("VALIDATION FAILURE: report this to the maintainer!");
-
- return (res);
-}
-
-static int
-validate_encoding_decl(node *tree)
-{
- int nch = NCH(tree);
- int res = ((nch == 1)
- && validate_file_input(CHILD(tree, 0)));
-
- if (!res && !PyErr_Occurred())
- err_string("Error Parsing encoding_decl");
-
- return res;
-}
-
static PyObject*
pickle_constructor = NULL;
--
Repository URL: https://hg.python.org/cpython
1
0

June 2, 2016
https://hg.python.org/cpython/rev/174eae50b664
changeset: 101600:174eae50b664
parent: 101598:b110dd3d6cea
parent: 101599:ef800c30e28c
user: Berker Peksag <berker.peksag(a)gmail.com>
date: Thu Jun 02 11:31:51 2016 -0700
summary:
Issue #23116: Merge from 3.5
files:
Doc/tutorial/controlflow.rst | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -364,7 +364,7 @@
This creates a function that can be called with fewer arguments than it is
defined to allow. For example::
- def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
+ def ask_ok(prompt, retries=4, reminder='Please try again!'):
while True:
ok = input(prompt)
if ok in ('y', 'ye', 'yes'):
@@ -373,8 +373,8 @@
return False
retries = retries - 1
if retries < 0:
- raise OSError('uncooperative user')
- print(complaint)
+ raise ValueError('invalid user response')
+ print(reminder)
This function can be called in several ways:
--
Repository URL: https://hg.python.org/cpython
1
0

cpython (3.5): Issue #23116: Improve ask_ok() example in the Python tutorial
by berker.peksag June 2, 2016
by berker.peksag June 2, 2016
June 2, 2016
https://hg.python.org/cpython/rev/ef800c30e28c
changeset: 101599:ef800c30e28c
branch: 3.5
parent: 101594:ce31ee3b1e69
user: Berker Peksag <berker.peksag(a)gmail.com>
date: Thu Jun 02 11:31:19 2016 -0700
summary:
Issue #23116: Improve ask_ok() example in the Python tutorial
files:
Doc/tutorial/controlflow.rst | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -361,7 +361,7 @@
This creates a function that can be called with fewer arguments than it is
defined to allow. For example::
- def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
+ def ask_ok(prompt, retries=4, reminder='Please try again!'):
while True:
ok = input(prompt)
if ok in ('y', 'ye', 'yes'):
@@ -370,8 +370,8 @@
return False
retries = retries - 1
if retries < 0:
- raise OSError('uncooperative user')
- print(complaint)
+ raise ValueError('invalid user response')
+ print(reminder)
This function can be called in several ways:
--
Repository URL: https://hg.python.org/cpython
1
0

cpython: Issue #21271: Adds new keyword only parameters in reset_mock call
by kushal.das June 2, 2016
by kushal.das June 2, 2016
June 2, 2016
https://hg.python.org/cpython/rev/b110dd3d6cea
changeset: 101598:b110dd3d6cea
parent: 101596:0ddba0abab49
user: Kushal Das <kushaldas(a)gmail.com>
date: Thu Jun 02 10:20:16 2016 -0700
summary:
Issue #21271: Adds new keyword only parameters in reset_mock call
We now have two keyword only parameters in the reset_mock function to
selectively reset the return_value or the side_effects, or both.
files:
Doc/library/unittest.mock.rst | 12 +++++++-
Lib/unittest/mock.py | 7 ++++-
Lib/unittest/test/testmock/testmock.py | 18 ++++++++++++++
Misc/NEWS | 2 +
4 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -364,7 +364,7 @@
.. versionadded:: 3.5
- .. method:: reset_mock()
+ .. method:: reset_mock(*, return_value=False, side_effect=False)
The reset_mock method resets all the call attributes on a mock object:
@@ -376,12 +376,20 @@
>>> mock.called
False
+ .. versionchanged:: 3.6
+ Added two keyword only argument to the reset_mock function.
+
This can be useful where you want to make a series of assertions that
reuse the same object. Note that :meth:`reset_mock` *doesn't* clear the
return value, :attr:`side_effect` or any child attributes you have
- set using normal assignment. Child mocks and the return value mock
+ set using normal assignment by default. In case you want to reset
+ *return_value* or :attr:`side_effect`, then pass the corresponding
+ parameter as ``True``. Child mocks and the return value mock
(if any) are reset as well.
+ .. note:: *return_value*, and :attr:`side_effect` are keyword only
+ argument.
+
.. method:: mock_add_spec(spec, spec_set=False)
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -523,7 +523,7 @@
side_effect = property(__get_side_effect, __set_side_effect)
- def reset_mock(self, visited=None):
+ def reset_mock(self, visited=None,*, return_value=False, side_effect=False):
"Restore the mock object to its initial state."
if visited is None:
visited = []
@@ -538,6 +538,11 @@
self.call_args_list = _CallList()
self.method_calls = _CallList()
+ if return_value:
+ self._mock_return_value = DEFAULT
+ if side_effect:
+ self._mock_side_effect = None
+
for child in self._mock_children.values():
if isinstance(child, _SpecState):
continue
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -1277,6 +1277,24 @@
self.assertEqual(m.method_calls[0], c)
self.assertEqual(m.method_calls[1], i)
+ def test_reset_return_sideeffect(self):
+ m = Mock(return_value=10, side_effect=[2,3])
+ m.reset_mock(return_value=True, side_effect=True)
+ self.assertIsInstance(m.return_value, Mock)
+ self.assertEqual(m.side_effect, None)
+
+ def test_reset_return(self):
+ m = Mock(return_value=10, side_effect=[2,3])
+ m.reset_mock(return_value=True)
+ self.assertIsInstance(m.return_value, Mock)
+ self.assertNotEqual(m.side_effect, None)
+
+ def test_reset_sideeffect(self):
+ m = Mock(return_value=10, side_effect=[2,3])
+ m.reset_mock(side_effect=True)
+ self.assertEqual(m.return_value, 10)
+ self.assertEqual(m.side_effect, None)
+
def test_mock_add_spec(self):
class _One(object):
one = 1
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -36,6 +36,8 @@
- Issue #27056: Optimize pickle.load() and pickle.loads(), up to 10% faster
to deserialize a lot of small objects.
+- Issue #21271: New keyword only parameters in reset_mock call.
+
IDLE
----
--
Repository URL: https://hg.python.org/cpython
1
0

cpython (2.7): Issue #27171: Fix typos in documentation, code comments, and tests
by martin.panter June 2, 2016
by martin.panter June 2, 2016
June 2, 2016
https://hg.python.org/cpython/rev/b0b463760b45
changeset: 101597:b0b463760b45
branch: 2.7
parent: 101593:98870f27d2ed
user: Martin Panter <vadmium+py(a)gmail.com>
date: Thu Jun 02 10:35:44 2016 +0000
summary:
Issue #27171: Fix typos in documentation, code comments, and tests
files:
Demo/tkinter/ttk/ttkcalendar.py | 2 +-
Include/pymacconfig.h | 2 +-
Lib/Cookie.py | 2 +-
Lib/_osx_support.py | 12 ++++++------
Lib/_pyio.py | 2 +-
Lib/bsddb/test/test_all.py | 2 +-
Lib/decimal.py | 2 +-
Lib/distutils/tests/test_build_ext.py | 2 +-
Lib/hotshot/__init__.py | 2 +-
Lib/idlelib/AutoComplete.py | 2 +-
Lib/idlelib/MultiCall.py | 2 +-
Lib/idlelib/rpc.py | 2 +-
Lib/locale.py | 2 +-
Lib/pdb.doc | 2 +-
Lib/plat-mac/bgenlocations.py | 2 +-
Lib/test/test_socket.py | 4 ++--
Lib/test/test_sys_setprofile.py | 2 +-
Misc/HISTORY | 2 +-
Misc/NEWS | 10 +++++-----
Modules/_bsddb.c | 2 +-
Modules/ld_so_aix.in | 6 +++---
Modules/readline.c | 2 +-
Objects/fileobject.c | 2 +-
Tools/bgen/bgen/bgenVariable.py | 2 +-
setup.py | 4 ++--
25 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/Demo/tkinter/ttk/ttkcalendar.py b/Demo/tkinter/ttk/ttkcalendar.py
--- a/Demo/tkinter/ttk/ttkcalendar.py
+++ b/Demo/tkinter/ttk/ttkcalendar.py
@@ -191,7 +191,7 @@
self._date = self._date - self.timedelta(days=1)
self._date = self.datetime(self._date.year, self._date.month, 1)
- self._build_calendar() # reconstuct calendar
+ self._build_calendar() # reconstruct calendar
def _next_month(self):
"""Update calendar to show the next month."""
diff --git a/Include/pymacconfig.h b/Include/pymacconfig.h
--- a/Include/pymacconfig.h
+++ b/Include/pymacconfig.h
@@ -66,7 +66,7 @@
* Therefore surpress the toolbox-glue in 64-bit mode.
*/
- /* In 64-bit mode setpgrp always has no argments, in 32-bit
+ /* In 64-bit mode setpgrp always has no arguments, in 32-bit
* mode that depends on the compilation environment
*/
# undef SETPGRP_HAVE_ARG
diff --git a/Lib/Cookie.py b/Lib/Cookie.py
--- a/Lib/Cookie.py
+++ b/Lib/Cookie.py
@@ -190,7 +190,7 @@
Backwards Compatibility
-----------------------
-In order to keep compatibilty with earlier versions of Cookie.py,
+In order to keep compatibility with earlier versions of Cookie.py,
it is still possible to use Cookie.Cookie() to create a Cookie. In
fact, this simply returns a SmartCookie.
diff --git a/Lib/_osx_support.py b/Lib/_osx_support.py
--- a/Lib/_osx_support.py
+++ b/Lib/_osx_support.py
@@ -157,7 +157,7 @@
# gcc-4.2 is either not present, or a copy of 'llvm-gcc' that
# miscompiles Python.
- # skip checks if the compiler was overriden with a CC env variable
+ # skip checks if the compiler was overridden with a CC env variable
if 'CC' in os.environ:
return _config_vars
@@ -193,7 +193,7 @@
if cc != oldcc:
# Found a replacement compiler.
# Modify config vars using new compiler, if not already explicitly
- # overriden by an env variable, preserving additional arguments.
+ # overridden by an env variable, preserving additional arguments.
for cv in _COMPILER_CONFIG_VARS:
if cv in _config_vars and cv not in os.environ:
cv_split = _config_vars[cv].split()
@@ -207,7 +207,7 @@
"""Remove all universal build arguments from config vars"""
for cv in _UNIVERSAL_CONFIG_VARS:
- # Do not alter a config var explicitly overriden by env var
+ # Do not alter a config var explicitly overridden by env var
if cv in _config_vars and cv not in os.environ:
flags = _config_vars[cv]
flags = re.sub('-arch\s+\w+\s', ' ', flags)
@@ -228,7 +228,7 @@
# build extensions on OSX 10.7 and later with the prebuilt
# 32-bit installer on the python.org website.
- # skip checks if the compiler was overriden with a CC env variable
+ # skip checks if the compiler was overridden with a CC env variable
if 'CC' in os.environ:
return _config_vars
@@ -244,7 +244,7 @@
# across Xcode and compiler versions, there is no reliable way
# to be sure why it failed. Assume here it was due to lack of
# PPC support and remove the related '-arch' flags from each
- # config variables not explicitly overriden by an environment
+ # config variables not explicitly overridden by an environment
# variable. If the error was for some other reason, we hope the
# failure will show up again when trying to compile an extension
# module.
@@ -292,7 +292,7 @@
sdk = m.group(1)
if not os.path.exists(sdk):
for cv in _UNIVERSAL_CONFIG_VARS:
- # Do not alter a config var explicitly overriden by env var
+ # Do not alter a config var explicitly overridden by env var
if cv in _config_vars and cv not in os.environ:
flags = _config_vars[cv]
flags = re.sub(r'-isysroot\s+\S+(?:\s|$)', ' ', flags)
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -997,7 +997,7 @@
break
avail += len(chunk)
chunks.append(chunk)
- # n is more then avail only when an EOF occurred or when
+ # n is more than avail only when an EOF occurred or when
# read() would have blocked.
n = min(n, avail)
out = b"".join(chunks)
diff --git a/Lib/bsddb/test/test_all.py b/Lib/bsddb/test/test_all.py
--- a/Lib/bsddb/test/test_all.py
+++ b/Lib/bsddb/test/test_all.py
@@ -523,7 +523,7 @@
return path
-# This path can be overriden via "set_test_path_prefix()".
+# This path can be overridden via "set_test_path_prefix()".
import os, os.path
get_new_path.prefix=os.path.join(os.environ.get("TMPDIR",
os.path.join(os.sep,"tmp")), "z-Berkeley_DB")
diff --git a/Lib/decimal.py b/Lib/decimal.py
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -1082,7 +1082,7 @@
def __pos__(self, context=None):
"""Returns a copy, unless it is a sNaN.
- Rounds the number (if more then precision digits)
+ Rounds the number (if more than precision digits)
"""
if self._is_special:
ans = self._check_nans(context=context)
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -251,7 +251,7 @@
def test_compiler_option(self):
# cmd.compiler is an option and
- # should not be overriden by a compiler instance
+ # should not be overridden by a compiler instance
# when the command is run
dist = Distribution()
cmd = build_ext(dist)
diff --git a/Lib/hotshot/__init__.py b/Lib/hotshot/__init__.py
--- a/Lib/hotshot/__init__.py
+++ b/Lib/hotshot/__init__.py
@@ -72,7 +72,7 @@
Additional positional and keyword arguments may be passed
along; the result of the call is returned, and exceptions are
- allowed to propogate cleanly, while ensuring that profiling is
+ allowed to propagate cleanly, while ensuring that profiling is
disabled on the way out.
"""
return self._prof.runcall(func, args, kw)
diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/AutoComplete.py
--- a/Lib/idlelib/AutoComplete.py
+++ b/Lib/idlelib/AutoComplete.py
@@ -1,6 +1,6 @@
"""AutoComplete.py - An IDLE extension for automatically completing names.
-This extension can complete either attribute names of file names. It can pop
+This extension can complete either attribute names or file names. It can pop
a window with all available names, for the user to select from.
"""
import os
diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/MultiCall.py
--- a/Lib/idlelib/MultiCall.py
+++ b/Lib/idlelib/MultiCall.py
@@ -101,7 +101,7 @@
self.widget.unbind(self.widgetinst, self.sequence, self.handlerid)
# An int in range(1 << len(_modifiers)) represents a combination of modifiers
-# (if the least significent bit is on, _modifiers[0] is on, and so on).
+# (if the least significant bit is on, _modifiers[0] is on, and so on).
# _state_subsets gives for each combination of modifiers, or *state*,
# a list of the states which are a subset of it. This list is ordered by the
# number of modifiers is the state - the most specific state comes first.
diff --git a/Lib/idlelib/rpc.py b/Lib/idlelib/rpc.py
--- a/Lib/idlelib/rpc.py
+++ b/Lib/idlelib/rpc.py
@@ -1,4 +1,4 @@
-"""RPC Implemention, originally written for the Python Idle IDE
+"""RPC Implementation, originally written for the Python Idle IDE
For security reasons, GvR requested that Idle's Python execution server process
connect to the Idle process, which listens for the connection. Since Idle has
diff --git a/Lib/locale.py b/Lib/locale.py
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -16,7 +16,7 @@
import operator
import functools
-# keep a copy of the builtin str type, because 'str' name is overriden
+# keep a copy of the builtin str type, because 'str' name is overridden
# in globals by a function below
_str = str
diff --git a/Lib/pdb.doc b/Lib/pdb.doc
--- a/Lib/pdb.doc
+++ b/Lib/pdb.doc
@@ -48,7 +48,7 @@
directory, it is read in and executed as if it had been typed at the
debugger prompt. This is particularly useful for aliases. If both
files exist, the one in the home directory is read first and aliases
-defined there can be overriden by the local file.
+defined there can be overridden by the local file.
Aside from aliases, the debugger is not directly programmable; but it
is implemented as a class from which you can derive your own debugger
diff --git a/Lib/plat-mac/bgenlocations.py b/Lib/plat-mac/bgenlocations.py
--- a/Lib/plat-mac/bgenlocations.py
+++ b/Lib/plat-mac/bgenlocations.py
@@ -34,7 +34,7 @@
# Creator for C files:
CREATOR="CWIE"
-# The previous definitions can be overriden by creating a module
+# The previous definitions can be overridden by creating a module
# bgenlocationscustomize.py and putting it in site-packages (or anywere else
# on sys.path, actually)
try:
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -708,7 +708,7 @@
pass
def check_sendall_interrupted(self, with_timeout):
- # socketpair() is not stricly required, but it makes things easier.
+ # socketpair() is not strictly required, but it makes things easier.
if not hasattr(signal, 'alarm') or not hasattr(socket, 'socketpair'):
self.skipTest("signal.alarm and socket.socketpair required for this test")
# Our signal handlers clobber the C errno by calling a math function
@@ -827,7 +827,7 @@
self.serv_conn.sendall(big_chunk)
@unittest.skipUnless(hasattr(socket, 'fromfd'),
- 'socket.fromfd not availble')
+ 'socket.fromfd not available')
def testFromFd(self):
# Testing fromfd()
fd = self.cli_conn.fileno()
diff --git a/Lib/test/test_sys_setprofile.py b/Lib/test/test_sys_setprofile.py
--- a/Lib/test/test_sys_setprofile.py
+++ b/Lib/test/test_sys_setprofile.py
@@ -165,7 +165,7 @@
(1, 'return', g_ident),
])
- def test_exception_propogation(self):
+ def test_exception_propagation(self):
def f(p):
1./0
def g(p):
diff --git a/Misc/HISTORY b/Misc/HISTORY
--- a/Misc/HISTORY
+++ b/Misc/HISTORY
@@ -10009,7 +10009,7 @@
* Tools/scripts/dutree.py:
During display, if EPIPE is raised, it's probably because a pager was
- killed. Discard the error in that case, but propogate it otherwise.
+ killed. Discard the error in that case, but propagate it otherwise.
Fri Mar 26 16:20:45 1999 Guido van Rossum <guido(a)eric.cnri.reston.va.us>
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -2344,8 +2344,8 @@
with port None or "0" and flags AI_NUMERICSERV.
- Issue #18080: When building a C extension module on OS X, if the compiler
- is overriden with the CC environment variable, use the new compiler as
- the default for linking if LDSHARED is not also overriden. This restores
+ is overridden with the CC environment variable, use the new compiler as
+ the default for linking if LDSHARED is not also overridden. This restores
Distutils behavior introduced in 2.7.3 and inadvertently dropped in 2.7.4.
- Issue #18071: C extension module builds on OS X could fail with TypeError
@@ -5467,7 +5467,7 @@
- Issue #7900: The getgroups(2) system call on MacOSX behaves rather oddly
compared to other unix systems. In particular, os.getgroups() does
- not reflect any changes made using os.setgroups() but basicly always
+ not reflect any changes made using os.setgroups() but basically always
returns the same information as the id command.
os.getgroups() can now return more than 16 groups on MacOSX.
@@ -8076,7 +8076,7 @@
backported to help facilitate transitions from 2.7 to 3.1.
- Issue #1885: distutils: When running sdist with --formats=tar,gztar the tar
- file was overriden by the gztar one.
+ file was overridden by the gztar one.
- Issue #4863: distutils.mwerkscompiler has been removed.
@@ -8365,7 +8365,7 @@
installed.
- Issue #5809: Specifying both --enable-framework and --enable-shared is an
- error. Configure now explicity tells you about this.
+ error. Configure now explicitly tells you about this.
- Issue #3585: Add pkg-config support. It creates a python-2.7.pc file and a
python.pc symlink in the $(LIBDIR)/pkgconfig directory. Patch by Clinton Roy.
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -3686,7 +3686,7 @@
/*
** DB_BUFFER_SMALL is only used if we use "get".
** We can drop it when we only use "exists",
- ** when we drop suport for Berkeley DB < 4.6.
+ ** when we drop support for Berkeley DB < 4.6.
*/
if (err == DB_BUFFER_SMALL || err == 0) {
Py_INCREF(Py_True);
diff --git a/Modules/ld_so_aix.in b/Modules/ld_so_aix.in
--- a/Modules/ld_so_aix.in
+++ b/Modules/ld_so_aix.in
@@ -12,7 +12,7 @@
#
# ARGUMENTS: Same as for "ld". The following arguments are processed
# or supplied by this script (those marked with an asterisk
-# can be overriden from command line):
+# can be overridden from command line):
#
# Argument Default value
# (*) -o [OutputFileName] -o shr.o
@@ -85,7 +85,7 @@
fi
# Default import file for Python
-# Can be overriden by providing a -bI: argument.
+# Can be overridden by providing a -bI: argument.
impfile="./python.exp"
# Parse arguments
@@ -156,7 +156,7 @@
fi
# Default entry symbol for Python modules = init[modulename]
-# Can be overriden by providing a -e argument.
+# Can be overridden by providing a -e argument.
if test -z "$entry"; then
entry=init`echo $filename | sed "s/module.*//"`
fi
diff --git a/Modules/readline.c b/Modules/readline.c
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -960,7 +960,7 @@
#ifndef __APPLE__
if (!isatty(STDOUT_FILENO)) {
- /* Issue #19884: stdout is no a terminal. Disable meta modifier
+ /* Issue #19884: stdout is not a terminal. Disable meta modifier
keys to not write the ANSI sequence "\033[1034h" into stdout. On
terminals supporting 8 bit characters like TERM=xterm-256color
(which is now the default Fedora since Fedora 18), the meta key is
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -835,7 +835,7 @@
if (initialpos == -1)
goto onioerror;
- /* Set newsize to current postion if newsizeobj NULL, else to the
+ /* Set newsize to current position if newsizeobj NULL, else to the
* specified value.
*/
if (newsizeobj != NULL) {
diff --git a/Tools/bgen/bgen/bgenVariable.py b/Tools/bgen/bgen/bgenVariable.py
--- a/Tools/bgen/bgen/bgenVariable.py
+++ b/Tools/bgen/bgen/bgenVariable.py
@@ -20,7 +20,7 @@
"""A Variable holds a type, a name, a transfer mode and flags.
- Most of its methods call the correponding type method with the
+ Most of its methods call the corresponding type method with the
variable name.
"""
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -770,7 +770,7 @@
# In every directory on the search path search for a dynamic
# library and then a static library, instead of first looking
# for dynamic libraries on the entire path.
- # This way a staticly linked custom readline gets picked up
+ # This way a statically linked custom readline gets picked up
# before the (possibly broken) dynamic library in /usr/lib.
readline_extra_link_args = ('-Wl,-search_paths_first',)
else:
@@ -1767,7 +1767,7 @@
# --with-tcltk-libs="-L/path/to/tcllibs -ltclm.n \
# -L/path/to/tklibs -ltkm.n"
#
- # These values can also be specified or overriden via make:
+ # These values can also be specified or overridden via make:
# make TCLTK_INCLUDES="..." TCLTK_LIBS="..."
#
# This can be useful for building and testing tkinter with multiple
--
Repository URL: https://hg.python.org/cpython
1
0
https://hg.python.org/cpython/rev/0ddba0abab49
changeset: 101596:0ddba0abab49
user: Martin Panter <vadmium+py(a)gmail.com>
date: Thu Jun 02 10:13:47 2016 +0000
summary:
Issue #27171: Fix typo in exception message
files:
Modules/_ctypes/callproc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -380,7 +380,7 @@
whose operation is not allowed in the current
machine mode. */
PyErr_SetString(PyExc_OSError,
- "exception: priviledged instruction");
+ "exception: privileged instruction");
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
--
Repository URL: https://hg.python.org/cpython
1
0

cpython (merge 3.5 -> default): Issue #27171: Merge typo fixes from 3.5
by martin.panter June 2, 2016
by martin.panter June 2, 2016
June 2, 2016
https://hg.python.org/cpython/rev/c67f1f4ebb32
changeset: 101595:c67f1f4ebb32
parent: 101592:1bd3daae351d
parent: 101594:ce31ee3b1e69
user: Martin Panter <vadmium+py(a)gmail.com>
date: Thu Jun 02 10:11:18 2016 +0000
summary:
Issue #27171: Merge typo fixes from 3.5
files:
Include/pymacconfig.h | 2 +-
Lib/_osx_support.py | 12 +++++-----
Lib/_pydecimal.py | 2 +-
Lib/_pyio.py | 2 +-
Lib/distutils/tests/test_build_ext.py | 2 +-
Lib/idlelib/autocomplete.py | 2 +-
Lib/idlelib/multicall.py | 2 +-
Lib/idlelib/rpc.py | 2 +-
Lib/pathlib.py | 2 +-
Lib/pdb.py | 2 +-
Lib/random.py | 2 +-
Lib/site.py | 4 +-
Lib/test/test_bigmem.py | 2 +-
Lib/test/test_email/test_policy.py | 2 +-
Lib/test/test_module.py | 2 +-
Lib/test/test_pep3151.py | 6 ++--
Lib/test/test_random.py | 2 +-
Lib/test/test_socket.py | 2 +-
Lib/test/test_sys_setprofile.py | 2 +-
Lib/tkinter/__init__.py | 2 +-
Lib/unittest/suite.py | 2 +-
Misc/HISTORY | 18 +++++++-------
Misc/NEWS | 4 +-
Modules/_datetimemodule.c | 4 +-
Modules/_lzmamodule.c | 2 +-
Modules/ld_so_aix.in | 6 ++--
Modules/readline.c | 2 +-
Objects/exceptions.c | 2 +-
Objects/unicodeobject.c | 2 +-
setup.py | 4 +-
30 files changed, 51 insertions(+), 51 deletions(-)
diff --git a/Include/pymacconfig.h b/Include/pymacconfig.h
--- a/Include/pymacconfig.h
+++ b/Include/pymacconfig.h
@@ -66,7 +66,7 @@
* Therefore surpress the toolbox-glue in 64-bit mode.
*/
- /* In 64-bit mode setpgrp always has no argments, in 32-bit
+ /* In 64-bit mode setpgrp always has no arguments, in 32-bit
* mode that depends on the compilation environment
*/
# undef SETPGRP_HAVE_ARG
diff --git a/Lib/_osx_support.py b/Lib/_osx_support.py
--- a/Lib/_osx_support.py
+++ b/Lib/_osx_support.py
@@ -157,7 +157,7 @@
# gcc-4.2 is either not present, or a copy of 'llvm-gcc' that
# miscompiles Python.
- # skip checks if the compiler was overriden with a CC env variable
+ # skip checks if the compiler was overridden with a CC env variable
if 'CC' in os.environ:
return _config_vars
@@ -193,7 +193,7 @@
if cc != oldcc:
# Found a replacement compiler.
# Modify config vars using new compiler, if not already explicitly
- # overriden by an env variable, preserving additional arguments.
+ # overridden by an env variable, preserving additional arguments.
for cv in _COMPILER_CONFIG_VARS:
if cv in _config_vars and cv not in os.environ:
cv_split = _config_vars[cv].split()
@@ -207,7 +207,7 @@
"""Remove all universal build arguments from config vars"""
for cv in _UNIVERSAL_CONFIG_VARS:
- # Do not alter a config var explicitly overriden by env var
+ # Do not alter a config var explicitly overridden by env var
if cv in _config_vars and cv not in os.environ:
flags = _config_vars[cv]
flags = re.sub('-arch\s+\w+\s', ' ', flags, re.ASCII)
@@ -228,7 +228,7 @@
# build extensions on OSX 10.7 and later with the prebuilt
# 32-bit installer on the python.org website.
- # skip checks if the compiler was overriden with a CC env variable
+ # skip checks if the compiler was overridden with a CC env variable
if 'CC' in os.environ:
return _config_vars
@@ -244,7 +244,7 @@
# across Xcode and compiler versions, there is no reliable way
# to be sure why it failed. Assume here it was due to lack of
# PPC support and remove the related '-arch' flags from each
- # config variables not explicitly overriden by an environment
+ # config variables not explicitly overridden by an environment
# variable. If the error was for some other reason, we hope the
# failure will show up again when trying to compile an extension
# module.
@@ -292,7 +292,7 @@
sdk = m.group(1)
if not os.path.exists(sdk):
for cv in _UNIVERSAL_CONFIG_VARS:
- # Do not alter a config var explicitly overriden by env var
+ # Do not alter a config var explicitly overridden by env var
if cv in _config_vars and cv not in os.environ:
flags = _config_vars[cv]
flags = re.sub(r'-isysroot\s+\S+(?:\s|$)', ' ', flags)
diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py
--- a/Lib/_pydecimal.py
+++ b/Lib/_pydecimal.py
@@ -1152,7 +1152,7 @@
def __pos__(self, context=None):
"""Returns a copy, unless it is a sNaN.
- Rounds the number (if more then precision digits)
+ Rounds the number (if more than precision digits)
"""
if self._is_special:
ans = self._check_nans(context=context)
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -1043,7 +1043,7 @@
break
avail += len(chunk)
chunks.append(chunk)
- # n is more then avail only when an EOF occurred or when
+ # n is more than avail only when an EOF occurred or when
# read() would have blocked.
n = min(n, avail)
out = b"".join(chunks)
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -278,7 +278,7 @@
def test_compiler_option(self):
# cmd.compiler is an option and
- # should not be overriden by a compiler instance
+ # should not be overridden by a compiler instance
# when the command is run
dist = Distribution()
cmd = self.build_ext(dist)
diff --git a/Lib/idlelib/autocomplete.py b/Lib/idlelib/autocomplete.py
--- a/Lib/idlelib/autocomplete.py
+++ b/Lib/idlelib/autocomplete.py
@@ -1,6 +1,6 @@
"""autocomplete.py - An IDLE extension for automatically completing names.
-This extension can complete either attribute names of file names. It can pop
+This extension can complete either attribute names or file names. It can pop
a window with all available names, for the user to select from.
"""
import os
diff --git a/Lib/idlelib/multicall.py b/Lib/idlelib/multicall.py
--- a/Lib/idlelib/multicall.py
+++ b/Lib/idlelib/multicall.py
@@ -111,7 +111,7 @@
raise
# An int in range(1 << len(_modifiers)) represents a combination of modifiers
-# (if the least significent bit is on, _modifiers[0] is on, and so on).
+# (if the least significant bit is on, _modifiers[0] is on, and so on).
# _state_subsets gives for each combination of modifiers, or *state*,
# a list of the states which are a subset of it. This list is ordered by the
# number of modifiers is the state - the most specific state comes first.
diff --git a/Lib/idlelib/rpc.py b/Lib/idlelib/rpc.py
--- a/Lib/idlelib/rpc.py
+++ b/Lib/idlelib/rpc.py
@@ -1,4 +1,4 @@
-"""RPC Implemention, originally written for the Python Idle IDE
+"""RPC Implementation, originally written for the Python Idle IDE
For security reasons, GvR requested that Idle's Python execution server process
connect to the Idle process, which listens for the connection. Since Idle has
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -674,7 +674,7 @@
return cls._flavour.join(parts)
def _init(self):
- # Overriden in concrete Path
+ # Overridden in concrete Path
pass
def _make_child(self, args):
diff --git a/Lib/pdb.py b/Lib/pdb.py
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -52,7 +52,7 @@
directory, it is read in and executed as if it had been typed at the
debugger prompt. This is particularly useful for aliases. If both
files exist, the one in the home directory is read first and aliases
-defined there can be overriden by the local file.
+defined there can be overridden by the local file.
Aside from aliases, the debugger is not directly programmable; but it
is implemented as a class from which you can derive your own debugger
diff --git a/Lib/random.py b/Lib/random.py
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -231,7 +231,7 @@
while r >= n:
r = getrandbits(k)
return r
- # There's an overriden random() method but no new getrandbits() method,
+ # There's an overridden random() method but no new getrandbits() method,
# so we can only use random() from here.
if n >= maxsize:
_warn("Underlying random() generator does not supply \n"
diff --git a/Lib/site.py b/Lib/site.py
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -59,7 +59,7 @@
omitted because it is not mentioned in either path configuration file.
The readline module is also automatically configured to enable
-completion for systems that support it. This can be overriden in
+completion for systems that support it. This can be overridden in
sitecustomize, usercustomize or PYTHONSTARTUP.
After these operations, an attempt is made to import a module
@@ -379,7 +379,7 @@
If the readline module can be imported, the hook will set the Tab key
as completion key and register ~/.python_history as history file.
- This can be overriden in the sitecustomize or usercustomize module,
+ This can be overridden in the sitecustomize or usercustomize module,
or in a PYTHONSTARTUP file.
"""
def register_readline():
diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py
--- a/Lib/test/test_bigmem.py
+++ b/Lib/test/test_bigmem.py
@@ -736,7 +736,7 @@
finally:
r = s = None
- # The original test_translate is overriden here, so as to get the
+ # The original test_translate is overridden here, so as to get the
# correct size estimate: str.translate() uses an intermediate Py_UCS4
# representation.
diff --git a/Lib/test/test_email/test_policy.py b/Lib/test/test_email/test_policy.py
--- a/Lib/test/test_email/test_policy.py
+++ b/Lib/test/test_email/test_policy.py
@@ -177,7 +177,7 @@
with self.assertRaisesRegex(self.MyDefect, "the telly is broken"):
self.MyPolicy(raise_on_defect=True).handle_defect(foo, defect)
- def test_overriden_register_defect_works(self):
+ def test_overridden_register_defect_works(self):
foo = self.MyObj()
defect1 = self.MyDefect("one")
my_policy = self.MyPolicy()
diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py
--- a/Lib/test/test_module.py
+++ b/Lib/test/test_module.py
@@ -227,7 +227,7 @@
b"len = len",
b"shutil.rmtree = rmtree"})
- def test_descriptor_errors_propogate(self):
+ def test_descriptor_errors_propagate(self):
class Descr:
def __get__(self, o, t):
raise RuntimeError
diff --git a/Lib/test/test_pep3151.py b/Lib/test/test_pep3151.py
--- a/Lib/test/test_pep3151.py
+++ b/Lib/test/test_pep3151.py
@@ -163,7 +163,7 @@
e = SubOSError(EEXIST, "Bad file descriptor")
self.assertIs(type(e), SubOSError)
- def test_init_overriden(self):
+ def test_init_overridden(self):
e = SubOSErrorWithInit("some message", "baz")
self.assertEqual(e.bar, "baz")
self.assertEqual(e.args, ("some message",))
@@ -173,7 +173,7 @@
self.assertEqual(e.bar, "baz")
self.assertEqual(e.args, ("some message",))
- def test_new_overriden(self):
+ def test_new_overridden(self):
e = SubOSErrorWithNew("some message", "baz")
self.assertEqual(e.baz, "baz")
self.assertEqual(e.args, ("some message",))
@@ -183,7 +183,7 @@
self.assertEqual(e.baz, "baz")
self.assertEqual(e.args, ("some message",))
- def test_init_new_overriden(self):
+ def test_init_new_overridden(self):
e = SubOSErrorCombinedInitFirst("some message", "baz")
self.assertEqual(e.bar, "baz")
self.assertEqual(e.baz, "baz")
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -494,7 +494,7 @@
self.assertTrue(2**k > n > 2**(k-1)) # note the stronger assertion
@unittest.mock.patch('random.Random.random')
- def test_randbelow_overriden_random(self, random_mock):
+ def test_randbelow_overridden_random(self, random_mock):
# Random._randbelow() can only use random() when the built-in one
# has been overridden but no new getrandbits() method was supplied.
random_mock.side_effect = random.SystemRandom().random
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1314,7 +1314,7 @@
# socket.gethostbyaddr('испытание.python.org')
def check_sendall_interrupted(self, with_timeout):
- # socketpair() is not stricly required, but it makes things easier.
+ # socketpair() is not strictly required, but it makes things easier.
if not hasattr(signal, 'alarm') or not hasattr(socket, 'socketpair'):
self.skipTest("signal.alarm and socket.socketpair required for this test")
# Our signal handlers clobber the C errno by calling a math function
diff --git a/Lib/test/test_sys_setprofile.py b/Lib/test/test_sys_setprofile.py
--- a/Lib/test/test_sys_setprofile.py
+++ b/Lib/test/test_sys_setprofile.py
@@ -164,7 +164,7 @@
(1, 'return', g_ident),
])
- def test_exception_propogation(self):
+ def test_exception_propagation(self):
def f(p):
1/0
def g(p):
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -3125,7 +3125,7 @@
"""Creates a peer text widget with the given newPathName, and any
optional standard configuration options. By default the peer will
have the same start and end line as the parent widget, but
- these can be overriden with the standard configuration options."""
+ these can be overridden with the standard configuration options."""
self.tk.call(self._w, 'peer', 'create', newPathName,
*self._options(cnf, kw))
def peer_names(self): # new in Tk 8.5
diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py
--- a/Lib/unittest/suite.py
+++ b/Lib/unittest/suite.py
@@ -71,7 +71,7 @@
try:
test = self._tests[index]
except TypeError:
- # support for suite implementations that have overriden self._tests
+ # support for suite implementations that have overridden self._tests
pass
else:
# Some unittest tests add non TestCase/TestSuite objects to
diff --git a/Misc/HISTORY b/Misc/HISTORY
--- a/Misc/HISTORY
+++ b/Misc/HISTORY
@@ -1834,7 +1834,7 @@
objects. Initial patch by Matthias Troffaes.
- Fix OSError.__init__ and OSError.__new__ so that each of them can be
- overriden and take additional arguments (followup to issue #12555).
+ overridden and take additional arguments (followup to issue #12555).
- Fix the fix for issue #12149: it was incorrect, although it had the side
effect of appearing to resolve the issue. Thanks to Mark Shannon for
@@ -2053,7 +2053,7 @@
given, produce an informative error message which includes the name(s) of the
missing arguments.
-- Issue #12370: Fix super with no arguments when __class__ is overriden in the
+- Issue #12370: Fix super with no arguments when __class__ is overridden in the
class body.
- Issue #12084: os.stat on Windows now works properly with relative symbolic
@@ -7273,7 +7273,7 @@
messages parsed by email.Parser.HeaderParser.
- Issue #7361: Importlib was not properly checking the number of bytes in
- bytecode file when it was less then 8 bytes.
+ bytecode file when it was less than 8 bytes.
- Issue #7633: In the decimal module, Context class methods (with the exception
of canonical and is_canonical) now accept instances of int and long wherever a
@@ -7709,7 +7709,7 @@
- Issue #7900: The getgroups(2) system call on MacOSX behaves rather oddly
compared to other unix systems. In particular, os.getgroups() does not reflect
- any changes made using os.setgroups() but basicly always returns the same
+ any changes made using os.setgroups() but basically always returns the same
information as the id command. os.getgroups() can now return more than 16
groups on MacOSX.
@@ -7728,7 +7728,7 @@
- Issue #1578269: Implement os.symlink for Windows 6.0+. Patch by Jason
R. Coombs.
-- In struct.pack, correctly propogate exceptions from computing the truth of an
+- In struct.pack, correctly propagate exceptions from computing the truth of an
object in the '?' format.
- Issue #9000: datetime.timezone objects now have eval-friendly repr.
@@ -8215,7 +8215,7 @@
added LIBS to OS X framework builds.
- Issue #5809: Specifying both --enable-framework and --enable-shared is
- an error. Configure now explicity tells you about this.
+ an error. Configure now explicitly tells you about this.
@@ -9209,7 +9209,7 @@
been backported to help facilitate transitions from 2.7 to 3.1.
- Issue #1885: distutils. When running sdist with --formats=tar,gztar
- the tar file was overriden by the gztar one.
+ the tar file was overridden by the gztar one.
- Issue #4863: distutils.mwerkscompiler has been removed.
@@ -10679,7 +10679,7 @@
- Removed the 'new' module.
-- Removed all types from the 'types' module that are easily accessable
+- Removed all types from the 'types' module that are easily accessible
through builtins.
@@ -20921,7 +20921,7 @@
* Tools/scripts/dutree.py:
During display, if EPIPE is raised, it's probably because a pager was
- killed. Discard the error in that case, but propogate it otherwise.
+ killed. Discard the error in that case, but propagate it otherwise.
Fri Mar 26 16:20:45 1999 Guido van Rossum <guido(a)eric.cnri.reston.va.us>
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -7862,8 +7862,8 @@
error message has been removed. Patch by Ram Rachum.
- Issue #18080: When building a C extension module on OS X, if the compiler
- is overriden with the CC environment variable, use the new compiler as
- the default for linking if LDSHARED is not also overriden. This restores
+ is overridden with the CC environment variable, use the new compiler as
+ the default for linking if LDSHARED is not also overridden. This restores
Distutils behavior introduced in 3.2.3 and inadvertently dropped in 3.3.0.
- Issue #18113: Fixed a refcount leak in the curses.panel module's
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -1071,7 +1071,7 @@
minutes = divmod(seconds, 60, &seconds);
hours = divmod(minutes, 60, &minutes);
assert(seconds == 0);
- /* XXX ignore sub-minute data, curently not allowed. */
+ /* XXX ignore sub-minute data, currently not allowed. */
PyOS_snprintf(buf, buflen, "%c%02d%s%02d", sign, hours, sep, minutes);
return 0;
@@ -3305,7 +3305,7 @@
Py_DECREF(offset);
minutes = divmod(seconds, 60, &seconds);
hours = divmod(minutes, 60, &minutes);
- /* XXX ignore sub-minute data, curently not allowed. */
+ /* XXX ignore sub-minute data, currently not allowed. */
assert(seconds == 0);
return PyUnicode_FromFormat("UTC%c%02d:%02d", sign, hours, minutes);
}
diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c
--- a/Modules/_lzmamodule.c
+++ b/Modules/_lzmamodule.c
@@ -701,7 +701,7 @@
check: int(c_default="-1") = unspecified
The integrity check to use. For FORMAT_XZ, the default
- is CHECK_CRC64. FORMAT_ALONE and FORMAT_RAW do not suport integrity
+ is CHECK_CRC64. FORMAT_ALONE and FORMAT_RAW do not support integrity
checks; for these formats, check must be omitted, or be CHECK_NONE.
preset: object = None
diff --git a/Modules/ld_so_aix.in b/Modules/ld_so_aix.in
--- a/Modules/ld_so_aix.in
+++ b/Modules/ld_so_aix.in
@@ -12,7 +12,7 @@
#
# ARGUMENTS: Same as for "ld". The following arguments are processed
# or supplied by this script (those marked with an asterisk
-# can be overriden from command line):
+# can be overridden from command line):
#
# Argument Default value
# (*) -o [OutputFileName] -o shr.o
@@ -85,7 +85,7 @@
fi
# Default import file for Python
-# Can be overriden by providing a -bI: argument.
+# Can be overridden by providing a -bI: argument.
impfile="./python.exp"
# Parse arguments
@@ -156,7 +156,7 @@
fi
# Default entry symbol for Python modules = init[modulename]
-# Can be overriden by providing a -e argument.
+# Can be overridden by providing a -e argument.
if test -z "$entry"; then
entry=PyInit_`echo $filename | sed "s/module.*//"`
fi
diff --git a/Modules/readline.c b/Modules/readline.c
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -1092,7 +1092,7 @@
#ifndef __APPLE__
if (!isatty(STDOUT_FILENO)) {
- /* Issue #19884: stdout is no a terminal. Disable meta modifier
+ /* Issue #19884: stdout is not a terminal. Disable meta modifier
keys to not write the ANSI sequence "\033[1034h" into stdout. On
terminals supporting 8 bit characters like TERM=xterm-256color
(which is now the default Fedora since Fedora 18), the meta key is
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -870,7 +870,7 @@
solution, given __new__ takes a variable number of arguments,
is to defer arg parsing and initialization to __init__.
- But when __new__ is overriden as well, it should call our __new__
+ But when __new__ is overridden as well, it should call our __new__
with the right arguments.
(see http://bugs.python.org/issue12555#msg148829 )
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -9492,7 +9492,7 @@
PyUnicode_GET_LENGTH(substring) *
PyUnicode_KIND(substring));
}
- /* otherwise we have to compare each character by first accesing it */
+ /* otherwise we have to compare each character by first accessing it */
else {
/* We do not need to compare 0 and len(substring)-1 because
the if statement above ensured already that they are equal
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -768,7 +768,7 @@
# In every directory on the search path search for a dynamic
# library and then a static library, instead of first looking
# for dynamic libraries on the entire path.
- # This way a staticly linked custom readline gets picked up
+ # This way a statically linked custom readline gets picked up
# before the (possibly broken) dynamic library in /usr/lib.
readline_extra_link_args = ('-Wl,-search_paths_first',)
else:
@@ -1622,7 +1622,7 @@
# --with-tcltk-libs="-L/path/to/tcllibs -ltclm.n \
# -L/path/to/tklibs -ltkm.n"
#
- # These values can also be specified or overriden via make:
+ # These values can also be specified or overridden via make:
# make TCLTK_INCLUDES="..." TCLTK_LIBS="..."
#
# This can be useful for building and testing tkinter with multiple
--
Repository URL: https://hg.python.org/cpython
1
0

cpython (3.5): Issue #27171: Fix typos in documentation, comments, and test function names
by martin.panter June 2, 2016
by martin.panter June 2, 2016
June 2, 2016
https://hg.python.org/cpython/rev/ce31ee3b1e69
changeset: 101594:ce31ee3b1e69
branch: 3.5
parent: 101591:c13198a2007e
user: Martin Panter <vadmium+py(a)gmail.com>
date: Thu Jun 02 10:07:09 2016 +0000
summary:
Issue #27171: Fix typos in documentation, comments, and test function names
files:
Include/pymacconfig.h | 2 +-
Lib/_osx_support.py | 12 +++++-----
Lib/_pydecimal.py | 2 +-
Lib/_pyio.py | 2 +-
Lib/distutils/tests/test_build_ext.py | 2 +-
Lib/idlelib/AutoComplete.py | 2 +-
Lib/idlelib/MultiCall.py | 2 +-
Lib/idlelib/rpc.py | 2 +-
Lib/pathlib.py | 2 +-
Lib/pdb.py | 2 +-
Lib/random.py | 2 +-
Lib/site.py | 4 +-
Lib/test/test_bigmem.py | 2 +-
Lib/test/test_email/test_policy.py | 2 +-
Lib/test/test_module.py | 2 +-
Lib/test/test_pep3151.py | 6 ++--
Lib/test/test_random.py | 2 +-
Lib/test/test_socket.py | 2 +-
Lib/test/test_sys_setprofile.py | 2 +-
Lib/tkinter/__init__.py | 2 +-
Lib/unittest/suite.py | 2 +-
Misc/HISTORY | 18 +++++++-------
Misc/NEWS | 4 +-
Modules/_datetimemodule.c | 4 +-
Modules/_lzmamodule.c | 2 +-
Modules/ld_so_aix.in | 6 ++--
Modules/readline.c | 2 +-
Objects/exceptions.c | 2 +-
Objects/unicodeobject.c | 2 +-
setup.py | 4 +-
30 files changed, 51 insertions(+), 51 deletions(-)
diff --git a/Include/pymacconfig.h b/Include/pymacconfig.h
--- a/Include/pymacconfig.h
+++ b/Include/pymacconfig.h
@@ -66,7 +66,7 @@
* Therefore surpress the toolbox-glue in 64-bit mode.
*/
- /* In 64-bit mode setpgrp always has no argments, in 32-bit
+ /* In 64-bit mode setpgrp always has no arguments, in 32-bit
* mode that depends on the compilation environment
*/
# undef SETPGRP_HAVE_ARG
diff --git a/Lib/_osx_support.py b/Lib/_osx_support.py
--- a/Lib/_osx_support.py
+++ b/Lib/_osx_support.py
@@ -157,7 +157,7 @@
# gcc-4.2 is either not present, or a copy of 'llvm-gcc' that
# miscompiles Python.
- # skip checks if the compiler was overriden with a CC env variable
+ # skip checks if the compiler was overridden with a CC env variable
if 'CC' in os.environ:
return _config_vars
@@ -193,7 +193,7 @@
if cc != oldcc:
# Found a replacement compiler.
# Modify config vars using new compiler, if not already explicitly
- # overriden by an env variable, preserving additional arguments.
+ # overridden by an env variable, preserving additional arguments.
for cv in _COMPILER_CONFIG_VARS:
if cv in _config_vars and cv not in os.environ:
cv_split = _config_vars[cv].split()
@@ -207,7 +207,7 @@
"""Remove all universal build arguments from config vars"""
for cv in _UNIVERSAL_CONFIG_VARS:
- # Do not alter a config var explicitly overriden by env var
+ # Do not alter a config var explicitly overridden by env var
if cv in _config_vars and cv not in os.environ:
flags = _config_vars[cv]
flags = re.sub('-arch\s+\w+\s', ' ', flags, re.ASCII)
@@ -228,7 +228,7 @@
# build extensions on OSX 10.7 and later with the prebuilt
# 32-bit installer on the python.org website.
- # skip checks if the compiler was overriden with a CC env variable
+ # skip checks if the compiler was overridden with a CC env variable
if 'CC' in os.environ:
return _config_vars
@@ -244,7 +244,7 @@
# across Xcode and compiler versions, there is no reliable way
# to be sure why it failed. Assume here it was due to lack of
# PPC support and remove the related '-arch' flags from each
- # config variables not explicitly overriden by an environment
+ # config variables not explicitly overridden by an environment
# variable. If the error was for some other reason, we hope the
# failure will show up again when trying to compile an extension
# module.
@@ -292,7 +292,7 @@
sdk = m.group(1)
if not os.path.exists(sdk):
for cv in _UNIVERSAL_CONFIG_VARS:
- # Do not alter a config var explicitly overriden by env var
+ # Do not alter a config var explicitly overridden by env var
if cv in _config_vars and cv not in os.environ:
flags = _config_vars[cv]
flags = re.sub(r'-isysroot\s+\S+(?:\s|$)', ' ', flags)
diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py
--- a/Lib/_pydecimal.py
+++ b/Lib/_pydecimal.py
@@ -1102,7 +1102,7 @@
def __pos__(self, context=None):
"""Returns a copy, unless it is a sNaN.
- Rounds the number (if more then precision digits)
+ Rounds the number (if more than precision digits)
"""
if self._is_special:
ans = self._check_nans(context=context)
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -1043,7 +1043,7 @@
break
avail += len(chunk)
chunks.append(chunk)
- # n is more then avail only when an EOF occurred or when
+ # n is more than avail only when an EOF occurred or when
# read() would have blocked.
n = min(n, avail)
out = b"".join(chunks)
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -279,7 +279,7 @@
def test_compiler_option(self):
# cmd.compiler is an option and
- # should not be overriden by a compiler instance
+ # should not be overridden by a compiler instance
# when the command is run
dist = Distribution()
cmd = self.build_ext(dist)
diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/AutoComplete.py
--- a/Lib/idlelib/AutoComplete.py
+++ b/Lib/idlelib/AutoComplete.py
@@ -1,6 +1,6 @@
"""AutoComplete.py - An IDLE extension for automatically completing names.
-This extension can complete either attribute names of file names. It can pop
+This extension can complete either attribute names or file names. It can pop
a window with all available names, for the user to select from.
"""
import os
diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/MultiCall.py
--- a/Lib/idlelib/MultiCall.py
+++ b/Lib/idlelib/MultiCall.py
@@ -111,7 +111,7 @@
raise
# An int in range(1 << len(_modifiers)) represents a combination of modifiers
-# (if the least significent bit is on, _modifiers[0] is on, and so on).
+# (if the least significant bit is on, _modifiers[0] is on, and so on).
# _state_subsets gives for each combination of modifiers, or *state*,
# a list of the states which are a subset of it. This list is ordered by the
# number of modifiers is the state - the most specific state comes first.
diff --git a/Lib/idlelib/rpc.py b/Lib/idlelib/rpc.py
--- a/Lib/idlelib/rpc.py
+++ b/Lib/idlelib/rpc.py
@@ -1,4 +1,4 @@
-"""RPC Implemention, originally written for the Python Idle IDE
+"""RPC Implementation, originally written for the Python Idle IDE
For security reasons, GvR requested that Idle's Python execution server process
connect to the Idle process, which listens for the connection. Since Idle has
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -674,7 +674,7 @@
return cls._flavour.join(parts)
def _init(self):
- # Overriden in concrete Path
+ # Overridden in concrete Path
pass
def _make_child(self, args):
diff --git a/Lib/pdb.py b/Lib/pdb.py
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -52,7 +52,7 @@
directory, it is read in and executed as if it had been typed at the
debugger prompt. This is particularly useful for aliases. If both
files exist, the one in the home directory is read first and aliases
-defined there can be overriden by the local file.
+defined there can be overridden by the local file.
Aside from aliases, the debugger is not directly programmable; but it
is implemented as a class from which you can derive your own debugger
diff --git a/Lib/random.py b/Lib/random.py
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -231,7 +231,7 @@
while r >= n:
r = getrandbits(k)
return r
- # There's an overriden random() method but no new getrandbits() method,
+ # There's an overridden random() method but no new getrandbits() method,
# so we can only use random() from here.
if n >= maxsize:
_warn("Underlying random() generator does not supply \n"
diff --git a/Lib/site.py b/Lib/site.py
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -59,7 +59,7 @@
omitted because it is not mentioned in either path configuration file.
The readline module is also automatically configured to enable
-completion for systems that support it. This can be overriden in
+completion for systems that support it. This can be overridden in
sitecustomize, usercustomize or PYTHONSTARTUP.
After these operations, an attempt is made to import a module
@@ -379,7 +379,7 @@
If the readline module can be imported, the hook will set the Tab key
as completion key and register ~/.python_history as history file.
- This can be overriden in the sitecustomize or usercustomize module,
+ This can be overridden in the sitecustomize or usercustomize module,
or in a PYTHONSTARTUP file.
"""
def register_readline():
diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py
--- a/Lib/test/test_bigmem.py
+++ b/Lib/test/test_bigmem.py
@@ -737,7 +737,7 @@
finally:
r = s = None
- # The original test_translate is overriden here, so as to get the
+ # The original test_translate is overridden here, so as to get the
# correct size estimate: str.translate() uses an intermediate Py_UCS4
# representation.
diff --git a/Lib/test/test_email/test_policy.py b/Lib/test/test_email/test_policy.py
--- a/Lib/test/test_email/test_policy.py
+++ b/Lib/test/test_email/test_policy.py
@@ -177,7 +177,7 @@
with self.assertRaisesRegex(self.MyDefect, "the telly is broken"):
self.MyPolicy(raise_on_defect=True).handle_defect(foo, defect)
- def test_overriden_register_defect_works(self):
+ def test_overridden_register_defect_works(self):
foo = self.MyObj()
defect1 = self.MyDefect("one")
my_policy = self.MyPolicy()
diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py
--- a/Lib/test/test_module.py
+++ b/Lib/test/test_module.py
@@ -227,7 +227,7 @@
b"len = len",
b"shutil.rmtree = rmtree"})
- def test_descriptor_errors_propogate(self):
+ def test_descriptor_errors_propagate(self):
class Descr:
def __get__(self, o, t):
raise RuntimeError
diff --git a/Lib/test/test_pep3151.py b/Lib/test/test_pep3151.py
--- a/Lib/test/test_pep3151.py
+++ b/Lib/test/test_pep3151.py
@@ -164,7 +164,7 @@
e = SubOSError(EEXIST, "Bad file descriptor")
self.assertIs(type(e), SubOSError)
- def test_init_overriden(self):
+ def test_init_overridden(self):
e = SubOSErrorWithInit("some message", "baz")
self.assertEqual(e.bar, "baz")
self.assertEqual(e.args, ("some message",))
@@ -174,7 +174,7 @@
self.assertEqual(e.bar, "baz")
self.assertEqual(e.args, ("some message",))
- def test_new_overriden(self):
+ def test_new_overridden(self):
e = SubOSErrorWithNew("some message", "baz")
self.assertEqual(e.baz, "baz")
self.assertEqual(e.args, ("some message",))
@@ -184,7 +184,7 @@
self.assertEqual(e.baz, "baz")
self.assertEqual(e.args, ("some message",))
- def test_init_new_overriden(self):
+ def test_init_new_overridden(self):
e = SubOSErrorCombinedInitFirst("some message", "baz")
self.assertEqual(e.bar, "baz")
self.assertEqual(e.baz, "baz")
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -494,7 +494,7 @@
self.assertTrue(2**k > n > 2**(k-1)) # note the stronger assertion
@unittest.mock.patch('random.Random.random')
- def test_randbelow_overriden_random(self, random_mock):
+ def test_randbelow_overridden_random(self, random_mock):
# Random._randbelow() can only use random() when the built-in one
# has been overridden but no new getrandbits() method was supplied.
random_mock.side_effect = random.SystemRandom().random
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1304,7 +1304,7 @@
# socket.gethostbyaddr('испытание.python.org')
def check_sendall_interrupted(self, with_timeout):
- # socketpair() is not stricly required, but it makes things easier.
+ # socketpair() is not strictly required, but it makes things easier.
if not hasattr(signal, 'alarm') or not hasattr(socket, 'socketpair'):
self.skipTest("signal.alarm and socket.socketpair required for this test")
# Our signal handlers clobber the C errno by calling a math function
diff --git a/Lib/test/test_sys_setprofile.py b/Lib/test/test_sys_setprofile.py
--- a/Lib/test/test_sys_setprofile.py
+++ b/Lib/test/test_sys_setprofile.py
@@ -164,7 +164,7 @@
(1, 'return', g_ident),
])
- def test_exception_propogation(self):
+ def test_exception_propagation(self):
def f(p):
1/0
def g(p):
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -3141,7 +3141,7 @@
"""Creates a peer text widget with the given newPathName, and any
optional standard configuration options. By default the peer will
have the same start and end line as the parent widget, but
- these can be overriden with the standard configuration options."""
+ these can be overridden with the standard configuration options."""
self.tk.call(self._w, 'peer', 'create', newPathName,
*self._options(cnf, kw))
def peer_names(self): # new in Tk 8.5
diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py
--- a/Lib/unittest/suite.py
+++ b/Lib/unittest/suite.py
@@ -71,7 +71,7 @@
try:
test = self._tests[index]
except TypeError:
- # support for suite implementations that have overriden self._tests
+ # support for suite implementations that have overridden self._tests
pass
else:
# Some unittest tests add non TestCase/TestSuite objects to
diff --git a/Misc/HISTORY b/Misc/HISTORY
--- a/Misc/HISTORY
+++ b/Misc/HISTORY
@@ -1834,7 +1834,7 @@
objects. Initial patch by Matthias Troffaes.
- Fix OSError.__init__ and OSError.__new__ so that each of them can be
- overriden and take additional arguments (followup to issue #12555).
+ overridden and take additional arguments (followup to issue #12555).
- Fix the fix for issue #12149: it was incorrect, although it had the side
effect of appearing to resolve the issue. Thanks to Mark Shannon for
@@ -2053,7 +2053,7 @@
given, produce an informative error message which includes the name(s) of the
missing arguments.
-- Issue #12370: Fix super with no arguments when __class__ is overriden in the
+- Issue #12370: Fix super with no arguments when __class__ is overridden in the
class body.
- Issue #12084: os.stat on Windows now works properly with relative symbolic
@@ -7273,7 +7273,7 @@
messages parsed by email.Parser.HeaderParser.
- Issue #7361: Importlib was not properly checking the number of bytes in
- bytecode file when it was less then 8 bytes.
+ bytecode file when it was less than 8 bytes.
- Issue #7633: In the decimal module, Context class methods (with the exception
of canonical and is_canonical) now accept instances of int and long wherever a
@@ -7709,7 +7709,7 @@
- Issue #7900: The getgroups(2) system call on MacOSX behaves rather oddly
compared to other unix systems. In particular, os.getgroups() does not reflect
- any changes made using os.setgroups() but basicly always returns the same
+ any changes made using os.setgroups() but basically always returns the same
information as the id command. os.getgroups() can now return more than 16
groups on MacOSX.
@@ -7728,7 +7728,7 @@
- Issue #1578269: Implement os.symlink for Windows 6.0+. Patch by Jason
R. Coombs.
-- In struct.pack, correctly propogate exceptions from computing the truth of an
+- In struct.pack, correctly propagate exceptions from computing the truth of an
object in the '?' format.
- Issue #9000: datetime.timezone objects now have eval-friendly repr.
@@ -8215,7 +8215,7 @@
added LIBS to OS X framework builds.
- Issue #5809: Specifying both --enable-framework and --enable-shared is
- an error. Configure now explicity tells you about this.
+ an error. Configure now explicitly tells you about this.
@@ -9209,7 +9209,7 @@
been backported to help facilitate transitions from 2.7 to 3.1.
- Issue #1885: distutils. When running sdist with --formats=tar,gztar
- the tar file was overriden by the gztar one.
+ the tar file was overridden by the gztar one.
- Issue #4863: distutils.mwerkscompiler has been removed.
@@ -10679,7 +10679,7 @@
- Removed the 'new' module.
-- Removed all types from the 'types' module that are easily accessable
+- Removed all types from the 'types' module that are easily accessible
through builtins.
@@ -20921,7 +20921,7 @@
* Tools/scripts/dutree.py:
During display, if EPIPE is raised, it's probably because a pager was
- killed. Discard the error in that case, but propogate it otherwise.
+ killed. Discard the error in that case, but propagate it otherwise.
Fri Mar 26 16:20:45 1999 Guido van Rossum <guido(a)eric.cnri.reston.va.us>
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -7141,8 +7141,8 @@
error message has been removed. Patch by Ram Rachum.
- Issue #18080: When building a C extension module on OS X, if the compiler
- is overriden with the CC environment variable, use the new compiler as
- the default for linking if LDSHARED is not also overriden. This restores
+ is overridden with the CC environment variable, use the new compiler as
+ the default for linking if LDSHARED is not also overridden. This restores
Distutils behavior introduced in 3.2.3 and inadvertently dropped in 3.3.0.
- Issue #18113: Fixed a refcount leak in the curses.panel module's
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -1073,7 +1073,7 @@
minutes = divmod(seconds, 60, &seconds);
hours = divmod(minutes, 60, &minutes);
assert(seconds == 0);
- /* XXX ignore sub-minute data, curently not allowed. */
+ /* XXX ignore sub-minute data, currently not allowed. */
PyOS_snprintf(buf, buflen, "%c%02d%s%02d", sign, hours, sep, minutes);
return 0;
@@ -3304,7 +3304,7 @@
Py_DECREF(offset);
minutes = divmod(seconds, 60, &seconds);
hours = divmod(minutes, 60, &minutes);
- /* XXX ignore sub-minute data, curently not allowed. */
+ /* XXX ignore sub-minute data, currently not allowed. */
assert(seconds == 0);
return PyUnicode_FromFormat("UTC%c%02d:%02d", sign, hours, minutes);
}
diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c
--- a/Modules/_lzmamodule.c
+++ b/Modules/_lzmamodule.c
@@ -705,7 +705,7 @@
check: int(c_default="-1") = unspecified
The integrity check to use. For FORMAT_XZ, the default
- is CHECK_CRC64. FORMAT_ALONE and FORMAT_RAW do not suport integrity
+ is CHECK_CRC64. FORMAT_ALONE and FORMAT_RAW do not support integrity
checks; for these formats, check must be omitted, or be CHECK_NONE.
preset: object = None
diff --git a/Modules/ld_so_aix.in b/Modules/ld_so_aix.in
--- a/Modules/ld_so_aix.in
+++ b/Modules/ld_so_aix.in
@@ -12,7 +12,7 @@
#
# ARGUMENTS: Same as for "ld". The following arguments are processed
# or supplied by this script (those marked with an asterisk
-# can be overriden from command line):
+# can be overridden from command line):
#
# Argument Default value
# (*) -o [OutputFileName] -o shr.o
@@ -85,7 +85,7 @@
fi
# Default import file for Python
-# Can be overriden by providing a -bI: argument.
+# Can be overridden by providing a -bI: argument.
impfile="./python.exp"
# Parse arguments
@@ -156,7 +156,7 @@
fi
# Default entry symbol for Python modules = init[modulename]
-# Can be overriden by providing a -e argument.
+# Can be overridden by providing a -e argument.
if test -z "$entry"; then
entry=PyInit_`echo $filename | sed "s/module.*//"`
fi
diff --git a/Modules/readline.c b/Modules/readline.c
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -1075,7 +1075,7 @@
#ifndef __APPLE__
if (!isatty(STDOUT_FILENO)) {
- /* Issue #19884: stdout is no a terminal. Disable meta modifier
+ /* Issue #19884: stdout is not a terminal. Disable meta modifier
keys to not write the ANSI sequence "\033[1034h" into stdout. On
terminals supporting 8 bit characters like TERM=xterm-256color
(which is now the default Fedora since Fedora 18), the meta key is
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -876,7 +876,7 @@
solution, given __new__ takes a variable number of arguments,
is to defer arg parsing and initialization to __init__.
- But when __new__ is overriden as well, it should call our __new__
+ But when __new__ is overridden as well, it should call our __new__
with the right arguments.
(see http://bugs.python.org/issue12555#msg148829 )
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -9323,7 +9323,7 @@
PyUnicode_GET_LENGTH(substring) *
PyUnicode_KIND(substring));
}
- /* otherwise we have to compare each character by first accesing it */
+ /* otherwise we have to compare each character by first accessing it */
else {
/* We do not need to compare 0 and len(substring)-1 because
the if statement above ensured already that they are equal
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -768,7 +768,7 @@
# In every directory on the search path search for a dynamic
# library and then a static library, instead of first looking
# for dynamic libraries on the entire path.
- # This way a staticly linked custom readline gets picked up
+ # This way a statically linked custom readline gets picked up
# before the (possibly broken) dynamic library in /usr/lib.
readline_extra_link_args = ('-Wl,-search_paths_first',)
else:
@@ -1622,7 +1622,7 @@
# --with-tcltk-libs="-L/path/to/tcllibs -ltclm.n \
# -L/path/to/tklibs -ltkm.n"
#
- # These values can also be specified or overriden via make:
+ # These values can also be specified or overridden via make:
# make TCLTK_INCLUDES="..." TCLTK_LIBS="..."
#
# This can be useful for building and testing tkinter with multiple
--
Repository URL: https://hg.python.org/cpython
1
0

June 2, 2016
Results for project Python 2.7, build date 2016-06-02 02:49:08 +0000
commit: 98870f27d2ed
previous commit: 824d32436198
revision date: 2016-06-02 01:32:42 +0000
environment: Haswell-EP
cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB
mem: 128 GB
os: CentOS 7.1
kernel: Linux 3.10.0-229.4.2.el7.x86_64
Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc
from 2015-05-23 16:02:14+00:00
----------------------------------------------------------------------------------
benchmark relative change since change since current rev run
std_dev* last run baseline with PGO
----------------------------------------------------------------------------------
:-) django_v2 0.10% 0.14% 4.87% 5.99%
:-) pybench 0.16% 0.28% 6.14% 4.97%
:-( regex_v8 0.65% 0.11% -2.08% 10.69%
:-) nbody 0.14% 0.21% 9.28% 3.93%
:-| json_dump_v2 0.56% -0.67% 1.13% 13.03%
:-( normal_startup 1.90% -0.96% -5.93% 2.06%
:-) ssbench 0.20% 0.34% 2.57% 1.31%
----------------------------------------------------------------------------------
* Relative Standard Deviation (Standard Deviation/Average)
If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/neutral-benchmark-results-for-python-…
Note: Benchmark results for ssbench are measured in requests/second while all
other are measured in seconds.
Subject Label Legend:
Attributes are determined based on the performance evolution of the workloads
compared to the previous measurement iteration.
NEUTRAL: performance did not change by more than 1% for any workload
GOOD: performance improved by more than 1% for at least one workload and there
is no regression greater than 1%
BAD: performance dropped by more than 1% for at least one workload and there is
no improvement greater than 1%
UGLY: performance improved by more than 1% for at least one workload and also
dropped by more than 1% for at least one workload
Our lab does a nightly source pull and build of the Python project and measures
performance changes against the previous stable version and the previous nightly
measurement. This is provided as a service to the community so that quality
issues with current hardware can be identified quickly.
Intel technologies' features and benefits depend on system configuration and may
require enabled hardware, software or service activation. Performance varies
depending on system configuration.
1
0