From 91f6c75da20ff25ddbc41aadf853001206cc02da 2012-07-08 16:37:01 From: Aaron Meurer Date: 2012-07-08 16:37:01 Subject: [PATCH] Don't dedent on yield, as yield doesn't always end a block --- diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index 8b7a21f..77e6c1d 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -115,8 +115,6 @@ dedent_re = re.compile('|'.join([ r'^\s+raise\([^\)]*\).*$', # wacky raise with immediate open paren r'^\s+return(\s.*)?$', # normal return (+ space + other stuff, maybe) r'^\s+return\([^\)]*\).*$', # wacky return with immediate open paren - r'^\s+yield(\s.*)?$', # normal yield (+ space + other stuff, maybe) - r'^\s+yield\([^\)]*\).*$', # wacky yield with immediate open paren r'^\s+pass\s*$', # pass (optionally followed by trailing spaces) r'^\s+break\s*$', # break (optionally followed by trailing spaces) r'^\s+continue\s*$', # continue (optionally followed by trailing spaces) diff --git a/IPython/core/tests/test_inputsplitter.py b/IPython/core/tests/test_inputsplitter.py index 3987967..94f761e 100644 --- a/IPython/core/tests/test_inputsplitter.py +++ b/IPython/core/tests/test_inputsplitter.py @@ -273,20 +273,6 @@ class InputSplitterTestCase(unittest.TestCase): isp.push('if 1:\n return(0)') self.assertEqual(isp.indent_spaces, 0) - def test_dedent_yield(self): - isp = self.isp # shorthand - # should NOT cause dedent - isp.push('if 1:\n yielding = 4') - self.assertEqual(isp.indent_spaces, 4) - isp.push('if 1:\n yield 5 + 493') - self.assertEqual(isp.indent_spaces, 0) - isp.push('if 1:\n yield') - self.assertEqual(isp.indent_spaces, 0) - isp.push('if 1:\n yield ') - self.assertEqual(isp.indent_spaces, 0) - isp.push('if 1:\n yield(0)') - self.assertEqual(isp.indent_spaces, 0) - def test_push(self): isp = self.isp self.assertTrue(isp.push('x=1'))