A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/ below:

Make resource.RLIM_INFINITY always positive (GH-137511) · python/cpython@0324c72 · GitHub

@@ -40,7 +40,10 @@ def test_fsize_ismax(self):

40 40

# we need to test that the get/setrlimit functions properly convert

41 41

# the number to a C long long and that the conversion doesn't raise

42 42

# an error.

43 +

self.assertGreater(resource.RLIM_INFINITY, 0)

43 44

self.assertEqual(resource.RLIM_INFINITY, max)

45 +

self.assertLessEqual(cur, max)

46 +

resource.setrlimit(resource.RLIMIT_FSIZE, (max, max))

44 47

resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))

45 48 46 49

@unittest.skipIf(sys.platform == "vxworks",

@@ -113,56 +116,53 @@ def test_fsize_not_too_big(self):

113 116

self.addCleanup(resource.setrlimit, resource.RLIMIT_FSIZE, (cur, max))

114 117 115 118

def expected(cur):

116 -

if resource.RLIM_INFINITY < 0:

117 -

return [(cur, max), (resource.RLIM_INFINITY, max)]

118 -

elif resource.RLIM_INFINITY < cur:

119 -

return [(resource.RLIM_INFINITY, max)]

120 -

else:

121 -

return [(cur, max)]

119 +

return (min(cur, resource.RLIM_INFINITY), max)

122 120 123 121

resource.setrlimit(resource.RLIMIT_FSIZE, (2**31-5, max))

124 122

self.assertEqual(resource.getrlimit(resource.RLIMIT_FSIZE), (2**31-5, max))

123 +

resource.setrlimit(resource.RLIMIT_FSIZE, (2**31, max))

124 +

self.assertEqual(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**31))

125 +

resource.setrlimit(resource.RLIMIT_FSIZE, (2**32-5, max))

126 +

self.assertEqual(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**32-5))

125 127 126 128

try:

127 129

resource.setrlimit(resource.RLIMIT_FSIZE, (2**32, max))

128 130

except OverflowError:

129 -

resource.setrlimit(resource.RLIMIT_FSIZE, (2**31, max))

130 -

self.assertIn(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**31))

131 -

resource.setrlimit(resource.RLIMIT_FSIZE, (2**32-5, max))

132 -

self.assertIn(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**32-5))

131 +

pass

133 132

else:

134 -

self.assertIn(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**32))

135 -

resource.setrlimit(resource.RLIMIT_FSIZE, (2**31, max))

136 -

self.assertEqual(resource.getrlimit(resource.RLIMIT_FSIZE), (2**31, max))

137 -

resource.setrlimit(resource.RLIMIT_FSIZE, (2**32-5, max))

138 -

self.assertEqual(resource.getrlimit(resource.RLIMIT_FSIZE), (2**32-5, max))

133 +

self.assertEqual(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**32))

139 134 140 135

resource.setrlimit(resource.RLIMIT_FSIZE, (2**63-5, max))

141 -

self.assertIn(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**63-5))

136 +

self.assertEqual(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**63-5))

142 137

try:

143 138

resource.setrlimit(resource.RLIMIT_FSIZE, (2**63, max))

144 139

except ValueError:

145 140

# There is a hard limit on macOS.

146 141

pass

147 142

else:

148 -

self.assertIn(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**63))

143 +

self.assertEqual(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**63))

149 144

resource.setrlimit(resource.RLIMIT_FSIZE, (2**64-5, max))

150 -

self.assertIn(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**64-5))

145 +

self.assertEqual(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**64-5))

151 146 152 147

@unittest.skipIf(sys.platform == "vxworks",

153 148

"setting RLIMIT_FSIZE is not supported on VxWorks")

154 149

@unittest.skipUnless(hasattr(resource, 'RLIMIT_FSIZE'), 'requires resource.RLIMIT_FSIZE')

155 150

def test_fsize_negative(self):

151 +

self.assertGreater(resource.RLIM_INFINITY, 0)

156 152

(cur, max) = resource.getrlimit(resource.RLIMIT_FSIZE)

157 153

for value in -5, -2**31, -2**32-5, -2**63, -2**64-5, -2**1000:

158 154

with self.subTest(value=value):

159 -

# This test assumes that the values don't map to RLIM_INFINITY,

160 -

# though Posix doesn't guarantee it.

161 -

self.assertNotEqual(value, resource.RLIM_INFINITY)

162 - 163 155

self.assertRaises(ValueError, resource.setrlimit, resource.RLIMIT_FSIZE, (value, max))

164 156

self.assertRaises(ValueError, resource.setrlimit, resource.RLIMIT_FSIZE, (cur, value))

165 157 158 +

if resource.RLIM_INFINITY in (2**32-3, 2**32-1, 2**64-3, 2**64-1):

159 +

value = (resource.RLIM_INFINITY & 0xffff) - 0x10000

160 +

with self.assertWarnsRegex(DeprecationWarning, "RLIM_INFINITY"):

161 +

resource.setrlimit(resource.RLIMIT_FSIZE, (value, max))

162 +

with self.assertWarnsRegex(DeprecationWarning, "RLIM_INFINITY"):

163 +

resource.setrlimit(resource.RLIMIT_FSIZE, (cur, value))

164 + 165 + 166 166

@unittest.skipUnless(hasattr(resource, "getrusage"), "needs getrusage")

167 167

def test_getrusage(self):

168 168

self.assertRaises(TypeError, resource.getrusage)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4