ENH: backport Python 3.3 ChainMap

ChainMap implements a list of mappings that effectively functions as a single
dictionary. This class is very useful for implementing scope. This commit also
adds a DeepChainMap subclass of ChainMap for writing and deleting keys.
CLN/ENH: use Scope.swapkey() to update names

Also useful for replacing local variable names with their mangled versions.
ENH/CLN: track scope instead of hard coding minimal stack level
ERR/API: disallow local references in top-level calls to eval
BUG: ChainMap m parameter only exists in Python 3.4

So backport that as well.
BUG: use a regular for loop in _ensure_term

In Python 3.x list comprehension build up stack frames, thus providing the
stack level to search is not the same as it is in Python 2.x.
Merge pull request #6366 from cpcloud/eval-fix-scope

ENH: fix eval scoping issues