Message 250578 - Python tracker

Message250578

Author desbma
Recipients desbma, martin.panter, python-dev, r.david.murray
Date 2015-09-13.17:18:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1442164680.41.0.014274463486.issue25063@psf.upfronthosting.co.za>
In-reply-to
Content
If I understand you correctly, a naive implementation like this:

use_chunk_copy = False
try:
  fdsrc = fsrc.fileno()
  fddst = fdst.fileno()
except OSError:
  # fallback on current chunk based Python copy
  use_chunk_copy = True
else:
  # we have 2 fd, try sendfile
  try:
    os.sendfile(fdsrc, fddst)
  except AttributeError:
    # sendfile not available
    use_chunk_copy = True
if use_chunk_copy:
  # use current Python based chunk copy

...would not work because some file like objects expose fileno(), even though it does not accurately represent the file because they wrap it to add special behavior (like GzipFile).

I don't understand, if they alter the file behavior, why do they expose fileno()?
History
Date User Action Args
2015-09-13 17:18:00desbmasetrecipients: + desbma, r.david.murray, python-dev, martin.panter
2015-09-13 17:18:00desbmasetmessageid: <1442164680.41.0.014274463486.issue25063@psf.upfronthosting.co.za>
2015-09-13 17:18:00desbmalinkissue25063 messages
2015-09-13 17:18:00desbmacreate