Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Fully incorporate the code from Python 3.7.2 (#78)
Browse files Browse the repository at this point in the history
This is a full port, following the recipe in update_process.md. I've also tried to keep the recipe up to date and improved the automation (see tools/script). I haven't cleaned up the commits. As of #77 there are a few tests that sanity-check this (though it's far from a full test suite), and they're run by Travis-CI and AppVeyor.
  • Loading branch information
gvanrossum committed Jan 23, 2019
1 parent 0cae934 commit 156afcb
Show file tree
Hide file tree
Showing 53 changed files with 3,393 additions and 6,148 deletions.
3 changes: 0 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ environment:
matrix:
# For Python versions available on Appveyor, see
# http://www.appveyor.com/docs/installed-software#python
- PYTHON: "C:\\Python33"
- PYTHON: "C:\\Python33-x64"
DISTUTILS_USE_SDK: 1
- PYTHON: "C:\\Python34"
- PYTHON: "C:\\Python34-x64"
DISTUTILS_USE_SDK: 1
Expand Down
5 changes: 2 additions & 3 deletions ast27/Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,6 @@ ast_for_atom(struct compiling *c, const node *n)
case STRING: {
PyObject *kind, *str = parsestrplus(c, n);
const char *raw, *s = STR(CHILD(n, 0));
int quote = Py_CHARMASK(*s);
/* currently Python allows up to 2 string modifiers */
char *ch, s_kind[3] = {0, 0, 0};
ch = s_kind;
Expand All @@ -1519,7 +1518,7 @@ ast_for_atom(struct compiling *c, const node *n)
PyErr_Fetch(&type, &value, &tback);
errstr = PyObject_Str(value);
if (errstr) {
char *s = "";
const char *s = "";
char buf[128];
s = _PyUnicode_AsString(errstr);
PyOS_snprintf(buf, sizeof(buf), "(unicode error) %s", s);
Expand Down Expand Up @@ -2190,7 +2189,7 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
keyword_ty kw;
identifier key;
int k;
char *tmp;
const char *tmp;

/* CHILD(ch, 0) is test, but must be an identifier? */
e = ast_for_expr(c, CHILD(ch, 0));
Expand Down
11 changes: 7 additions & 4 deletions ast3/Custom/typed_ast.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Python.h"
#include "Python-ast.h"
#include "compile.h"
#include "compile-ast3.h"
#include "node.h"
#include "grammar.h"
#include "token.h"
Expand Down Expand Up @@ -222,10 +222,13 @@ string_object_to_c_ast(const char *s, PyObject *filename, int start,
PyCompilerFlags localflags;
perrdetail err;
int iflags = PARSER_FLAGS(flags);
node *n;

node *n = Ta3Parser_ParseStringObject(s, filename,
&_Ta3Parser_Grammar, start, &err,
&iflags);
if (feature_version >= 7)
iflags |= PyPARSE_ASYNC_ALWAYS;
n = Ta3Parser_ParseStringObject(s, filename,
&_Ta3Parser_Grammar, start, &err,
&iflags);
if (flags == NULL) {
localflags.cf_flags = 0;
flags = &localflags;
Expand Down
12 changes: 3 additions & 9 deletions ast3/Grammar/Grammar
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
# Grammar for Python

# Note: Changing the grammar specified in this file will most likely
# require corresponding changes in the parser module
# (../Modules/parsermodule.c). If you can't make the changes to
# that module yourself, please co-ordinate the required changes
# with someone who can; ask around on python-dev for help. Fred
# Drake <fdrake@acm.org> will probably be listening there.

# NOTE WELL: You should also follow all the steps listed at
# https://docs.python.org/devguide/grammar.html
# https://devguide.python.org/grammar/

# Start symbols for the grammar:
# single_input is a single interactive statement;
Expand Down Expand Up @@ -150,7 +143,8 @@ argument: ( test [comp_for] |
'*' test )

comp_iter: comp_for | comp_if
comp_for: [ASYNC] 'for' exprlist 'in' or_test [comp_iter]
sync_comp_for: 'for' exprlist 'in' or_test [comp_iter]
comp_for: [ASYNC] sync_comp_for
comp_if: 'if' test_nocond [comp_iter]

# not used in grammar, but may appear in "node" passed from Parser to Compiler
Expand Down
Loading

0 comments on commit 156afcb

Please sign in to comment.