(method)
return _raw_property(_mjcf_property)
Modifies `@property` to keep track of any `AttributeError` raised.

  Our `Element` implementations overrides the `__getattr__` method. This does
  not interact well with `@property`: if a `property`'s code is buggy so as to
  raise an `AttributeError`, then Python would silently discard it and redirect
  to our `__getattr__` instead, leading to an uninformative stack trace. This
  makes it very difficult to debug issues that involve properties.

  To remedy this, we modify `@property` within this module to store any
  `AttributeError` raised within the respective `Element` object. Then, in our
  `__getattr__` logic, we could re-raise it to preserve the original stack
  trace.

  The reason that this is not implemented as a different decorator is that we
  could accidentally use @property on a new method. This would work fine until
  someone triggers a subtle bug. This is when a proper trace would be most
  useful, but we would still end up with a strange undebuggable stack trace
  anyway.

  Note that at the end of this module, we have a `del property` to prevent this
  override from being broadcasted externally.

  Args:
    method: The method that is being decorated.

  Returns:
    A `property` corresponding to the decorated method.
Modifies `@property` to keep track of any `AttributeError` raised.
Modifies @property to keep track of any AttributeError raised .
def property(method):  # pylint: disable=redefined-builtin
  """Modifies `@property` to keep track of any `AttributeError` raised.

  Our `Element` implementations overrides the `__getattr__` method. This does
  not interact well with `@property`: if a `property`'s code is buggy so as to
  raise an `AttributeError`, then Python would silently discard it and redirect
  to our `__getattr__` instead, leading to an uninformative stack trace. This
  makes it very difficult to debug issues that involve properties.

  To remedy this, we modify `@property` within this module to store any
  `AttributeError` raised within the respective `Element` object. Then, in our
  `__getattr__` logic, we could re-raise it to preserve the original stack
  trace.

  The reason that this is not implemented as a different decorator is that we
  could accidentally use @property on a new method. This would work fine until
  someone triggers a subtle bug. This is when a proper trace would be most
  useful, but we would still end up with a strange undebuggable stack trace
  anyway.

  Note that at the end of this module, we have a `del property` to prevent this
  override from being broadcasted externally.

  Args:
    method: The method that is being decorated.

  Returns:
    A `property` corresponding to the decorated method.
  """
  def _mjcf_property(self):
    try:
      return method(self)
    except:
      _, err, tb = sys.exc_info()
      err_with_next_tb = err.with_traceback(tb.tb_next)
      if isinstance(err, AttributeError):
        self._last_attribute_error = err_with_next_tb  # pylint: disable=protected-access
      raise err_with_next_tb
  return _raw_property(_mjcf_property)
def property ( method ) : # pylint: disable=redefined-builtin def _mjcf_property ( self ) : try : return method ( self ) except : _ , err , tb = sys . exc_info ( ) err_with_next_tb = err . with_traceback ( tb . tb_next ) if isinstance ( err , AttributeError ) : self . _last_attribute_error = err_with_next_tb # pylint: disable=protected-access raise err_with_next_tb return _raw_property ( _mjcf_property )