Fix regression in error message introduced in bpo-29951. (#2028)

* Fix regression in error message introduced in bpo-29951.

* Add test.

* Make the test more strong.
2 files changed