Skip to content

Commit 2a00449

Browse files
committed
Emit deprecation warning on access to sorted_dict.iloc
1 parent 28e99c0 commit 2a00449

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

sortedcontainers/sorteddict.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
1717
"""
1818

19+
import warnings
1920
from collections import ItemsView, KeysView, ValuesView, Sequence
2021

2122
from .sortedlist import SortedList, recursive_repr
@@ -179,7 +180,7 @@ def __init__(self, *args, **kwargs):
179180
# GrantJ 2018-05-21 Temporary fix for improved backwards compatibility
180181
# with V1.
181182

182-
self.iloc = SortedKeysView(self)
183+
self._iloc = SortedKeysView(self)
183184

184185
self._update(*args, **kwargs)
185186

@@ -194,6 +195,17 @@ def key(self):
194195
return self._key
195196

196197

198+
@property
199+
def iloc(self):
200+
warnings.warn(
201+
'sorted_dict.iloc is deprecated.'
202+
' Use SortedDict.keys() instead.',
203+
DeprecationWarning,
204+
stacklevel=2,
205+
)
206+
return self._iloc
207+
208+
197209
def clear(self):
198210
"""Remove all items from sorted dict.
199211

0 commit comments

Comments
 (0)