File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -1015,8 +1015,11 @@ def _setitem_copy(self, copy):
1015
1015
self ._is_copy = copy
1016
1016
return self
1017
1017
1018
- def _check_setitem_copy (self ):
1019
- """ validate if we are doing a settitem on a chained copy """
1018
+ def _check_setitem_copy (self , stacklevel = 4 ):
1019
+ """ validate if we are doing a settitem on a chained copy.
1020
+
1021
+ If you call this function, be sure to set the stacklevel such that the
1022
+ user will see the error *at the level of setting*"""
1020
1023
if self ._is_copy :
1021
1024
value = config .get_option ('mode.chained_assignment' )
1022
1025
@@ -1026,7 +1029,7 @@ def _check_setitem_copy(self):
1026
1029
if value == 'raise' :
1027
1030
raise SettingWithCopyError (t )
1028
1031
elif value == 'warn' :
1029
- warnings .warn (t , SettingWithCopyWarning )
1032
+ warnings .warn (t , SettingWithCopyWarning , stacklevel = stacklevel )
1030
1033
1031
1034
def __delitem__ (self , key ):
1032
1035
"""
You can’t perform that action at this time.
0 commit comments