Use fd.tell() instead of going around through os.lseek() with fdno
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 15 Oct 2009 08:36:46 +0000 (11:36 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 15 Oct 2009 08:36:46 +0000 (11:36 +0300)
python/rpm/__init__.py

index 82e5f46..56a7295 100644 (file)
@@ -55,12 +55,12 @@ def readHeaderListFromFile(path, retrofit = True):
 def readHeaderFromFD(file_desc):
     if not isinstance(file_desc, fd):
         file_desc = fd(file_desc)
-    offset = os.lseek(file_desc.fileno(), 0, os.SEEK_CUR)
     try:
+        offset = file_desc.tell()
         h = hdr(file_desc)
-    except _rpm.error:
-        h = None
+    except (_rpm.error, IOError):
         offset = None
+        h = None
 
     return (h, offset)