Skip to content

Instantly share code, notes, and snippets.

@wiiaboo
Created July 24, 2012 14:21
Show Gist options
  • Save wiiaboo/3170174 to your computer and use it in GitHub Desktop.
Save wiiaboo/3170174 to your computer and use it in GitHub Desktop.
Fix import exceptions to work with Python 3
diff --git a/animecheck.py b/animecheck.py
index b0e461e..03c74c8 100755
--- a/animecheck.py
+++ b/animecheck.py
@@ -32,7 +32,11 @@ There is NO WARRANTY, to the extent permitted by law.
'''
import codecs
-import exceptions
+# Python 3 doesn't have an exceptions module
+try:
+ from exceptions import IOError
+except:
+ pass
import hashlib
import io
import os
@@ -725,7 +729,7 @@ def currentHashingTask_error(e):
global currentHashingTask
# Dealing with various errors
- if isinstance(e, exceptions.IOError) and e.errno == 2:
+ if isinstance(e, IOError) and e.errno == 2:
# File not found error
currentHashingTask['errorFileNotFoundCount'] += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment