@@ -246,10 +246,12 @@ def create_deprecated(cls, var, message,
246246 ret ._target = var ._target
247247 return ret
248248
249- def _check_deprecation (self , kind ):
250- if isinstance (self .field , fields .DeprecatedField ):
251- if self .field .op & kind :
252- user_deprecation_warning (self .field .message )
249+ def _warn_deprecation (self , kind ):
250+ if self .is_deprecated () and self .field .op & kind :
251+ user_deprecation_warning (self .field .message )
252+
253+ def is_deprecated (self ):
254+ return isinstance (self ._p_field , fields .DeprecatedField )
253255
254256 def is_loggable (self ):
255257 return self ._loggable
@@ -261,7 +263,7 @@ def undefine(self):
261263 self ._default_value = Undefined
262264
263265 def define (self , value ):
264- self ._check_deprecation (DEPRECATE_WR )
266+ self ._warn_deprecation (DEPRECATE_WR )
265267 self ._default_value = value
266268
267269 @property
@@ -283,11 +285,14 @@ def default_value(self):
283285 # Variables must be returned by-value to prevent an instance from
284286 # modifying the class variable space.
285287 self ._check_is_defined ()
286- self ._check_deprecation (DEPRECATE_RD )
288+ self ._warn_deprecation (DEPRECATE_RD )
287289 return copy .deepcopy (self ._default_value )
288290
289291 @property
290292 def _field (self ):
293+ if self .is_deprecated ():
294+ return self ._p_field
295+
291296 if self ._target :
292297 return self ._target ._field
293298 else :
@@ -677,7 +682,7 @@ def __init__(self, other):
677682 for name in self .__slots__ :
678683 setattr (self , name , getattr (other , name ))
679684
680- self ._check_deprecation (DEPRECATE_RD )
685+ self ._warn_deprecation (DEPRECATE_RD )
681686
682687
683688class VarSpace (namespaces .Namespace ):
0 commit comments