python: Fix some corner cases handling scalars.