bpo-42918: Improve built-in function compile() in mode 'single' (GH-29934) (GH-30040)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit 28179aac796ed1debdce336c4b8ca18e8475d40d)

Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 4de5448..5f80a58 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -502,6 +502,7 @@ def test_single_statement(self):
         self.compile_single("if x:\n   f(x)")
         self.compile_single("if x:\n   f(x)\nelse:\n   g(x)")
         self.compile_single("class T:\n   pass")
+        self.compile_single("c = '''\na=1\nb=2\nc=3\n'''")
 
     def test_bad_single_statement(self):
         self.assertInvalidSingle('1\n2')
@@ -512,6 +513,7 @@ def test_bad_single_statement(self):
         self.assertInvalidSingle('f()\n# blah\nblah()')
         self.assertInvalidSingle('f()\nxy # blah\nblah()')
         self.assertInvalidSingle('x = 5 # comment\nx = 6\n')
+        self.assertInvalidSingle("c = '''\nd=1\n'''\na = 1\n\nb = 2\n")
 
     def test_particularly_evil_undecodable(self):
         # Issue 24022