summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-11-13 00:17:59 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-11-13 00:17:59 (GMT)
commitaeaa592516c8ea8a0a6318f69635baa817ced82f (patch)
tree7b082d501188cc6acc44469e7f33a766c51d9d55 /Lib
parenta1d23326b19a0182ef74aae32386c5119b1a6e39 (diff)
downloadcpython-aeaa592516c8ea8a0a6318f69635baa817ced82f.zip
cpython-aeaa592516c8ea8a0a6318f69635baa817ced82f.tar.gz
cpython-aeaa592516c8ea8a0a6318f69635baa817ced82f.tar.bz2
Merged revisions 76230 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76230 | benjamin.peterson | 2009-11-12 17:39:44 -0600 (Thu, 12 Nov 2009) | 2 lines fix several compile() issues by translating newlines in the tokenizer ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_codeop.py4
-rw-r--r--Lib/test/test_compile.py13
-rw-r--r--Lib/test/test_parser.py6
-rw-r--r--Lib/test/test_pep263.py2
4 files changed, 17 insertions, 8 deletions
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py
index ad44121..80a73f3 100644
--- a/Lib/test/test_codeop.py
+++ b/Lib/test/test_codeop.py
@@ -295,10 +295,6 @@ class CodeopTests(unittest.TestCase):
self.assertNotEquals(compile_command("a = 1\n", "abc").co_filename,
compile("a = 1\n", "def", 'single').co_filename)
- def test_no_universal_newlines(self):
- code = compile_command("'\rfoo\r'", symbol='eval')
- self.assertEqual(eval(code), '\rfoo\r')
-
def test_main():
run_unittest(CodeopTests)
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 32dd656..563a7ee 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -5,6 +5,19 @@ from test import 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')
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 0ac49da..d8df6a8 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -237,9 +237,9 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
(14, '+', 2, 13),
(2, '1', 2, 15),
(4, '', 2, 16),
- (6, '', 2, -1),
- (4, '', 2, -1),
- (0, '', 2, -1)],
+ (6, '', 3, -1),
+ (4, '', 3, -1),
+ (0, '', 3, -1)],
terminals)
def test_extended_unpacking(self):
diff --git a/Lib/test/test_pep263.py b/Lib/test/test_pep263.py
index 587b2fc..8c1fbe7 100644
--- a/Lib/test/test_pep263.py
+++ b/Lib/test/test_pep263.py
@@ -26,7 +26,7 @@ class PEP263Test(unittest.TestCase):
try:
compile(b"# coding: cp932\nprint '\x94\x4e'", "dummy", "exec")
except SyntaxError as v:
- self.assertEquals(v.text, "print '\u5e74'")
+ self.assertEquals(v.text, "print '\u5e74'\n")
else:
self.fail()