Skip to content

Fix bugs affecting exception wrapping in rmtree callback #1700

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

Merged
merged 19 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clean up git.objects.submodule.base imports
This reorders them lexicographically within each group, makes
spacing/formatting more consistent, and removes the old comment
about needing a dict to set .name, which had originally been on
what later became the BytesIO import but had become separate from
it. (In Python 2, there was a cStringIO type, which could provide a
speed advantage over StringIO, but its instances, not having
instance dictionaries, didn't support the dynamic creation of new
attributes. This was changed to StringIO in 00ce31a to allow .name
to be added. It was changed to BytesIO in bc8c912 to work with
bytes on both Python 2 and Python 3. The comment about needing a
dict later ended up on the preceding line in 0210e39, at which
point its meaning was unclear. Because Python 2 is no longer
supported and Python 3 has no cStringIO type, the comment is no
longer needed, and this commit removes it.)
  • Loading branch information
EliahKagan committed Oct 8, 2023
commit 683a3eeba838bb786bb1f334c963deb8e13eed0f
24 changes: 9 additions & 15 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,37 @@
# need a dict to set bloody .name field
from io import BytesIO
import logging
import os
import os.path as osp
import stat
import uuid

import git
from git.cmd import Git
from git.compat import (
defenc,
is_win,
)
from git.config import SectionConstraint, GitConfigParser, cp
from git.compat import defenc, is_win
from git.config import GitConfigParser, SectionConstraint, cp
from git.exc import (
BadName,
InvalidGitRepositoryError,
NoSuchPathError,
RepositoryDirtyError,
BadName,
)
from git.objects.base import IndexObject, Object
from git.objects.util import TraversableIterableObj

from git.util import (
join_path_native,
to_native_path_linux,
IterableList,
RemoteProgress,
join_path_native,
rmtree,
to_native_path_linux,
unbare_repo,
IterableList,
)

import os.path as osp

from .util import (
SubmoduleConfigParser,
find_first_remote_branch,
mkhead,
sm_name,
sm_section,
SubmoduleConfigParser,
find_first_remote_branch,
)


Expand Down
2 changes: 1 addition & 1 deletion test/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def tearDown(self):
gc.collect()

# ACTUALLY skipped by git.util.rmtree (in local onerror function), from the last call to it via
# git.objects.submodule.base.Submodule.remove (at "handle separate bare repository"), line 1068.
# git.objects.submodule.base.Submodule.remove (at "handle separate bare repository"), line 1062.
#
# @skipIf(HIDE_WINDOWS_KNOWN_ERRORS,
# "FIXME: helper.wrapper fails with: PermissionError: [WinError 5] Access is denied: "
Expand Down
2 changes: 1 addition & 1 deletion test/test_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def _do_base_tests(self, rwrepo):
)

# ACTUALLY skipped by git.util.rmtree (in local onerror function), called via
# git.objects.submodule.base.Submodule.remove at "method(mp)", line 1017.
# git.objects.submodule.base.Submodule.remove at "method(mp)", line 1011.
#
# @skipIf(HIDE_WINDOWS_KNOWN_ERRORS,
# "FIXME: fails with: PermissionError: [WinError 32] The process cannot access the file because"
Expand Down