On Mon, Dec 31, 2018 at 07:45:52PM +1100, Stuart Prescott wrote: > Many years ago in doing the Python 2→3 port for python-debian, you wrote a > function to guard against giving file-like objects that were not file > handles to apt_pkg [1]. The reason I've been looking at this today is that > the current check incorrectly identifies NamedTemporaryFile as not being > a real file, while apt_pkg is happy to accept such objects. > > I *think* this can now be simplified as in the following commit, presumably > due to changes to the supported versions of Python we care about: > > https://salsa.debian.org/python-debian-team/python-debian/merge_requests/8/diffs#89edc1b4f3188ea0d56566993279f0a9b5ad7c3a_298_298
Prior to python-apt 0.7.90 (specifically https://salsa.debian.org/apt-team/python-apt/commit/62d7f4b80d56ef1e27039441cd6584cfb71d6502), apt_pkg.TagFile only accepted actual file objects. I think the code in python-debian that I was porting predated that change, and so did an isinstance check; I don't remember exactly what I was thinking when I did the port, but perhaps I didn't follow the history all the way through, or perhaps I was just trying to make the most conservative possible change. Nowadays the python-apt change in question is long in the past, so your change looks correct to me, since it more accurately describes what python-apt needs. I might be inclined to suggest renaming _is_real_file, since its name is a little misleading now. Maybe _has_fileno? -- Colin Watson [cjwat...@debian.org]