Running modulefinder.ModuleFinder.run_script on a script which has an import statement with a module containing a syntax error will raise a SyntaxError exception. I think, modulefinder should instead continue its analysis and add the module to badmodules. Especially, as there are valid reasons for importing modules with syntax errors like in the following code snippet if not python3: from .exec_py2 import exec_ else: from .exec_py3 import exec_ I attached a patch which changes the code to catch potential SyntaxError exceptions and change them to an ImportError.
Certainly: http://docs.python.org/devguide contains information to get the source code, describes the files layout and explains how to generate a patch. You’ll find existing unit tests in Lib/test/test_modulefinder.py Feel free to ask any question you might have on this bug, or if you prefer on the friendly core-mentorship mailing list (where I am).
I would recommend that you base your patch on the default branch, i.e. what will become Python 3.4. If we judge that this is not a new feature but actually a bug fix, the core developer who commits the patch will take care of backporting it to 2.7 and 3.3.
Fixed for Python 3.8 via the patch for #35936. We won't be backporting that patch as it also migrates modulefinder from the deprecated imp API to support importlib one, and is hence considered overly intrusive for a bug fix release.