Backport PR #4188: Allow user_ns trait to be None

The Dict trait converts None to an empty dict, which caused the application to pass in a user_ns to the shell, which then behaves slightly differently, creating a DummyMod instance.

Ping @minrk : Is this the best way to fix this?