Merged revisions 62420-62421,62423-62424 via svnmerge from · pythoncapi/cpython@e57950f · GitHub
Skip to content

Commit e57950f

Browse files
committed
Merged revisions 62420-62421,62423-62424 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r62420 | mark.dickinson | 2008-04-20 20:30:05 +0200 (Sun, 20 Apr 2008) | 3 lines Even more fixes for alpha Tru64, this time for the phase and polar methods. ........ r62421 | mark.dickinson | 2008-04-20 22:38:48 +0200 (Sun, 20 Apr 2008) | 2 lines Add test for tanh(-0.) == -0. on IEEE 754 systems ........ r62423 | amaury.forgeotdarc | 2008-04-20 23:02:21 +0200 (Sun, 20 Apr 2008) | 3 lines Correct an apparent refleak in test_pkgutil: zipimport._zip_directory_cache contains info for all processed zip files, even when they are no longer used. ........ r62424 | mark.dickinson | 2008-04-20 23:39:04 +0200 (Sun, 20 Apr 2008) | 4 lines math.atan2 is misbehaving on Windows; this patch should fix the problem in the same way that the cmath.phase problems were fixed. ........
1 parent 1a3239e commit e57950f

4 files changed

Lines changed: 108 additions & 2 deletions

File tree

Lib/test/test_math.py

Lines changed: 58 additions & 0 deletions

Lib/test/test_pkgutil.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ def test_alreadyloaded(self):
122122

123123
def test_main():
124124
run_unittest(PkgutilTests, PkgutilPEP302Tests)
125+
# this is necessary if test is run repeated (like when finding leaks)
126+
import zipimport
127+
zipimport._zip_directory_cache.clear()
125128

126129
if __name__ == '__main__':
127130
test_main()

Modules/cmathmodule.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ c_atan(Py_complex z)
264264
return r;
265265
}
266266

267-
/* Windows screws up atan2 for inf and nan */
267+
/* Windows screws up atan2 for inf and nan, and alpha Tru64 5.1 doesn't follow
268+
C99 for atan2(0., 0.). */
268269
static double
269270
c_atan2(Py_complex z)
270271
{
@@ -282,6 +283,14 @@ c_atan2(Py_complex z)
282283
/* atan2(+-inf, x) == +-pi/2 for finite x */
283284
return copysign(0.5*Py_MATH_PI, z.imag);
284285
}
286+
if (Py_IS_INFINITY(z.real) || z.imag == 0.) {
287+
if (copysign(1., z.real) == 1.)
288+
/* atan2(+-y, +inf) = atan2(+-0, +x) = +-0. */
289+
return copysign(0., z.imag);
290+
else
291+
/* atan2(+-y, -inf) = atan2(+-0., -x) = +-pi. */
292+
return copysign(Py_MATH_PI, z.imag);
293+
}
285294
return atan2(z.imag, z.real);
286295
}
287296

Modules/mathmodule.c

Lines changed: 37 additions & 1 deletion

0 commit comments

Comments
 (0)