mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
* os.py: _exit doesn't exist in all variations of posix
* Added fcmp() to test_support.py and use it in test*.py
This commit is contained in:
parent
93f0740073
commit
35fb82a33f
4 changed files with 45 additions and 19 deletions
|
@ -18,5 +18,24 @@ def forget(modname):
|
|||
except os.error:
|
||||
pass
|
||||
|
||||
FUZZ = 1e-6
|
||||
|
||||
def fcmp(x, y): # fuzzy comparison function
|
||||
if type(x) == type(0.0) or type(y) == type(0.0):
|
||||
try:
|
||||
x, y = coerce(x, y)
|
||||
fuzz = (abs(x) + abs(y)) * FUZZ
|
||||
if abs(x-y) <= fuzz:
|
||||
return 0
|
||||
except:
|
||||
pass
|
||||
elif type(x) == type(y) and type(x) in (type(()), type([])):
|
||||
for i in range(min(len(x), len(y))):
|
||||
outcome = fcmp(x[i], y[i])
|
||||
if outcome <> 0:
|
||||
return outcome
|
||||
return cmp(len(x), len(y))
|
||||
return cmp(x, y)
|
||||
|
||||
TESTFN = '@test' # Filename used for testing
|
||||
from os import unlink
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue