]> git.phdru.name Git - extfs.d.git/blobdiff - torrent
Fix(locale): Do not call `locale.getdefaultlocale()` under Python 3.11+
[extfs.d.git] / torrent
diff --git a/torrent b/torrent
index 63632420629529168b7325423f6b2df8413a57e1..1a3c2c17b302266296dc6bf1ac833d7d94bb1beb 100755 (executable)
--- a/torrent
+++ b/torrent
@@ -56,7 +56,10 @@ except ImportError:
 if use_locale:
     # Get the default charset.
     try:
-        lcAll = locale.getdefaultlocale()
+        if sys.version_info[:2] < (3, 11):
+            lcAll = locale.getdefaultlocale()
+        else:
+            lcAll = []
     except locale.Error as err:
         #print("WARNING:", err, file=sys.stderr)
         lcAll = []
@@ -265,7 +268,7 @@ def torrent_error(error_str):
 
 def decode_torrent():
     try:
-        torrent_file = open(sys.argv[2], 'r')
+        torrent_file = open(sys.argv[2], 'rb')
         data = torrent_file.read()
         torrent_file.close()
         return decode(data)