Skip to content

Commit

Permalink
Merge pull request #27 from rajulkumar/fix_hdrFromFdno
Browse files Browse the repository at this point in the history
Accept buffered IO stream objects as fd in hdrFromFdno
  • Loading branch information
rohanpm authored Jan 10, 2024
2 parents b90d721 + 4a80530 commit bef2c53
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 bef2c53

Please sign in to comment.