bpo-20104: Change the file_actions parameter of os.posix_spawn(). (GH… · python/cpython@d700f97 (original) (raw)
`@@ -1499,8 +1499,7 @@ def test_returns_pid(self):
`
1499
1499
` pidfile.write(str(os.getpid()))
`
1500
1500
` """
`
1501
1501
`args = self.python_args('-c', script)
`
1502
``
`-
pid = posix.posix_spawn(args[0], args,
`
1503
``
`-
os.environ)
`
``
1502
`+
pid = posix.posix_spawn(args[0], args, os.environ)
`
1504
1503
`self.assertEqual(os.waitpid(pid, 0), (pid, 0))
`
1505
1504
`with open(pidfile) as f:
`
1506
1505
`self.assertEqual(f.read(), str(pid))
`
`@@ -1538,7 +1537,7 @@ def test_empty_file_actions(self):
`
1538
1537
`self.NOOP_PROGRAM[0],
`
1539
1538
`self.NOOP_PROGRAM,
`
1540
1539
`os.environ,
`
1541
``
`-
[]
`
``
1540
`+
file_actions=[]
`
1542
1541
` )
`
1543
1542
`self.assertEqual(os.waitpid(pid, 0), (pid, 0))
`
1544
1543
``
`@@ -1691,37 +1690,38 @@ def test_multiple_file_actions(self):
`
1691
1690
` ]
`
1692
1691
`pid = posix.posix_spawn(self.NOOP_PROGRAM[0],
`
1693
1692
`self.NOOP_PROGRAM,
`
1694
``
`-
os.environ, file_actions)
`
``
1693
`+
os.environ,
`
``
1694
`+
file_actions=file_actions)
`
1695
1695
`self.assertEqual(os.waitpid(pid, 0), (pid, 0))
`
1696
1696
``
1697
1697
`def test_bad_file_actions(self):
`
1698
1698
`args = self.NOOP_PROGRAM
`
1699
1699
`with self.assertRaises(TypeError):
`
1700
``
`-
posix.posix_spawn(args[0], args,
`
1701
``
`-
os.environ, [None])
`
``
1700
`+
posix.posix_spawn(args[0], args, os.environ,
`
``
1701
`+
file_actions=[None])
`
1702
1702
`with self.assertRaises(TypeError):
`
1703
``
`-
posix.posix_spawn(args[0], args,
`
1704
``
`-
os.environ, [()])
`
``
1703
`+
posix.posix_spawn(args[0], args, os.environ,
`
``
1704
`+
file_actions=[()])
`
1705
1705
`with self.assertRaises(TypeError):
`
1706
``
`-
posix.posix_spawn(args[0], args,
`
1707
``
`-
os.environ, [(None,)])
`
``
1706
`+
posix.posix_spawn(args[0], args, os.environ,
`
``
1707
`+
file_actions=[(None,)])
`
1708
1708
`with self.assertRaises(TypeError):
`
1709
``
`-
posix.posix_spawn(args[0], args,
`
1710
``
`-
os.environ, [(12345,)])
`
``
1709
`+
posix.posix_spawn(args[0], args, os.environ,
`
``
1710
`+
file_actions=[(12345,)])
`
1711
1711
`with self.assertRaises(TypeError):
`
1712
``
`-
posix.posix_spawn(args[0], args,
`
1713
``
`-
os.environ, [(os.POSIX_SPAWN_CLOSE,)])
`
``
1712
`+
posix.posix_spawn(args[0], args, os.environ,
`
``
1713
`+
file_actions=[(os.POSIX_SPAWN_CLOSE,)])
`
1714
1714
`with self.assertRaises(TypeError):
`
1715
``
`-
posix.posix_spawn(args[0], args,
`
1716
``
`-
os.environ, [(os.POSIX_SPAWN_CLOSE, 1, 2)])
`
``
1715
`+
posix.posix_spawn(args[0], args, os.environ,
`
``
1716
`+
file_actions=[(os.POSIX_SPAWN_CLOSE, 1, 2)])
`
1717
1717
`with self.assertRaises(TypeError):
`
1718
``
`-
posix.posix_spawn(args[0], args,
`
1719
``
`-
os.environ, [(os.POSIX_SPAWN_CLOSE, None)])
`
``
1718
`+
posix.posix_spawn(args[0], args, os.environ,
`
``
1719
`+
file_actions=[(os.POSIX_SPAWN_CLOSE, None)])
`
1720
1720
`with self.assertRaises(ValueError):
`
1721
``
`-
posix.posix_spawn(args[0], args,
`
1722
``
`-
os.environ,
`
1723
``
`-
[(os.POSIX_SPAWN_OPEN, 3, file + '\0',
`
1724
``
`-
os.O_RDONLY, 0)])
`
``
1721
`+
posix.posix_spawn(args[0], args, os.environ,
`
``
1722
`+
file_actions=[(os.POSIX_SPAWN_OPEN,
`
``
1723
`+
3, file + '\0',
`
``
1724
`+
os.O_RDONLY, 0)])
`
1725
1725
``
1726
1726
`def test_open_file(self):
`
1727
1727
`outfile = support.TESTFN
`
`@@ -1736,8 +1736,8 @@ def test_open_file(self):
`
1736
1736
`stat.S_IRUSR | stat.S_IWUSR),
`
1737
1737
` ]
`
1738
1738
`args = self.python_args('-c', script)
`
1739
``
`-
pid = posix.posix_spawn(args[0], args,
`
1740
``
`-
os.environ, file_actions)
`
``
1739
`+
pid = posix.posix_spawn(args[0], args, os.environ,
`
``
1740
`+
file_actions=file_actions)
`
1741
1741
`self.assertEqual(os.waitpid(pid, 0), (pid, 0))
`
1742
1742
`with open(outfile) as f:
`
1743
1743
`self.assertEqual(f.read(), 'hello')
`
`@@ -1754,9 +1754,8 @@ def test_close_file(self):
`
1754
1754
` closefile.write('is closed %d' % e.errno)
`
1755
1755
` """
`
1756
1756
`args = self.python_args('-c', script)
`
1757
``
`-
pid = posix.posix_spawn(args[0], args,
`
1758
``
`-
os.environ,
`
1759
``
`-
[(os.POSIX_SPAWN_CLOSE, 0),])
`
``
1757
`+
pid = posix.posix_spawn(args[0], args, os.environ,
`
``
1758
`+
file_actions=[(os.POSIX_SPAWN_CLOSE, 0),])
`
1760
1759
`self.assertEqual(os.waitpid(pid, 0), (pid, 0))
`
1761
1760
`with open(closefile) as f:
`
1762
1761
`self.assertEqual(f.read(), 'is closed %d' % errno.EBADF)
`
`@@ -1773,8 +1772,8 @@ def test_dup2(self):
`
1773
1772
` (os.POSIX_SPAWN_DUP2, childfile.fileno(), 1),
`
1774
1773
` ]
`
1775
1774
`args = self.python_args('-c', script)
`
1776
``
`-
pid = posix.posix_spawn(args[0], args,
`
1777
``
`-
os.environ, file_actions)
`
``
1775
`+
pid = posix.posix_spawn(args[0], args, os.environ,
`
``
1776
`+
file_actions=file_actions)
`
1778
1777
`self.assertEqual(os.waitpid(pid, 0), (pid, 0))
`
1779
1778
`with open(dupfile) as f:
`
1780
1779
`self.assertEqual(f.read(), 'hello')
`