[API] fix "except" syntax for Python 3