Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __spec__ to DummyMod #11185

merged 1 commit into from Jun 13, 2018

Add __spec__ to DummyMod #11185

merged 1 commit into from Jun 13, 2018


Copy link

@gpotter2 gpotter2 commented Jun 12, 2018

Hello, I am having an issue while calling multiprocessing.Process with latest IPython version on python 3.6. This bug does not happen with 2.7.14, and does not seem to be needed to be backported to 5.X. I don’t know about 6.X

Specs: Python 3.6.0, Windows 10 x64

I'm calling a code looking similar to

p = multiprocessing.Process(target=self.trace3D_notebook)

Stack trace

AttributeError                            Traceback (most recent call last)
<ipython-input-2-5260639d868d> in <module>
----> 1 a[0].trace3D()

Z:\Coding\github\scapy\scapy\layers\ in trace3D(self, join)
   1165         import multiprocessing
   1166         p = multiprocessing.Process(target=self.trace3D_notebook)
-> 1167         p.start()
   1168         if join:
   1169             p.join()

D:\Programms\Python3\lib\multiprocessing\ in start(self)
    103                'daemonic processes are not allowed to have children'
    104         _cleanup()
--> 105         self._popen = self._Popen(self)
    106         self._sentinel = self._popen.sentinel
    107         _children.add(self)

D:\Programms\Python3\lib\multiprocessing\ in _Popen(process_obj)
    221     @staticmethod
    222     def _Popen(process_obj):
--> 223         return _default_context.get_context().Process._Popen(process_obj)
    225 class DefaultContext(BaseContext):

D:\Programms\Python3\lib\multiprocessing\ in _Popen(process_obj)
    320         def _Popen(process_obj):
    321             from .popen_spawn_win32 import Popen
--> 322             return Popen(process_obj)
    324     class SpawnContext(BaseContext):

D:\Programms\Python3\lib\multiprocessing\ in __init__(self, process_obj)
     32     def __init__(self, process_obj):
---> 33         prep_data = spawn.get_preparation_data(process_obj._name)
     35         # read end of pipe will be "stolen" by the child process

D:\Programms\Python3\lib\multiprocessing\ in get_preparation_data(name)
    170     # or through direct execution (or to leave it alone entirely)
    171     main_module = sys.modules['__main__']
--> 172     main_mod_name = getattr(main_module.__spec__, "name", None)
    173     if main_mod_name is not None:
    174         d['init_main_from_name'] = main_mod_name

AttributeError: 'DummyMod' object has no attribute '__spec__'


Multiprocessing fail as DummyMod does not contain a __spec__ field.
According to Python's source code, the code will handle a None value properly:

This patch fixes the issue on my end.

@minrk minrk merged commit 114f100 into ipython:master Jun 13, 2018
4 checks passed
4 checks passed
codecov/patch 100% of diff hit (target 0%)
codecov/project Absolute coverage decreased by -<.01% but relative coverage increased by +32.75% compared to a7de851
continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
@gpotter2 gpotter2 deleted the gpotter2:spec-missing branch Jun 13, 2018
@takluyver takluyver added this to the 6.5 milestone Jun 17, 2018
takluyver added a commit that referenced this pull request Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants