check for None before dimension

also py3 fix