Rebase gh-1368

This PR is the same as gh-1368 except that it remove the first commit that is now useless. This commit is also dangerous.

NEWS.txt:
 * better error message (Ian Goodfellow)