Throw a TypeError when a non-object is passed where one is expected.
Merge pull request #2961 from Ms2ger/non-object-throw

Throw a TypeError when a non-object is passed where one is expected; r=jdm