[GRASS-dev] [GRASS GIS] #3812: Specifying output in r.pack fails if you give a filename with no extension

#3812: Specifying output in r.pack fails if you give a filename with no extension
-------------------------+-------------------------
Reporter: pmav99 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Raster | Version: unspecified
Keywords: | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
{{{
# This fails
$ r.pack input=elevation output=/tmp/packs/raster/elevation
Packing <elevation@PERMANENT> to </tmp/packs/raster/elevation>...
Traceback (most recent call last):
   File "/home/feanor/Prog/git/grass-p3/repo/dist.x86_64-pc-linux-
gnu/scripts/r.pack", line 128, in <module>
     sys.exit(main())
   File "/home/feanor/Prog/git/grass-p3/repo/dist.x86_64-pc-linux-
gnu/scripts/r.pack", line 112, in main
     tar = tarfile.TarFile.open(name=outfile_base, mode='w:gz')
   File "/usr/lib/python3.7/tarfile.py", line 1591, in open
     return func(name, filemode, fileobj, **kwargs)
   File "/usr/lib/python3.7/tarfile.py", line 1638, in gzopen
     fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
   File "/usr/lib/python3.7/gzip.py", line 163, in __init__
     fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
IsADirectoryError: [Errno 21] Is a directory: 'elevation'

# This works...
$ r.pack input=elevation output=/tmp/packs/raster/elevation.pack
Packing <elevation@PERMANENT> to </tmp/packs/raster/elevation.pack>...
}}}

If an extension is expected, it should be documented. That being said the
exception type is rather confusing.

For the record, {{{v.pack}}} does not raise this error.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3812&gt;
GRASS GIS <https://grass.osgeo.org>