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

Use importlib.import_module instead of __import__ #445

Merged
merged 3 commits into from
Nov 7, 2013

Conversation

rmax
Copy link
Contributor

@rmax rmax commented Oct 27, 2013

Given that python 2.6 support is going to be dropped, the recommended way to import modules is using importlib.import_module as stated in the __import__ doc:

Import a module. Because this function is meant for use by the Python
interpreter and not for general use it is better to use
importlib.import_module() to programmatically import a module.

PD: Sorry for the typo in the second commit!

Since python 2.7, importlib.import_module is the recommended way to
import modules programmatically.

From __import__'s doc:

    Import a module. Because this function is meant for use by the
Python
    interpreter and not for general use it is better to use
    importlib.import_module() to programmatically import a module.
This commit replaces the statements __import__(module) as the previous
replaced the statements __import__(module, {}, {}, ['']).

At first I thought leaving the single-argument calls, but perhaps it's
better to be strict rather than having exceptions to the rule in this
case.
@pablohoffman
Copy link
Member

Can you check why Travis failed @darkrho ?

@rmax
Copy link
Contributor Author

rmax commented Oct 31, 2013

@pablohoffman It failed due the removed file requirements-lucid.txt. I did merge latest changes from master and now everything is OK.

dangra added a commit that referenced this pull request Nov 7, 2013
Use `importlib.import_module` instead of `__import__`
@dangra dangra merged commit b78e761 into scrapy:master Nov 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants