Index: Doc/library/tarfile.rst =================================================================== --- Doc/library/tarfile.rst (revision 88190) +++ Doc/library/tarfile.rst (working copy) @@ -370,19 +370,20 @@ and :meth:`close`, and also supports iteration over its lines. -.. method:: TarFile.add(name, arcname=None, recursive=True, exclude=None, filter=None) +.. method:: TarFile.add(name, arcname=None, recursive=True, exclude=None, *, filter=None) - Add the file *name* to the archive. *name* may be any type of file (directory, - fifo, symbolic link, etc.). If given, *arcname* specifies an alternative name - for the file in the archive. Directories are added recursively by default. This - can be avoided by setting *recursive* to :const:`False`. If *exclude* is given, - it must be a function that takes one filename argument and returns a boolean - value. Depending on this value the respective file is either excluded - (:const:`True`) or added (:const:`False`). If *filter* is specified it must - be a function that takes a :class:`TarInfo` object argument and returns the - changed :class:`TarInfo` object. If it instead returns :const:`None` the :class:`TarInfo` - object will be excluded from the archive. See :ref:`tar-examples` for an - example. + Add the file *name* to the archive. *name* may be any type of file + (directory, fifo, symbolic link, etc.). If given, *arcname* specifies an + alternative name for the file in the archive. Directories are added + recursively by default. This can be avoided by setting *recursive* to + :const:`False`. If *exclude* is given, it must be a function that takes one + filename argument and returns a boolean value. Depending on this value the + respective file is either excluded (:const:`True`) or added + (:const:`False`). If *filter* is specified it must be a keyword argument. It + should be a function that takes a :class:`TarInfo` object argument and + returns the changed :class:`TarInfo` object. If it instead returns + :const:`None` the :class:`TarInfo` object will be excluded from the + archive. See :ref:`tar-examples` for an example. .. versionchanged:: 3.2 Added the *filter* parameter. Index: Lib/tarfile.py =================================================================== --- Lib/tarfile.py (revision 88190) +++ Lib/tarfile.py (working copy) @@ -2025,7 +2025,7 @@ print("link to", tarinfo.linkname, end=' ') print() - def add(self, name, arcname=None, recursive=True, exclude=None, filter=None): + def add(self, name, arcname=None, recursive=True, exclude=None, *, filter=None): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. @@ -2082,7 +2082,7 @@ if recursive: for f in os.listdir(name): self.add(os.path.join(name, f), os.path.join(arcname, f), - recursive, exclude, filter) + recursive, exclude, filter=filter) else: self.addfile(tarinfo)