The re.Pattern class was introduced in Python 3.7. Use duck-typing to distinguish between str and re pattern object. Fixes: https://pagure.io/freeipa/issue/8179 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Sergey Orlov <sorlov@redhat.com>