<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_permission(instance, field, permission):
 """ Check a permission for a given instance or field. Raises an error if denied. :param instance: The instance to check :param field: The field name to check or None for instance :param permission: The permission to check """

    if not get_permission_test(instance, field, permission)(instance):
        raise PermissionDeniedError(permission, instance, instance, field)