Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6bc217dd
Kaydet (Commit)
6bc217dd
authored
Haz 23, 2015
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
üst
03863d2b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
11 deletions
+58
-11
test_cmath.py
Lib/test/test_cmath.py
+41
-10
NEWS
Misc/NEWS
+2
-0
_testcapimodule.c
Modules/_testcapimodule.c
+13
-0
cmathmodule.c
Modules/cmathmodule.c
+2
-1
No files found.
Lib/test/test_cmath.py
Dosyayı görüntüle @
6bc217dd
from
test.support
import
run_unittest
,
requires_IEEE_754
from
test.support
import
run_unittest
,
requires_IEEE_754
,
cpython_only
from
test.test_math
import
parse_testfile
,
test_file
from
test.test_math
import
parse_testfile
,
test_file
import
unittest
import
unittest
import
cmath
,
math
import
cmath
,
math
...
@@ -381,17 +381,48 @@ class CMathTests(unittest.TestCase):
...
@@ -381,17 +381,48 @@ class CMathTests(unittest.TestCase):
self
.
rAssertAlmostEqual
(
expected
.
imag
,
actual
.
imag
,
self
.
rAssertAlmostEqual
(
expected
.
imag
,
actual
.
imag
,
msg
=
error_message
)
msg
=
error_message
)
def
assertCISEqual
(
self
,
a
,
b
):
def
check_polar
(
self
,
func
):
eps
=
1E-7
def
check
(
arg
,
expected
):
if
abs
(
a
[
0
]
-
b
[
0
])
>
eps
or
abs
(
a
[
1
]
-
b
[
1
])
>
eps
:
got
=
func
(
arg
)
self
.
fail
((
a
,
b
))
for
e
,
g
in
zip
(
expected
,
got
):
self
.
rAssertAlmostEqual
(
e
,
g
)
check
(
0
,
(
0.
,
0.
))
check
(
1
,
(
1.
,
0.
))
check
(
-
1
,
(
1.
,
pi
))
check
(
1
j
,
(
1.
,
pi
/
2
))
check
(
-
3
j
,
(
3.
,
-
pi
/
2
))
inf
=
float
(
'inf'
)
check
(
complex
(
inf
,
0
),
(
inf
,
0.
))
check
(
complex
(
-
inf
,
0
),
(
inf
,
pi
))
check
(
complex
(
3
,
inf
),
(
inf
,
pi
/
2
))
check
(
complex
(
5
,
-
inf
),
(
inf
,
-
pi
/
2
))
check
(
complex
(
inf
,
inf
),
(
inf
,
pi
/
4
))
check
(
complex
(
inf
,
-
inf
),
(
inf
,
-
pi
/
4
))
check
(
complex
(
-
inf
,
inf
),
(
inf
,
3
*
pi
/
4
))
check
(
complex
(
-
inf
,
-
inf
),
(
inf
,
-
3
*
pi
/
4
))
nan
=
float
(
'nan'
)
check
(
complex
(
nan
,
0
),
(
nan
,
nan
))
check
(
complex
(
0
,
nan
),
(
nan
,
nan
))
check
(
complex
(
nan
,
nan
),
(
nan
,
nan
))
check
(
complex
(
inf
,
nan
),
(
inf
,
nan
))
check
(
complex
(
-
inf
,
nan
),
(
inf
,
nan
))
check
(
complex
(
nan
,
inf
),
(
inf
,
nan
))
check
(
complex
(
nan
,
-
inf
),
(
inf
,
nan
))
def
test_polar
(
self
):
def
test_polar
(
self
):
self
.
assertCISEqual
(
polar
(
0
),
(
0.
,
0.
))
self
.
check_polar
(
polar
)
self
.
assertCISEqual
(
polar
(
1.
),
(
1.
,
0.
))
self
.
assertCISEqual
(
polar
(
-
1.
),
(
1.
,
pi
))
@cpython_only
self
.
assertCISEqual
(
polar
(
1
j
),
(
1.
,
pi
/
2
))
def
test_polar_errno
(
self
):
self
.
assertCISEqual
(
polar
(
-
1
j
),
(
1.
,
-
pi
/
2
))
# Issue #24489: check a previously set C errno doesn't disturb polar()
from
_testcapi
import
set_errno
def
polar_with_errno_set
(
z
):
set_errno
(
11
)
try
:
return
polar
(
z
)
finally
:
set_errno
(
0
)
self
.
check_polar
(
polar_with_errno_set
)
def
test_phase
(
self
):
def
test_phase
(
self
):
self
.
assertAlmostEqual
(
phase
(
0
),
0.
)
self
.
assertAlmostEqual
(
phase
(
0
),
0.
)
...
...
Misc/NEWS
Dosyayı görüntüle @
6bc217dd
...
@@ -60,6 +60,8 @@ Core and Builtins
...
@@ -60,6 +60,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #24489: ensure a previously set C errno doesn'
t
disturb
cmath
.
polar
().
-
Issue
#
5633
:
Fixed
timeit
when
the
statement
is
a
string
and
the
setup
is
not
.
-
Issue
#
5633
:
Fixed
timeit
when
the
statement
is
a
string
and
the
setup
is
not
.
-
Issue
#
24326
:
Fixed
audioop
.
ratecv
()
with
non
-
default
weightB
argument
.
-
Issue
#
24326
:
Fixed
audioop
.
ratecv
()
with
non
-
default
weightB
argument
.
...
...
Modules/_testcapimodule.c
Dosyayı görüntüle @
6bc217dd
...
@@ -1783,6 +1783,18 @@ raise_exception(PyObject *self, PyObject *args)
...
@@ -1783,6 +1783,18 @@ raise_exception(PyObject *self, PyObject *args)
return
NULL
;
return
NULL
;
}
}
static
PyObject
*
set_errno
(
PyObject
*
self
,
PyObject
*
args
)
{
int
new_errno
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:set_errno"
,
&
new_errno
))
return
NULL
;
errno
=
new_errno
;
Py_RETURN_NONE
;
}
static
PyObject
*
static
PyObject
*
test_set_exc_info
(
PyObject
*
self
,
PyObject
*
args
)
test_set_exc_info
(
PyObject
*
self
,
PyObject
*
args
)
{
{
...
@@ -3208,6 +3220,7 @@ pymarshal_read_object_from_file(PyObject* self, PyObject *args)
...
@@ -3208,6 +3220,7 @@ pymarshal_read_object_from_file(PyObject* self, PyObject *args)
static
PyMethodDef
TestMethods
[]
=
{
static
PyMethodDef
TestMethods
[]
=
{
{
"raise_exception"
,
raise_exception
,
METH_VARARGS
},
{
"raise_exception"
,
raise_exception
,
METH_VARARGS
},
{
"raise_memoryerror"
,
(
PyCFunction
)
raise_memoryerror
,
METH_NOARGS
},
{
"raise_memoryerror"
,
(
PyCFunction
)
raise_memoryerror
,
METH_NOARGS
},
{
"set_errno"
,
set_errno
,
METH_VARARGS
},
{
"test_config"
,
(
PyCFunction
)
test_config
,
METH_NOARGS
},
{
"test_config"
,
(
PyCFunction
)
test_config
,
METH_NOARGS
},
{
"test_sizeof_c_types"
,
(
PyCFunction
)
test_sizeof_c_types
,
METH_NOARGS
},
{
"test_sizeof_c_types"
,
(
PyCFunction
)
test_sizeof_c_types
,
METH_NOARGS
},
{
"test_datetime_capi"
,
test_datetime_capi
,
METH_NOARGS
},
{
"test_datetime_capi"
,
test_datetime_capi
,
METH_NOARGS
},
...
...
Modules/cmathmodule.c
Dosyayı görüntüle @
6bc217dd
...
@@ -941,9 +941,10 @@ cmath_polar(PyObject *self, PyObject *args)
...
@@ -941,9 +941,10 @@ cmath_polar(PyObject *self, PyObject *args)
double
r
,
phi
;
double
r
,
phi
;
if
(
!
PyArg_ParseTuple
(
args
,
"D:polar"
,
&
z
))
if
(
!
PyArg_ParseTuple
(
args
,
"D:polar"
,
&
z
))
return
NULL
;
return
NULL
;
errno
=
0
;
PyFPE_START_PROTECT
(
"polar function"
,
return
0
)
PyFPE_START_PROTECT
(
"polar function"
,
return
0
)
phi
=
c_atan2
(
z
);
/* should not cause any exception */
phi
=
c_atan2
(
z
);
/* should not cause any exception */
r
=
c_abs
(
z
);
/* sets errno to ERANGE on overflow
; otherwise 0
*/
r
=
c_abs
(
z
);
/* sets errno to ERANGE on overflow */
PyFPE_END_PROTECT
(
r
)
PyFPE_END_PROTECT
(
r
)
if
(
errno
!=
0
)
if
(
errno
!=
0
)
return
math_error
();
return
math_error
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment