mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	bpo-30406: Make async and await proper keywords (#1669)
Per PEP 492, 'async' and 'await' should become proper keywords in 3.7.
This commit is contained in:
		
							parent
							
								
									2084b30e54
								
							
						
					
					
						commit
						ac317700ce
					
				
					 22 changed files with 419 additions and 623 deletions
				
			
		| 
						 | 
				
			
			@ -394,20 +394,14 @@ def async(): pass
 | 
			
		|||
        ]
 | 
			
		||||
 | 
			
		||||
        for code in samples:
 | 
			
		||||
            with self.subTest(code=code), self.assertWarnsRegex(
 | 
			
		||||
                    DeprecationWarning,
 | 
			
		||||
                    "'await' will become reserved keywords"):
 | 
			
		||||
            with self.subTest(code=code), self.assertRaises(SyntaxError):
 | 
			
		||||
                compile(code, "<test>", "exec")
 | 
			
		||||
 | 
			
		||||
    def test_badsyntax_3(self):
 | 
			
		||||
        with self.assertRaises(DeprecationWarning):
 | 
			
		||||
            with warnings.catch_warnings():
 | 
			
		||||
                warnings.simplefilter("error")
 | 
			
		||||
                compile("async = 1", "<test>", "exec")
 | 
			
		||||
 | 
			
		||||
    def test_goodsyntax_1(self):
 | 
			
		||||
        # Tests for issue 24619
 | 
			
		||||
        with self.assertRaises(SyntaxError):
 | 
			
		||||
            compile("async = 1", "<test>", "exec")
 | 
			
		||||
 | 
			
		||||
    def test_badsyntax_4(self):
 | 
			
		||||
        samples = [
 | 
			
		||||
            '''def foo(await):
 | 
			
		||||
                async def foo(): pass
 | 
			
		||||
| 
						 | 
				
			
			@ -454,14 +448,8 @@ async def bar(): return await_
 | 
			
		|||
        ]
 | 
			
		||||
 | 
			
		||||
        for code in samples:
 | 
			
		||||
            with self.subTest(code=code):
 | 
			
		||||
                loc = {}
 | 
			
		||||
 | 
			
		||||
                with warnings.catch_warnings():
 | 
			
		||||
                    warnings.simplefilter("ignore")
 | 
			
		||||
                    exec(code, loc, loc)
 | 
			
		||||
 | 
			
		||||
                self.assertEqual(loc['foo'](10), 11)
 | 
			
		||||
            with self.subTest(code=code), self.assertRaises(SyntaxError):
 | 
			
		||||
                compile(code, "<test>", "exec")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TokenizerRegrTest(unittest.TestCase):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue