mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	- Bug #1487966: Fix SystemError with conditional expression in assignment
Most of the test_syntax changes are just updating the numbers.
This commit is contained in:
		
							parent
							
								
									7a5fc28e81
								
							
						
					
					
						commit
						373f0a718c
					
				
					 4 changed files with 25 additions and 16 deletions
				
			
		|  | @ -86,13 +86,16 @@ | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: can't assign to operator (<doctest test.test_syntax[12]>, line 1) | SyntaxError: can't assign to operator (<doctest test.test_syntax[12]>, line 1) | ||||||
| 
 | 
 | ||||||
|  | >>> a if 1 else b = 1 | ||||||
|  | Traceback (most recent call last): | ||||||
|  | SyntaxError: can't assign to conditional expression (<doctest test.test_syntax[13]>, line 1) | ||||||
| 
 | 
 | ||||||
| From compiler_complex_args(): | From compiler_complex_args(): | ||||||
| 
 | 
 | ||||||
| >>> def f(None=1): | >>> def f(None=1): | ||||||
| ...     pass | ...     pass | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: assignment to None (<doctest test.test_syntax[13]>, line 1) | SyntaxError: assignment to None (<doctest test.test_syntax[14]>, line 1) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| From ast_for_arguments(): | From ast_for_arguments(): | ||||||
|  | @ -100,22 +103,22 @@ | ||||||
| >>> def f(x, y=1, z): | >>> def f(x, y=1, z): | ||||||
| ...     pass | ...     pass | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: non-default argument follows default argument (<doctest test.test_syntax[14]>, line 1) | SyntaxError: non-default argument follows default argument (<doctest test.test_syntax[15]>, line 1) | ||||||
| 
 | 
 | ||||||
| >>> def f(x, None): | >>> def f(x, None): | ||||||
| ...     pass | ...     pass | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: assignment to None (<doctest test.test_syntax[15]>, line 1) | SyntaxError: assignment to None (<doctest test.test_syntax[16]>, line 1) | ||||||
| 
 | 
 | ||||||
| >>> def f(*None): | >>> def f(*None): | ||||||
| ...     pass | ...     pass | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: assignment to None (<doctest test.test_syntax[16]>, line 1) | SyntaxError: assignment to None (<doctest test.test_syntax[17]>, line 1) | ||||||
| 
 | 
 | ||||||
| >>> def f(**None): | >>> def f(**None): | ||||||
| ...     pass | ...     pass | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: assignment to None (<doctest test.test_syntax[17]>, line 1) | SyntaxError: assignment to None (<doctest test.test_syntax[18]>, line 1) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| From ast_for_funcdef(): | From ast_for_funcdef(): | ||||||
|  | @ -123,7 +126,7 @@ | ||||||
| >>> def None(x): | >>> def None(x): | ||||||
| ...     pass | ...     pass | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: assignment to None (<doctest test.test_syntax[18]>, line 1) | SyntaxError: assignment to None (<doctest test.test_syntax[19]>, line 1) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| From ast_for_call(): | From ast_for_call(): | ||||||
|  | @ -135,7 +138,7 @@ | ||||||
| [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | ||||||
| >>> f(x for x in L, 1) | >>> f(x for x in L, 1) | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: Generator expression must be parenthesized if not sole argument (<doctest test.test_syntax[22]>, line 1) | SyntaxError: Generator expression must be parenthesized if not sole argument (<doctest test.test_syntax[23]>, line 1) | ||||||
| >>> f((x for x in L), 1) | >>> f((x for x in L), 1) | ||||||
| [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | ||||||
| 
 | 
 | ||||||
|  | @ -167,7 +170,7 @@ | ||||||
| ...   i244,  i245,  i246,  i247,  i248,  i249,  i250,  i251,  i252, | ...   i244,  i245,  i246,  i247,  i248,  i249,  i250,  i251,  i252, | ||||||
| ...   i253,  i254,  i255) | ...   i253,  i254,  i255) | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: more than 255 arguments (<doctest test.test_syntax[24]>, line 1) | SyntaxError: more than 255 arguments (<doctest test.test_syntax[25]>, line 1) | ||||||
| 
 | 
 | ||||||
| The actual error cases counts positional arguments, keyword arguments, | The actual error cases counts positional arguments, keyword arguments, | ||||||
| and generator expression arguments separately.  This test combines the | and generator expression arguments separately.  This test combines the | ||||||
|  | @ -201,37 +204,37 @@ | ||||||
| ...   (x for x in i244),  i245,  i246,  i247,  i248,  i249,  i250,  i251, | ...   (x for x in i244),  i245,  i246,  i247,  i248,  i249,  i250,  i251, | ||||||
| ...    i252=1, i253=1,  i254=1,  i255=1) | ...    i252=1, i253=1,  i254=1,  i255=1) | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: more than 255 arguments (<doctest test.test_syntax[25]>, line 1) | SyntaxError: more than 255 arguments (<doctest test.test_syntax[26]>, line 1) | ||||||
| 
 | 
 | ||||||
| >>> f(lambda x: x[0] = 3) | >>> f(lambda x: x[0] = 3) | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: lambda cannot contain assignment (<doctest test.test_syntax[26]>, line 1) | SyntaxError: lambda cannot contain assignment (<doctest test.test_syntax[27]>, line 1) | ||||||
| 
 | 
 | ||||||
| The grammar accepts any test (basically, any expression) in the | The grammar accepts any test (basically, any expression) in the | ||||||
| keyword slot of a call site.  Test a few different options. | keyword slot of a call site.  Test a few different options. | ||||||
| 
 | 
 | ||||||
| >>> f(x()=2) | >>> f(x()=2) | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: keyword can't be an expression (<doctest test.test_syntax[27]>, line 1) | SyntaxError: keyword can't be an expression (<doctest test.test_syntax[28]>, line 1) | ||||||
| >>> f(a or b=1) | >>> f(a or b=1) | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: keyword can't be an expression (<doctest test.test_syntax[28]>, line 1) | SyntaxError: keyword can't be an expression (<doctest test.test_syntax[29]>, line 1) | ||||||
| >>> f(x.y=1) | >>> f(x.y=1) | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: keyword can't be an expression (<doctest test.test_syntax[29]>, line 1) | SyntaxError: keyword can't be an expression (<doctest test.test_syntax[30]>, line 1) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| From ast_for_expr_stmt(): | From ast_for_expr_stmt(): | ||||||
| 
 | 
 | ||||||
| >>> (x for x in x) += 1 | >>> (x for x in x) += 1 | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: augmented assignment to generator expression not possible (<doctest test.test_syntax[30]>, line 1) | SyntaxError: augmented assignment to generator expression not possible (<doctest test.test_syntax[31]>, line 1) | ||||||
| >>> None += 1 | >>> None += 1 | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: assignment to None (<doctest test.test_syntax[31]>, line 1) | SyntaxError: assignment to None (<doctest test.test_syntax[32]>, line 1) | ||||||
| >>> f() += 1 | >>> f() += 1 | ||||||
| Traceback (most recent call last): | Traceback (most recent call last): | ||||||
| SyntaxError: illegal expression for augmented assignment (<doctest test.test_syntax[32]>, line 1) | SyntaxError: illegal expression for augmented assignment (<doctest test.test_syntax[33]>, line 1) | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
| import re | import re | ||||||
|  |  | ||||||
|  | @ -547,6 +547,7 @@ Dietmar Schwertberger | ||||||
| Barry Scott | Barry Scott | ||||||
| Steven Scott | Steven Scott | ||||||
| Nick Seidenman | Nick Seidenman | ||||||
|  | Žiga Seilnach | ||||||
| Fred Sells | Fred Sells | ||||||
| Jiwon Seo | Jiwon Seo | ||||||
| Denis Severson | Denis Severson | ||||||
|  |  | ||||||
|  | @ -12,6 +12,8 @@ What's New in Python 2.5 alpha 3? | ||||||
| Core and builtins | Core and builtins | ||||||
| ----------------- | ----------------- | ||||||
| 
 | 
 | ||||||
|  | - Bug #1487966: Fix SystemError with conditional expression in assignment | ||||||
|  | 
 | ||||||
| - WindowsError now has two error code attributes: errno, which carries | - WindowsError now has two error code attributes: errno, which carries | ||||||
|   the error values from errno.h, and winerror, which carries the error |   the error values from errno.h, and winerror, which carries the error | ||||||
|   values from winerror.h. Previous versions put the winerror.h values |   values from winerror.h. Previous versions put the winerror.h values | ||||||
|  |  | ||||||
|  | @ -401,6 +401,9 @@ set_context(expr_ty e, expr_context_ty ctx, const node *n) | ||||||
|         case Repr_kind: |         case Repr_kind: | ||||||
|             expr_name = "repr"; |             expr_name = "repr"; | ||||||
|             break; |             break; | ||||||
|  |         case IfExp_kind: | ||||||
|  |             expr_name = "conditional expression"; | ||||||
|  |             break; | ||||||
|         default: |         default: | ||||||
|             PyErr_Format(PyExc_SystemError,  |             PyErr_Format(PyExc_SystemError,  | ||||||
|                          "unexpected expression in assignment %d (line %d)",  |                          "unexpected expression in assignment %d (line %d)",  | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Neal Norwitz
						Neal Norwitz