sys.getdefaultencoding() can return None.
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index 3110ea9..627e42f 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -86,6 +86,7 @@
 
         # the return encoding can be uppercase
         fs_encoding = sys.getfilesystemencoding().lower()
+        fs_encoding = fs_encoding.lower() if fs_encoding else 'ascii'
 
         # covers utf-8 and Windows ANSI code pages
         # one non-space symbol from every page