diff --git a/kcc/rarfile.py b/kcc/rarfile.py index 567f5ce..afb19a7 100644 --- a/kcc/rarfile.py +++ b/kcc/rarfile.py @@ -360,9 +360,8 @@ class RarCannotExec(RarExecError): def is_rarfile(xfile): '''Check quickly whether file is rar archive.''' - fd = XFile(xfile) - buf = fd.read(len(RAR_ID)) - fd.close() + with open(xfile, 'rb') as fh: + buf = fh.read(len(RAR_ID)) if buf == RAR_ID or buf == RAR5_ID: return True else: