code: def _mglobals(self):
          
          if self._pdb_frame is not None:
              return self._pdb_frame.f_globals
          else:
              return self.shell.user_ns
docs: Return current globals -- handles Pdb frames