Fix crash during idna cleanup

This commit is contained in:
Oleksii Shevchuk 2018-09-23 23:04:17 +03:00
parent 26e9f464d0
commit fba47eee4f
1 changed files with 3 additions and 1 deletions

View File

@ -41,7 +41,9 @@ if not hasattr(os, 'stdout_write'):
# Remove IDNA module if it was not properly loaded
if hasattr(encodings, 'idna') and not hasattr(encodings.idna, 'getregentry'):
del sys.modules['encodings.idna']
if 'encodings.idna' in sys.modules:
del sys.modules['encodings.idna']
if 'idna' in encodings._cache:
del encodings._cache['idna']