def object_session(instance):
 try:
  return _state_session(attributes.instance_state(instance))
 except exc.NO_STATE:
  raise exc.UnmappedInstanceError(instance)

def object_session ( instance ) : try : return _state_session ( attributes . instance_state ( instance ) ) except exc . NO_STATE : raise exc . UnmappedInstanceError ( instance )
return the session to which instance belongs .