~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to services/python-console

  • Committer: David Coles
  • Date: 2010-07-20 00:30:45 UTC
  • Revision ID: coles.david@gmail.com-20100720003045-j239u3w3m5wfribb
Put "__name__" = "__main__" into globals for console.

Fixes issue where __name__ did not work when run in the python console. exec() 
with an empty globals dictionary will result in "__name__" = "__builtin__".

Show diffs side-by-side

added added

removed removed

Lines of Context:
170
170
 
171
171
    def run(self):
172
172
        # Set up global space and partial command buffer
173
 
        self.globs = {}
 
173
        self.globs = {'__name__': '__main__'}
174
174
        self.curr_cmd = ''
175
175
 
176
176
        # Set up I/O to use web interface
262
262
    def handle_globals(self, params):
263
263
        # Unpickle the new space (if provided)
264
264
        if isinstance(params, dict):
265
 
            self.globs = {}
 
265
            self.globs = {'__name__': '__main__'}
266
266
            for g in params:
267
267
                try:
268
268
                    self.globs[g] = cPickle.loads(params[g])