Skip to content

Commit

Permalink
Accept buffered IO stream objects as fd in hdrFromFdno
Browse files Browse the repository at this point in the history
fd arg to hdrFromFdno might be a buffered IO stream object
like the one returned by open(). As rpm.transaction.hdrFromFdno
accepts the buffered IO object as fd, the method here should
accept the object as well.
  • Loading branch information
rajulkumar committed Jan 10, 2024
1 parent b90d721 commit 4a80530
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/rpmdyn/_transaction.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from io import IOBase

from ._ffi import gc, cstr
from . import _ffi, _const

Expand Down Expand Up @@ -111,6 +113,11 @@ def getVSFlags(self):
return _ffi.rpmtsVSFlags(self.__ts)

def hdrFromFdno(self, fd):
# Accept the Buffered I/O stream object as fd. It inherits IOBase
# the proides the underlying FD number where available.
if isinstance(fd, IOBase):
fd = fd.fileno()

assert isinstance(fd, int)

rpmfd = _ffi.fdDup(fd)
Expand Down

0 comments on commit 4a80530

Please sign in to comment.