Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d6903ec

Browse files
committed
MAINT: Remove references to non-existent sys.exc_clear()
sys.exc_clear() was removed in Python 3. All internal uses can be removed.
1 parent c31cc36 commit d6903ec

5 files changed

Lines changed: 3 additions & 25 deletions

File tree

numpy/_pytesttester.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ def __call__(self, label='fast', verbose=1, extra_argv=None,
164164

165165
# Ignore python2.7 -3 warnings
166166
pytest_args += [
167-
r"-W ignore:sys\.exc_clear\(\) not supported in 3\.x:DeprecationWarning",
168167
r"-W ignore:in 3\.x, __setslice__:DeprecationWarning",
169168
r"-W ignore:in 3\.x, __getslice__:DeprecationWarning",
170169
r"-W ignore:buffer\(\) not supported in 3\.x:DeprecationWarning",

numpy/core/tests/test_indexing.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from itertools import product
1010
from numpy.testing import (
1111
assert_, assert_equal, assert_raises, assert_array_equal, assert_warns,
12-
HAS_REFCOUNT, suppress_warnings,
12+
HAS_REFCOUNT,
1313
)
1414

1515

@@ -669,30 +669,16 @@ def __setitem__(self, indx, val):
669669
k[0:5]
670670
assert_equal(k.indx, slice(0, 5))
671671
assert_equal(sys.getrefcount(k.indx), 2)
672-
try:
672+
with assert_raises(ValueError):
673673
k[0:7]
674-
raise AssertionError
675-
except ValueError:
676-
# The exception holds a reference to the slice so clear on Py2
677-
if hasattr(sys, 'exc_clear'):
678-
with suppress_warnings() as sup:
679-
sup.filter(DeprecationWarning)
680-
sys.exc_clear()
681674
assert_equal(k.indx, slice(0, 7))
682675
assert_equal(sys.getrefcount(k.indx), 2)
683676

684677
k[0:3] = 6
685678
assert_equal(k.indx, slice(0, 3))
686679
assert_equal(sys.getrefcount(k.indx), 2)
687-
try:
680+
with assert_raises(ValueError):
688681
k[0:4] = 2
689-
raise AssertionError
690-
except ValueError:
691-
# The exception holds a reference to the slice so clear on Py2
692-
if hasattr(sys, 'exc_clear'):
693-
with suppress_warnings() as sup:
694-
sup.filter(DeprecationWarning)
695-
sys.exc_clear()
696682
assert_equal(k.indx, slice(0, 4))
697683
assert_equal(sys.getrefcount(k.indx), 2)
698684

numpy/core/tests/test_multiarray.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8221,9 +8221,6 @@ class Dummy: pass
82218221
# get an array that crashed in __array_finalize__
82228222
with assert_raises(Exception) as e:
82238223
obj_arr.view(RaisesInFinalize)
8224-
if sys.version_info.major == 2:
8225-
# prevent an extra reference being kept
8226-
sys.exc_clear()
82278224

82288225
obj_subarray = e.exception.args[0]
82298226
del e

numpy/testing/_private/nosetester.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,6 @@ def test(self, label='fast', verbose=1, extra_argv=None,
454454
# This is very specific, so using the fragile module filter
455455
# is fine
456456
import threading
457-
sup.filter(DeprecationWarning,
458-
r"sys\.exc_clear\(\) not supported in 3\.x",
459-
module=threading)
460457
sup.filter(DeprecationWarning, message=r"in 3\.x, __setslice__")
461458
sup.filter(DeprecationWarning, message=r"in 3\.x, __getslice__")
462459
sup.filter(DeprecationWarning, message=r"buffer\(\) not supported in 3\.x")

pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ filterwarnings =
1414
# Matrix PendingDeprecationWarning.
1515
ignore:the matrix subclass is not
1616
# Ignore python2.7 -3 warnings
17-
ignore:sys\.exc_clear\(\) not supported in 3\.x:DeprecationWarning
1817
ignore:in 3\.x, __setslice__:DeprecationWarning
1918
ignore:in 3\.x, __getslice__:DeprecationWarning
2019
ignore:buffer\(\) not supported in 3\.x:DeprecationWarning

0 commit comments

Comments
 (0)