bpo-33354 Skip test_load_dh_params when python filesystem encoding cannot decode path by pablogsal · Pull Request #6613 · python/cpython
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decoding an Unicode string doesn't make any sense :-) Moreover, you have to specify the encoding. The default encoding is ASCII, whereas the question here is if the string can be encoded to sys.getfilesystemencoding().
I propose:
fs_encoding = getfilesystemencoding()
try:
filename.encode(fs_encoding)
except UnicodeEncodeError:
self.skipTest("filename %r cannot be encoded to the filesystem encoding %r" % (filename, fs_encoding))
It would provide better skip message to check if the test is skipped for good reasons, or not ;-)