Skip to content

pathlib.Path objects can be used as context managers #83863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
barneygale mannequin opened this issue Feb 19, 2020 · 16 comments
Closed

pathlib.Path objects can be used as context managers #83863

barneygale mannequin opened this issue Feb 19, 2020 · 16 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@barneygale
Copy link
Mannequin

barneygale mannequin commented Feb 19, 2020

BPO 39682
Nosy @brettcannon, @pitrou, @barneygale
PRs
  • bpo-39682: make pathlib.Path immutable by removing (undocumented) support for "closing" a path by using it as a context manager #18846
  • bpo-46556: emit DeprecationWarning from pathlib.Path.__enter__() #30971
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-04-01.14:11:09.381>
    created_at = <Date 2020-02-19.02:10:35.842>
    labels = ['type-bug', 'library', '3.9']
    title = 'pathlib.Path objects can be used as context managers'
    updated_at = <Date 2022-01-27.23:22:28.820>
    user = 'https://github.com/barneygale'

    bugs.python.org fields:

    activity = <Date 2022-01-27.23:22:28.820>
    actor = 'barneygale'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-04-01.14:11:09.381>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2020-02-19.02:10:35.842>
    creator = 'barneygale'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39682
    keywords = ['patch']
    message_count = 14.0
    messages = ['362244', '362840', '362934', '363206', '363209', '363218', '363260', '363261', '363285', '363298', '363383', '363468', '363469', '365473']
    nosy_count = 4.0
    nosy_names = ['brett.cannon', 'pitrou', 'Isaac Muse', 'barneygale']
    pr_nums = ['18846', '30971']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue39682'
    versions = ['Python 3.9']

    Linked PRs

    @barneygale
    Copy link
    Mannequin Author

    barneygale mannequin commented Feb 19, 2020

    pathlib.Path objects can be used as context managers, but this functionality is undocumented and makes little sense. Example:

    >>> import pathlib
    >>> root = pathlib.Path("/")
    >>> with root:
    ...     print(1)
    ... 
    1
    >>> with root:
    ...     print(2)
    ... 
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/barney/.pyenv/versions/3.7.3/lib/python3.7/pathlib.py", line 1028, in __enter__
        self._raise_closed()
      File "/home/barney/.pyenv/versions/3.7.3/lib/python3.7/pathlib.py", line 1035, in _raise_closed
        raise ValueError("I/O operation on closed path")
    ValueError: I/O operation on closed path

    Path objects don't acquire any resources on new/init/enter, nor do they release any resources on exit. The whole notion of the path being _closed seems to exist purely to make impure Path methods unusable after exiting from the context manager. I can't personally think of a compelling use case for this, and suggest that it be removed.

    @barneygale barneygale mannequin added 3.8 (EOL) end of life stdlib Python modules in the Lib dir labels Feb 19, 2020
    @brettcannon
    Copy link
    Member

    A use-case of "closing" a path is to cheaply flag that a path object is no longer valid, e.g. you deleted the underlying file and so you don't want others using the object anymore without paying the penalty of having to do the I/O to trigger the failure due to the path no longer existing.

    Now whether anyone is using this functionality I don't know, but removing it will inevitably break code for someone, so someone will need to make at least some form of an attempt to see if there's any use in the wild to justify simplifying the code by removing the functionality.

    @anntzer
    Copy link
    Mannequin

    anntzer mannequin commented Feb 28, 2020

    A problem of having this bit of state in paths is that it violates assumptions based on immutability/hashability, e.g. with

        from pathlib import Path
    
        p = Path("foo")
        q = Path("foo")
    
        with p: pass
    
        unique_paths = {p, q}
    
        print(len(unique_paths))  # == 1, as p == q
        for path in unique_paths:
            print(path.resolve())  # Fails if the path is closed.

    The last line fails with unique_paths = {p, q} as p has been closed (and apparently sets keep the first element when multiple "equal" elements are passed in), but not with unique_paths = {q, p}.

    It would also prevent optimizations based on immutability as proposed in https://bugs.python.org/issue39783.

    @brettcannon
    Copy link
    Member

    I guess a question is whether we want immutability guarantees (I for one didn't even know you could hash Path objects until now).

    I'm personally fine with that idea as it mentally makes sense to not need paths to be mutable. But as I said, someone needs to take at least some stab at seeing if any preexisting code out there will break if the _closed flag is removed before we can continue this discussion.

    @anntzer
    Copy link
    Mannequin

    anntzer mannequin commented Mar 2, 2020

    Immutability and hashability are listed first among "general properties" of paths (https://docs.python.org/3/library/pathlib.html#general-properties), and in the PEP proposing pathlib (https://www.python.org/dev/peps/pep-0428/#immutability). Looking at it again I *guess* the docs version could be read as only guaranteeing this for PurePaths (because that's in the PurePath section) rather than Path, but the PEP version clearly implies that this is true for both PurePaths and concrete Paths.

    It may be tricky to check usage in third-party packages, given that one would need to look for with <path-object>: ... rather than, say, a method name which can be grepped. Do you have any suggestions here?

    @pitrou
    Copy link
    Member

    pitrou commented Mar 2, 2020

    As with the Accessor abstraction, the original idea was to support Path objects backed by a directory file descriptor (for use with openat() and friends). That idea was abandoned but it looks like the context manager stayed. It's certainly not useful currently.

    @barneygale
    Copy link
    Mannequin Author

    barneygale mannequin commented Mar 3, 2020

    Can I ask what sort of backwards-compatibility guarantees Python provides for these cases? In the case of using a Path object as a context manager, I think we can say:

    • It's easy to do - there's no need to call any underscore-prefixed methods for example
    • It's undocumented
    • It's pretty hard to determine existing usage statically - grepping for `with p:` is years of work.

    @barneygale
    Copy link
    Mannequin Author

    barneygale mannequin commented Mar 3, 2020

    Also, thank you Antoine for your explanation :-)

    @brettcannon
    Copy link
    Member

    Can I ask what sort of backwards-compatibility guarantees Python provides for these cases?

    A deprecation warning for two releases (i.e. two years). Then it can be removed. So if people want to move forward with removing this then a DeprecationWarning would need to be raised in all places where _closed is set with a message stating the functionality is deprecated in 3.9 and slated for removal in 3.11 (along with appropriate doc updates, both for the module and What's New).

    @pitrou
    Copy link
    Member

    pitrou commented Mar 3, 2020

    Note you could simply remove the "closed" flag and the context manager live. That way, you don't have to deprecate anything.

    @brettcannon
    Copy link
    Member

    @antoine I just quite follow what you mean. Are you saying ditch _closed and just leave the context manager to be a no-op?

    @IsaacMuse
    Copy link
    Mannequin

    IsaacMuse mannequin commented Mar 6, 2020

    Brace expansion does not currently exist in Python's glob. You'd have to use a third party module to expand the braces and then run glob on each returned pattern, or use a third party module that implements a glob that does it for you.

    Shameless plug:

    Brace expansion: https://github.com/facelessuser/bracex

    Glob that does it for you (when the feature is enabled): https://github.com/facelessuser/wcmatch

    Now whether Python should integrate such behavior by default is another question.

    @IsaacMuse
    Copy link
    Mannequin

    IsaacMuse mannequin commented Mar 6, 2020

    Wrong thread sorry

    @pitrou
    Copy link
    Member

    pitrou commented Apr 1, 2020

    New changeset 00002e6 by Barney Gale in branch 'master':
    bpo-39682: make pathlib.Path immutable by removing (undocumented) support for "closing" a path by using it as a context manager (GH-18846)
    00002e6

    @pitrou pitrou closed this as completed Apr 1, 2020
    @pitrou pitrou added the type-bug An unexpected behavior, bug, or error label Apr 1, 2020
    @pitrou pitrou closed this as completed Apr 1, 2020
    @pitrou pitrou added type-bug An unexpected behavior, bug, or error 3.9 only security fixes and removed 3.8 (EOL) end of life labels Apr 1, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    skshetry added a commit to skshetry/hydra that referenced this issue Oct 15, 2022
    Path as a contextmanager is deprecated from 3.11 onwards, and was a
    no-op since Python 3.11. Also this functionality was never documented.
    
    See [cpython/Lib/pathlib.py#L810-L816][1], python/cpython#83863 and, python/cpython#90714.
    
    [1]: https://github.com/python/cpython/blob/120b4ab2b68aebf96ce0de243eab89a25fc2d282/Lib/pathlib.py#L810-L816
    skshetry added a commit to skshetry/hydra that referenced this issue Oct 15, 2022
    Path as a contextmanager is deprecated from 3.11 onwards, and was a
    no-op since Python 3.9. Also this functionality was never documented.
    
    See [cpython/Lib/pathlib.py#L810-L816][1], python/cpython#83863 and, python/cpython#90714.
    
    [1]: https://github.com/python/cpython/blob/120b4ab2b68aebf96ce0de243eab89a25fc2d282/Lib/pathlib.py#L810-L816
    pixelb pushed a commit to facebookresearch/hydra that referenced this issue Oct 17, 2022
    Path as a contextmanager is deprecated from 3.11 onwards, and was a
    no-op since Python 3.9. Also this functionality was never documented.
    
    See [cpython/Lib/pathlib.py#L810-L816][1], python/cpython#83863 and, python/cpython#90714.
    
    [1]: https://github.com/python/cpython/blob/120b4ab2b68aebf96ce0de243eab89a25fc2d282/Lib/pathlib.py#L810-L816
    barneygale added a commit to barneygale/cpython that referenced this issue May 23, 2023
    …ext managers
    
    In Python 3.8 and prior, `pathlib.Path.__exit__()` marked a path as closed;
    some subsequent attempts to perform I/O would raise an IOError. This
    functionality was never documented, and had the effect of making `Path`
    objects mutable, contrary to PEP 428. In Python 3.9 we made `__exit__()` a
    no-op, and in 3.11 `__enter__()` began raising deprecation warnings. Here
    we remove both methods.
    barneygale added a commit that referenced this issue May 23, 2023
    …nagers (GH-104807)
    
    In Python 3.8 and prior, `pathlib.Path.__exit__()` marked a path as closed;
    some subsequent attempts to perform I/O would raise an IOError. This
    functionality was never documented, and had the effect of making `Path`
    objects mutable, contrary to PEP 428. In Python 3.9 we made `__exit__()` a
    no-op, and in 3.11 `__enter__()` began raising deprecation warnings. Here
    we remove both methods.
    @andrewshadura
    Copy link

    Oh well. I was actually using this functionality.
    It was super convenient to do something like:

    with Path('debian') / 'fill.copyright.blanks.yml' as debian_copyright_overrides:
        if debian_copyright_overrides.is_file():
            ...
        else:
            ...

    Basically it was a very visual way to structure code that worked with different subpaths. So no matter that it didn’t "close" path, it allowed to temporarily assign a shortcut to that path, do some work, and then forget about it.

    @barneygale
    Copy link
    Contributor

    Perhaps contextlib.nullcontext() would help?

    But context managers are all about acquiring and releasing resources. It could be considered misleading to use a context manager only for code formating purposes. I would write:

    debian_copyright_overrides = Path('debian') / 'fill.copyright.blanks.yml'
    if debian_copyright_overrides.is_file():
        ...
    else:
        ...

    agx added a commit to agx/git-buildpackage that referenced this issue Jan 9, 2025
    Python's breaks backward compatibility without being helpful.
    
    See python/cpython#83863
    
    This fixes running gbp with Pythone 3.13
    
    Signed-off-by: Guido Günther <agx@sigxcpu.org>
    mhy-pexip pushed a commit to pexip/os-git-buildpackage that referenced this issue Apr 28, 2025
    git-buildpackage (0.9.38) unstable; urgency=medium
    .
      [ Otto Kekäläinen ]
      * [b15709f] config: Enable 'multimaint-merge' by default.
        There are currently 735 packages[1] that default to 'True' for this
        option and seems most no maintainer would manually write a
        debian/changelog with the same maintainer repeated, so this would be a
        better default.
        Also, devscripts itself recently changed this and will have it enabled
        by default in version 2.25.1+.
      * [f7ce004] docs: Add diagram to manual to help readers grasp the DEP-14 branches.
    .
      [ Andrew Kreimer ]
      * [b44226e] docs: fix typos.
    .
      [ Guido Günther ]
      * [89b0995] ci: Run codespell. We run it on th doc folder.
      * [a6f65c1] docs: Mention DCO.Hopefully we get more commits with
        `Signed-off-by:`.
      * [2a30c7a] import-orig: Keep upstream branch on initial import.
        When importing a new package we want to keep both upstream and debian
        branch as otherwise the user has an extra manual step of recreating the
        branch.
      * [091b811] docs: Modernize creating a new package.  With upcoming support
        for gbp.conf in dh_make let's modernize the docs a bit and use `*/latest`
        there too.
      * [462d5f7] clone: Ensure attribute changes are applied past clone.
        This makes sure changes due to the added gitattributes take effect in
        the checkout. This helps e.g. kotlin wich otherwise has
          $ git status
          [..snip..]
          Changes not staged for commit:
          (use "git add <file>..." to update what will be committed)
          (use "git restore <file>..." to discard changes in working directory)
        	modified:   compiler/cli/bin/kapt.bat
        	modified:   compiler/cli/bin/kotlin-dce-js.bat
        	modified:   compiler/cli/bin/kotlin.bat
        	modified:   compiler/cli/bin/kotlinc-js.bat
        	modified:   compiler/cli/bin/kotlinc-jvm.bat
        	modified:   compiler/cli/bin/kotlinc.bat
        after
           gbp clone vcsgit:kotlin
        Helps: #1092800
      * [ed0bb53] tests: Check that git attributes are disarmed.
        Add a test for
           462d5f75 ("clone: Ensure attribute changes are applied past clone")
        to ensure git attributes aren't applied and the working copy stays
        clean. Based on bits from !38 by Julien Plissonneau Duquène
      * [6512a0d] changelog: Don't capture dch's stderr.  Otherwise we'll never
        see it
    .
      [ Gioele Barabucci ]
      * [7beb71e] buildpackage: Allow both DEP-14 and DEP14 as values for `dist`
      * [67baaae] Consistently use DEP-X in documentation and error messages.
        The consensus on debian-devel is that "DEP-X" should be preferred
        to "DEPX" and "DEP X".
        See: https://lists.debian.org/debian-devel/2024/11/msg00141.html
    .
      [ Richard Hansen ]
      * [69afa42] packaging: Bump Python version for `type` statement.
        The `type` statement was added in Python 3.12.
      * [ec76596] packaging: Remove unused python3-filelock dependency.
        This reverts commit 5155e98b3cac28a32f20ac369e28e9fa78676fd4.
      * [240fbb4] packaging: Mark test build dependencies as !nocheck
      * [971d253] packaging: Fix python3-notify2 suggestion for git-buildpackage-rpm
      * [117f3ed] build: Drop exact version requirement for flake8
        v3.5.0 hasn't been supported since at least Python 3.9.
      * [7b6408a] build: Change coverage dependency to pytest-cov.
        Testing fails if pytest-cov isn't installed.
      * [b4e2e8f] build: Add missing requirements to requirements.txt
      * [ebd478d] build: Add a venv target to Makefile for convenience
      * [f251b86] build: Make it easier to override python executable in Makefile.
        Now users can do `make PYTHON=python3.12` to force a particular
        version of Python if desired.
    .
      [ Julien Plissonneau Duquène ]
      * [a738315] Pass --download-version to uscan
    .
    git-buildpackage (0.9.37) unstable; urgency=medium
    .
      [ Guido Günther ]
      * [9551420] import-orig: Add mention of --upstream-vcs-tag to description.
        This makes it hopefully easier to discover.
      * [9a2507e] setup: Require python 3.11.
        We don't test it on anything older. (Closes: #1091851)
      * [005676a] buildpackage: Make sure export_dir is always set.
        Fixes c9cc8df4 ("buildpackage: remove export_dir if build fails")
        (Closes: #1091554)
      * [ae6f841] repo-setup: Drop context manager for posix path.
        Python's breaks backward compatibility without being helpful.
        See python/cpython#83863
        This fixes running gbp with Pythone 3.13
    .
      [ Otto Kekäläinen ]
      * [ec9ee37] docs: Clarify and unify the purpose of each command in the man pages.
        Update the <refpurpose> field in each command to better capture the main
        purpose of the command, and ensure the main `gbp (1)` man page uses the
        same text to avoid them from diverging.
      * [f3036fb] docs: Add examples sections where missing, and enrich examples.
        Most commands should have an EXAMPLES section on the man page, and the
        first 1-2 examples should show what are the most common invocations.
    .
    git-buildpackage (0.9.36) unstable; urgency=medium
    .
      [ Michael R. Crusoe ]
      * [aee0584] Idiomatic usage of pytest, remove almost all traces of nose
        (Closes: #1018367)
    .
      [ Guido Günther ]
      * [4c63abd] d/control: Drop dependency on pkg-resources (Closes: #1083415)
      * [f243658] docs: Mardownify development hints
      * [379e63f] docs: Adjust test invocations for pytest. It's different from
        nose, sigh
      * [1f1f7f2] docs: Link to hacking
      * [a699d3b] docs: Add merge request URL
      * [45b2d4f] docs: Clean up markdown. Make mdl happy.
      * [5495aa6] docs: Use application instead of product.
        Avoids the ™. See
            https://tdg.docbook.org/tdg/5.1/application
        While at that move all applications into their own block
      * [ae431af] docs: Use entities for lintian and rpm-lint.
        We use command rather than productname as the related text refers to
        running external commands.
      * [9c1ec80] dirlocals: Avoid tabs in xml mode
      * [e19f76e] docs: intro: Make first point more crisp
      * [e0e1102] docs: intro: Use <filename> around debian/changelog
      * [dc42093] docs: intro: Mention that we support push and pull
      * [12287be] docs: intro: Mention gbp push.
        The initial paragraph was written before gbp push existed.
      * [3d34a37] tests: Strip result.
        This unbreaks CI and lets us work with recent and older
        dpkg-parsechangelog.
      * [8396466] build: Allow to pass args to mypy. Useful in CI
      * [a3472d3] ci: Add upstream pipeline. Do the linting and checking before
        running salsa-ci
      * [f7c50a1] ci: Store ruff result as junit. Makes things easier to read in
        gitlab
      * [e228fed] ci: Run typecheck
      * [59b3da2] upstreamsource: Add some types for tarball lists.
        We need to slightly tweak the code for this
      * [80e5964] pristine-tar: Move import to its own function. Rename debsource
        to source while at that to match other scripts
      * [0365f5c] pristine-tar: Import upstream signatures too. Otherwise we're
        not consistent with import-orig
      * [55a5925] tests: Skip repo creation test in CI. We have too many perms
      * [c8dfce0] build: Allow to pass extra args to pytest. Useful in ci.
      * [0337772] ci: Run pytests. This allows us to run the tests that need
        network as well
      * [1930a4a] ci: Fetch deb packaging data.
        Enables us to run the deb based component tests. We do this for the test
        job only as the others don't need the submodules to work.
        The rpm component tests need more work so we don't fetch the subodule
        yet.
      * [69f1fe7] packaging: Don't run flake8.
        This makes the package build more robust as we don't have to worry about
        new formatting warnings/errors which don't affect the functionality of
        the package.
      * [15fe75e] ci: Use ci pipelines and robustify CI runs. Cancel running jobs
        to save resources
      * [4f28776] ci: Run ci-fairy. This keeps commit messages sane
      * [2c5d94d] tests: Ease checking exit status. Print the error log when exit
        status is not 0
      * [7a9c89c] tests/clone: Print logs on failure. Eases debugging in CI
      * [83af90e] ci: Enable tests that need network access
      * [fb6d859] ci: Run shell checks. We can drop them from the packaging run.
      * [410df5f] packaging: Drop test dependencies. We run the tests in CI
      * [b6aaa8e] tests: Enable coverage reports and coverage percentage
      * [6ff6117] gbp: Add pipes module verbatim from Python 3.12.8
      * [e401bae] pipes: Drop deprecation warning. Drop the deprecation warning,
        add a copyright header and make flake8 happy.
      * [43d4b3b] pipes: Use shlex.quote. Ensures we don't leak pipe.quote
      * [87e5905] gbp: Use our bundled pipes module (Closes: #1084672)
    .
      [ Otto Kekäläinen ]
      * [ea20cff] Support numerical prefix in suite names.
        E.g. '12-bookworm' or '24.04-noble'.
        Repositories that have many parallel releases in maintenance are easier
        to manage when the suites have a number prefix so they sort alphabetically
        correctly, and also causes less cognitive load in trying to remember what
        release number and name to put in debian/changelog.
      * [dd3bba9] Document vendor detection and sort names alphabetically
      * [b8e75c6] docs: Consistently use 'upsreamvcs' as git remote for upstream
      * [a92b54d] docs: Misc minor tweaks and fixes
        * Fix one stray use of 'debian/sid' missed in 4dc9a6ce
        * Mention DEP-14 layout on page about branches
        * Update links to upstream Git homepage and to salsa.debian.org
        * Replace link 'here' with actual manual URL to make the link readable
        * Use https in links
        * Remove trailing white space
      * [14e2a30] docs: Use the shorter URL to online manual, and promote it in man pages too.
        Shorter is better and prettier, so promote https://gbp.sigxcpu.org/manual/
        over the long URL. Also promote this in the introduction of the most
        important man pages, as currently the anyone reading the man pages will
        not discover the online manual as the links are missing.
        The only link in the manpages currently is a local link, which does not
        render at all at e.g. https://manpages.debian.org/bookworm/git-buildpackage/git-buildpackage.1.en.html
      * [7ae9847] docs: Clarify that 'upstream' branch doesn't mean actual upstream branch.
        Correct common misunderstanding that the gbp 'upstream' branch is not
        the actual upstream branch, but a custom branch that represents the
        source code at the time of the release, and which together with the
        pristine-tar is used to reconstruct the upstream source code as-is.
        Co-authored-by: Guido Günther <agx@debian.org>
      * [1187384] docs: gbp-clone: Clarify commands and include --add-upstream-vcs in example.
        Also unify the use of `<screen>` syntax in examples to avoid excess
        whitespace, and fix some indentation.
        Use `vcs-git:` in examples to avoid confusing reader with multiple options
        for the exact same thing. Choose this spelling as it will be correctly
        associated with the `Vcs-Git:` field in the `debian/control` file in the
        mind of Debian maintainers/developers.
      * [74d059a] docs: Improve intro to better summarize what git-buildpackage can do
      * [3fc948a] docs: Extend intro mentioning uscan, pristine-tar, debchange, debuild etc.
        Extend the intro to mention that git-buildpackage uses under the hood
        many existing core Debian packaging tools. This is important as it gives
        new readers a better understanding of how git-buildpackage operates, in
        particular if they are experienced Debian packagers.
    .
      [ Chris Lamb ]
      * [c224b03] Prevent "pq export" (etc.) from creating unparsable diffs when diff.noprefix=true is set.
        Using diff.noprefix=true globally makes Git nicer to use as a human, as it
        makes it possible to copy file paths when running git diff (etc.) on the
        command line.
        Otherwise, you typically see filenames which technically don't exist. For
        instance, these files aren't under a directory called "a" or "b" at all; they
        are placeholders:
          --- a/tochange.py
          +++ b/tochange.py
        However, when this global option is set, "pq export" will serialise the patch
        branch into debian/patches with the filenames missing the prefix, which
        dpkg-source then can't actually parse and it errors out. In other words, they
        look like this:
          --- tochange.py
          +++ tochange.py
        A patch is attached that overrides diff.noprefix when calling out to
        "git diff", meaning that it will use "a/" and "b/" as expected. This
        seems somewhat analogous to overriding the user's core.abbrev setting.
        (Closes: #1088032)
    .
      [ Richard Lewis ]
      * [c9cc8df] buildpackage: remove export_dir if build fails.
        Previously, the export_dir was not removed if the build command
        (set by --git-builder) failed, or was interrupted.
        This commit ensures it is removed, unless --git-no-purge is used
        Not removing is useful for debugging, but does not need to be the
        default (Closes: #1088179)
      * [663b3ff] gbp: Use shlex.quote rather than pipe.quote
    .
      [ Travis Wrightsman ]
      * [2914c03] docs: Add import-ref to gbp(1)
    .
    git-buildpackage (0.9.35) unstable; urgency=medium
    .
      [ Guido Günther ]
      * [09d65cb] Use pythons builtin mock
      * [360222d] d/control: Let Vcs-* point to salsa
      * [ca70762] import: Use debian/latest.
        It's the recommended layout
      * [4dc9a6c] docs: Prefer debian/latest over debian/sid.
        This is more widespread nowadays and ensures the latest upstream
        version is always in the repositories default branch.
      * [a88e01e] Drop completely outdated tox.ini
      * [5c8f1af] Drop travis CI file.
        We use salsa's CI and haven't used travis CI since ages.
      * [8e494cb] tests: Merge the repository doctests.
        We use a single doctest as module scoped fixtures can't be used with
        doctests in pytest
      * [d21fead] tests: Merge the pristine-tar doctests.
        We use a single doctest as module scoped fixtures can't be used with
        doctests in pytest
      * [33f4884] build: Run tests through pytest.
        We still use nose's assertions. See
        https://github.com/pytest-dev/nose2pytest on how to convert those in the
        future so can't drop the dependency yet.
        Closes: #1080224
        Helps: #1018367
      * [a553f93] rpm: Mark two tests as xfail.
        Needs debugging why they regressed as there weren't any changes in that
        area recently.
      * [54bec6e] tests/component: Fix skipping tests when submodules are no
        present.  Rework the logic to work with pytest instead of nose
      * [3a87c05] tests/component/rpm: Fix skipping tests with pytest.
        Rework the logic to work with pytest instead of nose
    .
      [ Ferenc Wágner ]
      * [aa468c0] dscfile.py: decide native/non-native based on diff presence, not
        version format. Source format 1.0 native packages with a hyphen in their
        version number were mistaken by the original code for non-native.
      * [1fecdcd] 12_test_deb: add test for native 1.0 DSC with Debian revision
    .
    git-buildpackage (0.9.34) unstable; urgency=medium
    .
      [ Otto Kekäläinen ]
      * [dbd1b36] salsa-ci: Disable SALSA_CI_DISABLE_VERSION_BUMP.
        Disabling the version automatic version bump in Salsa-CI satisfies
        Python setuptools and build passes.
      * [ae2d10c] docs: Fix misc spelling in documentation.
        In code standardize on using 'commitish' while docs have 'commit-ish'
        like upstream git convention seems to be.
      * [a0e45c6] gbp: Fix misc spelling in user visible output and comments
      * [42c3e15] debian: Fix misc spelling.
        The debian/changelog has many spelling errors but not touching them now
        as changing past changelog entries might be contentious.
      * [13f5205] tests: Implement 'run-in-docker -c docker'
        Typically developers have either Docker or Podman on their laptops for
        running containers. As Podman follows nearly identical syntax as Docker,
        add new option '-c' that allows to specify Podman or Docker as the
        container command, with Podman being default if nothing is defined as
        the main developer is using Podman.
        Also ignore log files both in .gitignore and resulting .dockerignore so
        that tests runs can be logged with 'tee x.log' without triggering
        rebuilds of the container via polluting the 'COPY . .' step.
      * [6df86f9] tests: Avoid busting container layer cache on every file change
      * [c7c73d3] tests: Capitalize Dockerfile commands to follow to formal syntax.
        This is necessary to be able to use static Dockerfile analyzers.
      * [4940747] tests: Fix shell syntax issues in run-in-container.
        If 'run-in-container x' was issued, script would fail silently. With
        this change it will properly exit with 'bad action: x' and help message.
        Also fix a bunch of other minor issues detected by ShellCheck.
      * [dd891c6] tests: Rename run-in-docker to run-in-container to be more generic
    .
      [ Guido Günther ]
      * [75cda52] Validate shell completion functions.
        For zsh we can at least catch syntax errors and use shellcheck for
        bash.
      * [2f47ec4] setup: Move most options to setup.cfg.
        We can move everything that doesn't depend on running a script
        or evaluating environment variables.
      * [307f8ad] docs: Drop NEWS
        dh_installchangelogs handles that
      * [af15aad] rpm: Adjust to new gbp.conf install path.
        To make setup.py happy we moved to an underscore path name in
            2f47ec4c ("setup: Move most options to setup.cfg")
      * [ef0211c] tests: shellcheck packaging-in-container too.
        Now that is passes let's make sure it stays that way.
      * [dca6702] dscfile: Use "file" as context manager.
        Closes the file automatically. Move parsing out of the constructor
        while at that.
      * [2ba5b93] dscfile: Improve error when dsc file isn't UTF-8
        (Closes: #1072387)
      * [c0b776c] examples/zeitgest: Exit early if we don't find the python module.
        Don't use `unicode` while at that.
      * [1233918] rpm: Prefer isinstance() over type()
      * [cbce318] rpm: Prefer 'not in' for membership tests
      * [6166d74] tristate: Prefer isinstance() over type()
      * [9650f68] tests: Prefer isinstance() over type()
      * [364eccb] tests: Clarify noqa tags.
        Ruff is more strict than flake8 here
      * [ff276e5] Add linter configs
      * [077cc51] ci: Run ruff
      * [0d7193b] tests: Avoid assertEquals.
        Python 3.12 dropped it. I just wish there would be deprecations.
      * [dde9e7d] tests: Avoid assertRaisesRegexp.
        Python 3.12 dropped it. I just wish there would be deprecations.
      * [15f3b8c] Drop format_b.
        We require python 3.5 anyway and Python 3.12 dropped decode from string.
        (Closes: #1074681)
    .
      [ Jochen Sprickerhof ]
      * [026cd23] pull: Allow pull in unclean repos.
        This works just fine when git can fast forward, i.e. with untracked
        content or changes in tracked files that are not touched by the commits.
        In case fast forward is not possible gbp will complain anyhow.
    .
      [ Carlos Henrique Lima Melara ]
      * [385291f] docs: document how to send the tip of debian-branch with gbp push.
        When --debian-tag is set to '' empty string, gbp will push the tip of
        the debian branch to remote.
        Small typo fix also: s/branach/branch/
    .
      [ Sven Geuer ]
      * [1d814b9] docs: create_repo uses DEBFULLNAME not DEBUSER.
        Make the docs match.
    .
    git-buildpackage (0.9.33) unstable; urgency=medium
    .
      [ Evangelos Ribeiro Tzaras ]
      * [f6d90d5] docs: gbp-clone: Fix small typo and fix metadata file name
    .
      [ Guido Günther ]
      * [6923df4] config: Catch DuplicateOption errors.
        Nicer than printing a stack trace
      * [8deb2e1] tests: Make flake8 happy (Closes: #1058551)
    .
      [ Taihsiang Ho (tai271828) ]
      * [d1a9745] d/control: Specify required git version as dependency.
        Explicitly specify the git version to facilitate easier backporting.
        Developers can align with this git version to reduce false alarms due
        to version inconsistencies.
    .
    git-buildpackage (0.9.32) unstable; urgency=medium
    .
      * Upload to unstable
        Closes: #1042188
    .
    git-buildpackage (0.9.31) experimental; urgency=medium
    .
      [ Guido Günther ]
      * Upload to experimental.
        gbp-import-orig when used with --upstream-vcs-tag now strips extensions like
        'dfsg', 'ds' or 'repack' from upstream version numbers and handles the
        'really' convention. Let's test this in experimental before uploading to
        unstable.
      * [cf5b2ad] config: Print sensible error message on duplicate sections.
        Don't confuse users with a backtrace.
      * [a420bc9] gbp/deb/git: Don't strip ~ patterns unconditionally.
        They're needed when packaging upstream beta versions. So use
        a positive list instead.
        Fixes: a5575e178639a8e167c7f3090263a03b362e05e7
      * [9c4841e] d/rules: Check for DEB_BUILD_OPTIONS
      * [e358254] dch: Catch d/control parse errors too.
        Print a clear error message instead of hiding it in the backtrace.
        Thanks to Mechtilde Stehmann for the report
      * [4f909d2] pq: Roll back on all errors.
        Drop the pq branch on all exceptions not only on the ones gbp throws
        itself. This makes sure the result is consistent in such situations (no
        patches applied).
      * [8dfec59] patch_series: Ignore whitespace lines.
        E.g. python-coverage has a form feed in the series file.
        Thanks to Ian Jackson for the detailed report (Closes: #1030534)
      * [c72464b] gbp-upload: Check if remote exists
    .
      [ Akbarkhon Variskhanov ]
      * [afcd15b] create-remote-repo.xml: Fix minor typo
    .
      [ Samuel Henrique ]
      * [11728ec] rpm/policy: Add missing dash before version in RPM changelog header.
    .
      [ Huw Jones ]
      * [3434531] repository.create_tag: Explicitly don't sign when sign=False.
        This avoids `tag.gpgsign = true` from git-config leaking through.
        (Closes: #1032932)
    .
      [ Richard Laager ]
      * [29370b5] import-orig: Parse various Debian version patterns.
        This parses common Debian version patterns into the "real" upstream
        version.  For example, 1.1.8+dfsg1 becomes 1.1.8.  This strips epochs,
        handles the +really convention, finds git revisions, and strips other +
        or ~ patterns. (Closes: #968329)
    .
      [ Junichi Uekawa ]
      * [f0e9d41] docs: gbp-pq manpage: refer to the moved location
        gbp-pq manpage refers to a page that says the content has moved.
        I think it can refer to the local html copy[1], or the internet copy.
        [1] /usr/share/doc/git-buildpackage/manual-html/gbp.patches.html
        (Closes: #1035838)
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants