Fix for Bug 1397: handled exception TypeError