[Python-checkins] bpo-31464: asdl_c.py no longer emits trailing spaces in Python-ast.h. (#3568)

Benjamin Peterson webhook-mailer at python.org
Thu Sep 14 23:28:27 EDT 2017


https://github.com/python/cpython/commit/5d84cb368c0c3e475c25171c302068c4dfc3e396
commit: 5d84cb368c0c3e475c25171c302068c4dfc3e396
branch: master
author: Serhiy Storchaka <storchaka at gmail.com>
committer: Benjamin Peterson <benjamin at python.org>
date: 2017年09月14日T20:28:22-07:00
summary:
bpo-31464: asdl_c.py no longer emits trailing spaces in Python-ast.h. (#3568)
files:
M Include/Python-ast.h
M Parser/asdl_c.py
diff --git a/Include/Python-ast.h b/Include/Python-ast.h
index d4a4ba3ab27..26dfef8fe15 100644
--- a/Include/Python-ast.h
+++ b/Include/Python-ast.h
@@ -48,19 +48,19 @@ struct _mod {
 asdl_seq *body;
 string docstring;
 } Module;
- 
+
 struct {
 asdl_seq *body;
 } Interactive;
- 
+
 struct {
 expr_ty body;
 } Expression;
- 
+
 struct {
 asdl_seq *body;
 } Suite;
- 
+
 } v;
 };
 
@@ -83,7 +83,7 @@ struct _stmt {
 expr_ty returns;
 string docstring;
 } FunctionDef;
- 
+
 struct {
 identifier name;
 arguments_ty args;
@@ -92,7 +92,7 @@ struct _stmt {
 expr_ty returns;
 string docstring;
 } AsyncFunctionDef;
- 
+
 struct {
 identifier name;
 asdl_seq *bases;
@@ -101,108 +101,108 @@ struct _stmt {
 asdl_seq *decorator_list;
 string docstring;
 } ClassDef;
- 
+
 struct {
 expr_ty value;
 } Return;
- 
+
 struct {
 asdl_seq *targets;
 } Delete;
- 
+
 struct {
 asdl_seq *targets;
 expr_ty value;
 } Assign;
- 
+
 struct {
 expr_ty target;
 operator_ty op;
 expr_ty value;
 } AugAssign;
- 
+
 struct {
 expr_ty target;
 expr_ty annotation;
 expr_ty value;
 int simple;
 } AnnAssign;
- 
+
 struct {
 expr_ty target;
 expr_ty iter;
 asdl_seq *body;
 asdl_seq *orelse;
 } For;
- 
+
 struct {
 expr_ty target;
 expr_ty iter;
 asdl_seq *body;
 asdl_seq *orelse;
 } AsyncFor;
- 
+
 struct {
 expr_ty test;
 asdl_seq *body;
 asdl_seq *orelse;
 } While;
- 
+
 struct {
 expr_ty test;
 asdl_seq *body;
 asdl_seq *orelse;
 } If;
- 
+
 struct {
 asdl_seq *items;
 asdl_seq *body;
 } With;
- 
+
 struct {
 asdl_seq *items;
 asdl_seq *body;
 } AsyncWith;
- 
+
 struct {
 expr_ty exc;
 expr_ty cause;
 } Raise;
- 
+
 struct {
 asdl_seq *body;
 asdl_seq *handlers;
 asdl_seq *orelse;
 asdl_seq *finalbody;
 } Try;
- 
+
 struct {
 expr_ty test;
 expr_ty msg;
 } Assert;
- 
+
 struct {
 asdl_seq *names;
 } Import;
- 
+
 struct {
 identifier module;
 asdl_seq *names;
 int level;
 } ImportFrom;
- 
+
 struct {
 asdl_seq *names;
 } Global;
- 
+
 struct {
 asdl_seq *names;
 } Nonlocal;
- 
+
 struct {
 expr_ty value;
 } Expr;
- 
+
 } v;
 int lineno;
 int col_offset;
@@ -224,145 +224,145 @@ struct _expr {
 boolop_ty op;
 asdl_seq *values;
 } BoolOp;
- 
+
 struct {
 expr_ty left;
 operator_ty op;
 expr_ty right;
 } BinOp;
- 
+
 struct {
 unaryop_ty op;
 expr_ty operand;
 } UnaryOp;
- 
+
 struct {
 arguments_ty args;
 expr_ty body;
 } Lambda;
- 
+
 struct {
 expr_ty test;
 expr_ty body;
 expr_ty orelse;
 } IfExp;
- 
+
 struct {
 asdl_seq *keys;
 asdl_seq *values;
 } Dict;
- 
+
 struct {
 asdl_seq *elts;
 } Set;
- 
+
 struct {
 expr_ty elt;
 asdl_seq *generators;
 } ListComp;
- 
+
 struct {
 expr_ty elt;
 asdl_seq *generators;
 } SetComp;
- 
+
 struct {
 expr_ty key;
 expr_ty value;
 asdl_seq *generators;
 } DictComp;
- 
+
 struct {
 expr_ty elt;
 asdl_seq *generators;
 } GeneratorExp;
- 
+
 struct {
 expr_ty value;
 } Await;
- 
+
 struct {
 expr_ty value;
 } Yield;
- 
+
 struct {
 expr_ty value;
 } YieldFrom;
- 
+
 struct {
 expr_ty left;
 asdl_int_seq *ops;
 asdl_seq *comparators;
 } Compare;
- 
+
 struct {
 expr_ty func;
 asdl_seq *args;
 asdl_seq *keywords;
 } Call;
- 
+
 struct {
 object n;
 } Num;
- 
+
 struct {
 string s;
 } Str;
- 
+
 struct {
 expr_ty value;
 int conversion;
 expr_ty format_spec;
 } FormattedValue;
- 
+
 struct {
 asdl_seq *values;
 } JoinedStr;
- 
+
 struct {
 bytes s;
 } Bytes;
- 
+
 struct {
 singleton value;
 } NameConstant;
- 
+
 struct {
 constant value;
 } Constant;
- 
+
 struct {
 expr_ty value;
 identifier attr;
 expr_context_ty ctx;
 } Attribute;
- 
+
 struct {
 expr_ty value;
 slice_ty slice;
 expr_context_ty ctx;
 } Subscript;
- 
+
 struct {
 expr_ty value;
 expr_context_ty ctx;
 } Starred;
- 
+
 struct {
 identifier id;
 expr_context_ty ctx;
 } Name;
- 
+
 struct {
 asdl_seq *elts;
 expr_context_ty ctx;
 } List;
- 
+
 struct {
 asdl_seq *elts;
 expr_context_ty ctx;
 } Tuple;
- 
+
 } v;
 int lineno;
 int col_offset;
@@ -377,15 +377,15 @@ struct _slice {
 expr_ty upper;
 expr_ty step;
 } Slice;
- 
+
 struct {
 asdl_seq *dims;
 } ExtSlice;
- 
+
 struct {
 expr_ty value;
 } Index;
- 
+
 } v;
 };
 
@@ -405,7 +405,7 @@ struct _excepthandler {
 identifier name;
 asdl_seq *body;
 } ExceptHandler;
- 
+
 } v;
 int lineno;
 int col_offset;
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index f6c3a661172..a43d2e7b834 100644
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -94,8 +94,9 @@ def emit(self, s, depth, reflow=True):
 else:
 lines = [s]
 for line in lines:
- line = (" " * TABSIZE * depth) + line + "\n"
- self.file.write(line)
+ if line:
+ line = (" " * TABSIZE * depth) + line
+ self.file.write(line + "\n")
 
 
 class TypeDefVisitor(EmitVisitor):


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /