python-podman icon indicating copy to clipboard operation
python-podman copied to clipboard

Images.build incorrectly uses os.walk

Open eddsalkield opened this issue 4 years ago • 0 comments

The method podman/libs/images.py#Images.build runs os.walk, and expects it to return a list of files from context_directory. It actually yields a 3-tuple (dirpath, dirnames, filenames) as described here. Later, when trying to add files into the tar archive (line 176), the program fails with error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/edd/.local/lib/python3.8/site-packages/podman/libs/images.py", line 189, in build
    tar.addfile(tar.gettarinfo(fileobj=open(name)))
TypeError: expected str, bytes or os.PathLike object, not tuple

While we're at it, how is this code expected to function when encountering an empty directory?

eddsalkield avatar Apr 19 '20 16:04 eddsalkield