fix several compile() issues by translating newlines in the tokenizer

This commit is contained in:
Benjamin Peterson 2009-11-12 23:39:44 +00:00
parent c4cd6d3765
commit e36199b49d
8 changed files with 96 additions and 30 deletions

View file

@ -5,6 +5,19 @@ from test import test_support
class TestSpecifics(unittest.TestCase):
def test_no_ending_newline(self):
compile("hi", "<test>", "exec")
compile("hi\r", "<test>", "exec")
def test_empty(self):
compile("", "<test>", "exec")
def test_other_newlines(self):
compile("\r\n", "<test>", "exec")
compile("\r", "<test>", "exec")
compile("hi\r\nstuff\r\ndef f():\n pass\r", "<test>", "exec")
compile("this_is\rreally_old_mac\rdef f():\n pass", "<test>", "exec")
def test_debug_assignment(self):
# catch assignments to __debug__
self.assertRaises(SyntaxError, compile, '__debug__ = 1', '?', 'single')