'Return current namespace
This is globals() if not debugging, or a dictionary containing
both locals() and globals() for current frame when debugging'

def _get_current_namespace(self, with_magics=False):

    ns = {}
    glbs = self._mglobals()
    if (self._pdb_frame is None):
        ns.update(glbs)
    else:
        ns.update(glbs)
        ns.update(self._pdb_locals)
    if with_magics:
        line_magics = self.shell.magics_manager.magics['line']
        cell_magics = self.shell.magics_manager.magics['cell']
        ns.update(line_magics)
        ns.update(cell_magics)
    return ns
