Brett Cannon added the comment:

It is an abuse since I didn't design that part of the API to function that way, 
but it's cool that it just happens to. =)

I do see your use-case and it is legitimate, although extremely rare and 
narrow. Let me think about whether I want to add specific support either 
through your approach, Richard, or if I want to decouple the setting of module 
attributes so that it is more along the lines of::

  main_module = imp.new_module('__mp_main__')
  loader.set_attributes(main_module)  # BRAND-NEW; maybe private to the stdlib?
  main_module.__name__ = '__mp_main__'
  code_object = loader.get_code(main_name)
  sys.modules['__main__'] = sys.modules['__mp_main__'] = main_module  # OLD
  exec(code_object, main_module.__dict__)

I'm currently leaning towards the latter option since it's an annoying bit to 
get right and it doesn't hurt anything to expose.

----------
assignee: sbt -> brett.cannon

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17314>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to