File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -146,6 +146,12 @@ def test_snippets(self):
146146 self .assertEquals (to_tuple (ast_tree ), o )
147147 self ._assert_order (ast_tree , (0 , 0 ))
148148
149+ def test_slice (self ):
150+ slc = ast .parse ("x[::]" ).body [0 ].value .slice
151+ self .assertIsNone (slc .upper )
152+ self .assertIsNone (slc .lower )
153+ self .assertIsNone (slc .step )
154+
149155 def test_nodeclasses (self ):
150156 x = ast .BinOp (1 , 2 , 3 , lineno = 0 )
151157 self .assertEquals (x .left , 1 )
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
1212Core and Builtins
1313-----------------
1414
15+ - In the slice AST type, the step field will always be None if a step expression
16+ is not specified.
17+
1518- Issue #4547: When debugging a very large function, it was not always
1619 possible to update the lineno attribute of the current frame.
1720
Original file line number Diff line number Diff line change @@ -1468,14 +1468,7 @@ ast_for_slice(struct compiling *c, const node *n)
14681468
14691469 ch = CHILD (n , NCH (n ) - 1 );
14701470 if (TYPE (ch ) == sliceop ) {
1471- if (NCH (ch ) == 1 ) {
1472- /* No expression, so step is None */
1473- ch = CHILD (ch , 0 );
1474- step = Name (new_identifier ("None" , c -> c_arena ), Load ,
1475- LINENO (ch ), ch -> n_col_offset , c -> c_arena );
1476- if (!step )
1477- return NULL ;
1478- } else {
1471+ if (NCH (ch ) != 1 ) {
14791472 ch = CHILD (ch , 1 );
14801473 if (TYPE (ch ) == test ) {
14811474 step = ast_for_expr (c , ch );
You can’t perform that action at this time.
0 commit comments