Fix Trac #2597 (first bug): correct type checking for empty list