コード例 #1
0
def test_filesys_decode_fs_encoding_is_None(monkeypatch):
    """
    Test filesys_decode does not raise TypeError when
    getfilesystemencoding returns None.
    """
    monkeypatch.setattr('sys.getfilesystemencoding', lambda: None)
    unicode_utils.filesys_decode(b'test')
コード例 #2
0
ファイル: egg_info.py プロジェクト: 0x00xw/wooyun
    def _safe_path(self, path):
        enc_warn = "'%s' not %s encodable -- skipping"

        # To avoid accidental trans-codings errors, first to unicode
        u_path = unicode_utils.filesys_decode(path)
        if u_path is None:
            log.warn("'%s' in unexpected encoding -- skipping" % path)
            return False

        # Must ensure utf-8 encodability
        utf8_path = unicode_utils.try_encode(u_path, "utf-8")
        if utf8_path is None:
            log.warn(enc_warn, path, 'utf-8')
            return False

        try:
            # accept is either way checks out
            if os.path.exists(u_path) or os.path.exists(utf8_path):
                return True
        # this will catch any encode errors decoding u_path
        except UnicodeEncodeError:
            log.warn(enc_warn, path, sys.getfilesystemencoding())
コード例 #3
0
ファイル: egg_info.py プロジェクト: 0x00xw/wooyun
 def _manifest_normalize(self, path):
     path = unicode_utils.filesys_decode(path)
     return path.replace(os.sep, '/')
コード例 #4
0
ファイル: egg_info.py プロジェクト: 000-whoami-000/API
 def _manifest_normalize(self, path):
     path = unicode_utils.filesys_decode(path)
     return path.replace(os.sep, '/')