back to OpenHands summary
OpenHands: dulwich
Pytest Summary for test tests
status |
count |
failed |
959 |
skipped |
13 |
passed |
40 |
error |
10 |
xfailed |
1 |
total |
1023 |
collected |
1023 |
Failed pytests:
test_client.py::DulwichTCPClientTest::test_archive
test_client.py::DulwichTCPClientTest::test_archive
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmprbteumow/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmprbteumow/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_fetch_empty_pack
test_client.py::DulwichTCPClientTest::test_fetch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpyazjt6pd/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpyazjt6pd/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_fetch_pack
test_client.py::DulwichTCPClientTest::test_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpatvq2lgm/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpatvq2lgm/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_fetch_pack_depth
test_client.py::DulwichTCPClientTest::test_fetch_pack_depth
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmphlmwd8l4/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmphlmwd8l4/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_fetch_pack_no_side_band_64k
test_client.py::DulwichTCPClientTest::test_fetch_pack_no_side_band_64k
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpuiw9l11b/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpuiw9l11b/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_fetch_pack_zero_sha
test_client.py::DulwichTCPClientTest::test_fetch_pack_zero_sha
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpv9nisvlo/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpv9nisvlo/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_get_refs
test_client.py::DulwichTCPClientTest::test_get_refs
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpecw8zyq_/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpecw8zyq_/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_incremental_fetch_pack
test_client.py::DulwichTCPClientTest::test_incremental_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp16phfla5/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp16phfla5/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_repeat
test_client.py::DulwichTCPClientTest::test_repeat
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpzwdulpao/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpzwdulpao/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_send_new_branch_empty_pack
test_client.py::DulwichTCPClientTest::test_send_new_branch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpbkcfc9dk/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpbkcfc9dk/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_send_pack
test_client.py::DulwichTCPClientTest::test_send_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp72etba95/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp72etba95/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_send_pack_from_shallow_clone
test_client.py::DulwichTCPClientTest::test_send_pack_from_shallow_clone
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp74pm3vny/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp74pm3vny/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_send_pack_multiple_errors
test_client.py::DulwichTCPClientTest::test_send_pack_multiple_errors
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpj1p47jx6/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpj1p47jx6/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_send_pack_nothing_to_send
test_client.py::DulwichTCPClientTest::test_send_pack_nothing_to_send
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpbndcsq0y/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpbndcsq0y/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_send_pack_one_error
test_client.py::DulwichTCPClientTest::test_send_pack_one_error
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpq7yvj69u/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpq7yvj69u/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_send_remove_branch
test_client.py::DulwichTCPClientTest::test_send_remove_branch
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp650beprh/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp650beprh/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTest::test_send_without_report_status
test_client.py::DulwichTCPClientTest::test_send_without_report_status
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpxid0djlw/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpxid0djlw/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_archive
test_client.py::DulwichTCPClientTestGitProtov0::test_archive
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp230ldxxa/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp230ldxxa/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_fetch_empty_pack
test_client.py::DulwichTCPClientTestGitProtov0::test_fetch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmptenyvts0/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmptenyvts0/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_fetch_pack
test_client.py::DulwichTCPClientTestGitProtov0::test_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpuucf000c/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpuucf000c/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_fetch_pack_depth
test_client.py::DulwichTCPClientTestGitProtov0::test_fetch_pack_depth
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpdo2by_im/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpdo2by_im/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_fetch_pack_no_side_band_64k
test_client.py::DulwichTCPClientTestGitProtov0::test_fetch_pack_no_side_band_64k
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpidq2x2rs/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpidq2x2rs/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_fetch_pack_zero_sha
test_client.py::DulwichTCPClientTestGitProtov0::test_fetch_pack_zero_sha
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpd_bmbsos/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpd_bmbsos/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_get_refs
test_client.py::DulwichTCPClientTestGitProtov0::test_get_refs
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpt2nzwkyr/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpt2nzwkyr/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_incremental_fetch_pack
test_client.py::DulwichTCPClientTestGitProtov0::test_incremental_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpy_a7xbgt/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpy_a7xbgt/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_repeat
test_client.py::DulwichTCPClientTestGitProtov0::test_repeat
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpv3oyi0q2/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpv3oyi0q2/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_send_new_branch_empty_pack
test_client.py::DulwichTCPClientTestGitProtov0::test_send_new_branch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpballdrbc/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpballdrbc/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_send_pack
test_client.py::DulwichTCPClientTestGitProtov0::test_send_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmplwmbbvhk/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmplwmbbvhk/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_send_pack_from_shallow_clone
test_client.py::DulwichTCPClientTestGitProtov0::test_send_pack_from_shallow_clone
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmppr64ivsl/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmppr64ivsl/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_send_pack_multiple_errors
test_client.py::DulwichTCPClientTestGitProtov0::test_send_pack_multiple_errors
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpngk8hyu_/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpngk8hyu_/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_send_pack_nothing_to_send
test_client.py::DulwichTCPClientTestGitProtov0::test_send_pack_nothing_to_send
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpvf8zhmwk/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpvf8zhmwk/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_send_pack_one_error
test_client.py::DulwichTCPClientTestGitProtov0::test_send_pack_one_error
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpuurucjuf/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpuurucjuf/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_send_remove_branch
test_client.py::DulwichTCPClientTestGitProtov0::test_send_remove_branch
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp77f80__k/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp77f80__k/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichTCPClientTestGitProtov0::test_send_without_report_status
test_client.py::DulwichTCPClientTestGitProtov0::test_send_without_report_status
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpd52mb8rn/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpd52mb8rn/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_archive
test_client.py::DulwichMockSSHClientTest::test_archive
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmplyspz7f_/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmplyspz7f_/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_fetch_empty_pack
test_client.py::DulwichMockSSHClientTest::test_fetch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpbhd5h4p9/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpbhd5h4p9/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_fetch_pack
test_client.py::DulwichMockSSHClientTest::test_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpyeys9222/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpyeys9222/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_fetch_pack_depth
test_client.py::DulwichMockSSHClientTest::test_fetch_pack_depth
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmppqg3nrjo/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmppqg3nrjo/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_fetch_pack_no_side_band_64k
test_client.py::DulwichMockSSHClientTest::test_fetch_pack_no_side_band_64k
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp3xhoyq6w/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp3xhoyq6w/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_fetch_pack_zero_sha
test_client.py::DulwichMockSSHClientTest::test_fetch_pack_zero_sha
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp0nlabddw/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp0nlabddw/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_get_refs
test_client.py::DulwichMockSSHClientTest::test_get_refs
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpiebs6aey/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpiebs6aey/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_incremental_fetch_pack
test_client.py::DulwichMockSSHClientTest::test_incremental_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp8r9vun9p/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp8r9vun9p/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_repeat
test_client.py::DulwichMockSSHClientTest::test_repeat
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpomf7ufsm/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpomf7ufsm/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_send_new_branch_empty_pack
test_client.py::DulwichMockSSHClientTest::test_send_new_branch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpudf6rxtv/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpudf6rxtv/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_send_pack
test_client.py::DulwichMockSSHClientTest::test_send_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpqt7thxqx/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpqt7thxqx/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_send_pack_from_shallow_clone
test_client.py::DulwichMockSSHClientTest::test_send_pack_from_shallow_clone
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpvjtzrjrk/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpvjtzrjrk/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_send_pack_multiple_errors
test_client.py::DulwichMockSSHClientTest::test_send_pack_multiple_errors
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpbjlshxbu/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpbjlshxbu/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_send_pack_nothing_to_send
test_client.py::DulwichMockSSHClientTest::test_send_pack_nothing_to_send
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpuedpi5g3/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpuedpi5g3/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_send_pack_one_error
test_client.py::DulwichMockSSHClientTest::test_send_pack_one_error
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp6eqvbmqr/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp6eqvbmqr/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_send_remove_branch
test_client.py::DulwichMockSSHClientTest::test_send_remove_branch
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpgtcala6_/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpgtcala6_/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTest::test_send_without_report_status
test_client.py::DulwichMockSSHClientTest::test_send_without_report_status
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp630ska8w/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp630ska8w/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_archive
test_client.py::DulwichMockSSHClientTestGitProtov0::test_archive
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpj0c5hdih/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpj0c5hdih/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_fetch_empty_pack
test_client.py::DulwichMockSSHClientTestGitProtov0::test_fetch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp4253hd2r/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp4253hd2r/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_fetch_pack
test_client.py::DulwichMockSSHClientTestGitProtov0::test_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpafqzrdte/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpafqzrdte/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_fetch_pack_depth
test_client.py::DulwichMockSSHClientTestGitProtov0::test_fetch_pack_depth
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpz_cwu053/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpz_cwu053/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_fetch_pack_no_side_band_64k
test_client.py::DulwichMockSSHClientTestGitProtov0::test_fetch_pack_no_side_band_64k
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp7h531fpo/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp7h531fpo/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_fetch_pack_zero_sha
test_client.py::DulwichMockSSHClientTestGitProtov0::test_fetch_pack_zero_sha
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpg2eemhe5/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpg2eemhe5/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_get_refs
test_client.py::DulwichMockSSHClientTestGitProtov0::test_get_refs
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpw1s_1rbe/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpw1s_1rbe/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_incremental_fetch_pack
test_client.py::DulwichMockSSHClientTestGitProtov0::test_incremental_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmph19r9yvo/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmph19r9yvo/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_repeat
test_client.py::DulwichMockSSHClientTestGitProtov0::test_repeat
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpkcd1h5v8/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpkcd1h5v8/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_new_branch_empty_pack
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_new_branch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpt6gnffy5/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpt6gnffy5/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_pack
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpawv3pdc5/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpawv3pdc5/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_pack_from_shallow_clone
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_pack_from_shallow_clone
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpvbqpe4rr/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpvbqpe4rr/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_pack_multiple_errors
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_pack_multiple_errors
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpwm3g9pw8/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpwm3g9pw8/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_pack_nothing_to_send
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_pack_nothing_to_send
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpge0rajlf/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpge0rajlf/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_pack_one_error
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_pack_one_error
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp9hez_ani/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp9hez_ani/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_remove_branch
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_remove_branch
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpywmrkl_b/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpywmrkl_b/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_without_report_status
test_client.py::DulwichMockSSHClientTestGitProtov0::test_send_without_report_status
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp63q0lo1o/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp63q0lo1o/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_archive
test_client.py::DulwichSubprocessClientTest::test_archive
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp_588tmul/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp_588tmul/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_fetch_empty_pack
test_client.py::DulwichSubprocessClientTest::test_fetch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmprc_qxjeu/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmprc_qxjeu/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_fetch_pack
test_client.py::DulwichSubprocessClientTest::test_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp5h33p4b8/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp5h33p4b8/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_fetch_pack_depth
test_client.py::DulwichSubprocessClientTest::test_fetch_pack_depth
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpo962hqfv/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpo962hqfv/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_fetch_pack_no_side_band_64k
test_client.py::DulwichSubprocessClientTest::test_fetch_pack_no_side_band_64k
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp9300_7k4/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp9300_7k4/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_fetch_pack_zero_sha
test_client.py::DulwichSubprocessClientTest::test_fetch_pack_zero_sha
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpovdu2527/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpovdu2527/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_get_refs
test_client.py::DulwichSubprocessClientTest::test_get_refs
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpzqbbl8ro/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpzqbbl8ro/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_incremental_fetch_pack
test_client.py::DulwichSubprocessClientTest::test_incremental_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmptzsbn40d/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmptzsbn40d/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_repeat
test_client.py::DulwichSubprocessClientTest::test_repeat
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmph85kzp8u/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmph85kzp8u/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_send_new_branch_empty_pack
test_client.py::DulwichSubprocessClientTest::test_send_new_branch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmppohj4ecf/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmppohj4ecf/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_send_pack
test_client.py::DulwichSubprocessClientTest::test_send_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpvxazspq1/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpvxazspq1/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_send_pack_from_shallow_clone
test_client.py::DulwichSubprocessClientTest::test_send_pack_from_shallow_clone
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpigsodsgl/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpigsodsgl/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_send_pack_multiple_errors
test_client.py::DulwichSubprocessClientTest::test_send_pack_multiple_errors
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpm6kdynbz/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpm6kdynbz/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_send_pack_nothing_to_send
test_client.py::DulwichSubprocessClientTest::test_send_pack_nothing_to_send
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpvw2u6hi5/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpvw2u6hi5/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_send_pack_one_error
test_client.py::DulwichSubprocessClientTest::test_send_pack_one_error
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpulxu77hs/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpulxu77hs/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_send_remove_branch
test_client.py::DulwichSubprocessClientTest::test_send_remove_branch
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpomhfvaov/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpomhfvaov/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTest::test_send_without_report_status
test_client.py::DulwichSubprocessClientTest::test_send_without_report_status
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpbnh0ns3y/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpbnh0ns3y/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_archive
test_client.py::DulwichSubprocessClientTestGitProtov0::test_archive
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpja04huoc/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpja04huoc/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_fetch_empty_pack
test_client.py::DulwichSubprocessClientTestGitProtov0::test_fetch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp9a5vcll4/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp9a5vcll4/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_fetch_pack
test_client.py::DulwichSubprocessClientTestGitProtov0::test_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpklkpfvle/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpklkpfvle/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_fetch_pack_depth
test_client.py::DulwichSubprocessClientTestGitProtov0::test_fetch_pack_depth
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpih2eatw3/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpih2eatw3/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_fetch_pack_no_side_band_64k
test_client.py::DulwichSubprocessClientTestGitProtov0::test_fetch_pack_no_side_band_64k
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp5imkbb5p/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp5imkbb5p/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_fetch_pack_zero_sha
test_client.py::DulwichSubprocessClientTestGitProtov0::test_fetch_pack_zero_sha
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpf9a_9taj/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpf9a_9taj/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_get_refs
test_client.py::DulwichSubprocessClientTestGitProtov0::test_get_refs
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpt322ohpm/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpt322ohpm/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_incremental_fetch_pack
test_client.py::DulwichSubprocessClientTestGitProtov0::test_incremental_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp7tzlaal1/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp7tzlaal1/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_repeat
test_client.py::DulwichSubprocessClientTestGitProtov0::test_repeat
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpyy25132c/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpyy25132c/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_new_branch_empty_pack
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_new_branch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpl7yjpbg4/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpl7yjpbg4/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_pack
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp48s86obd/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp48s86obd/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_pack_from_shallow_clone
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_pack_from_shallow_clone
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp6t4h1fkq/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp6t4h1fkq/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_pack_multiple_errors
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_pack_multiple_errors
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpl09p62sf/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpl09p62sf/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_pack_nothing_to_send
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_pack_nothing_to_send
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpko4v_n61/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpko4v_n61/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_pack_one_error
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_pack_one_error
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpqyqj5gxf/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpqyqj5gxf/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_remove_branch
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_remove_branch
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp5e_1cgil/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp5e_1cgil/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_without_report_status
test_client.py::DulwichSubprocessClientTestGitProtov0::test_send_without_report_status
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp799sv8jm/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp799sv8jm/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_archive
test_client.py::DulwichHttpClientTest::test_archive
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpkgs21p2e/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpkgs21p2e/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_fetch_empty_pack
test_client.py::DulwichHttpClientTest::test_fetch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp1s6a7v50/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp1s6a7v50/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_fetch_pack
test_client.py::DulwichHttpClientTest::test_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp0i40sl98/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp0i40sl98/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_fetch_pack_depth
test_client.py::DulwichHttpClientTest::test_fetch_pack_depth
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp4f9gc7ja/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp4f9gc7ja/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_fetch_pack_no_side_band_64k
test_client.py::DulwichHttpClientTest::test_fetch_pack_no_side_band_64k
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp1wqhsecs/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp1wqhsecs/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_fetch_pack_zero_sha
test_client.py::DulwichHttpClientTest::test_fetch_pack_zero_sha
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp__ogse9a/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp__ogse9a/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_get_refs
test_client.py::DulwichHttpClientTest::test_get_refs
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp1z9f77n2/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp1z9f77n2/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_incremental_fetch_pack
test_client.py::DulwichHttpClientTest::test_incremental_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpek3grdey/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpek3grdey/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_repeat
test_client.py::DulwichHttpClientTest::test_repeat
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpqq76glzw/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpqq76glzw/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_send_new_branch_empty_pack
test_client.py::DulwichHttpClientTest::test_send_new_branch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpixcczm6t/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpixcczm6t/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_send_pack
test_client.py::DulwichHttpClientTest::test_send_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpt4t8gz1r/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpt4t8gz1r/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_send_pack_from_shallow_clone
test_client.py::DulwichHttpClientTest::test_send_pack_from_shallow_clone
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpkjip1s0k/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpkjip1s0k/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_send_pack_multiple_errors
test_client.py::DulwichHttpClientTest::test_send_pack_multiple_errors
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpyt53jsgv/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpyt53jsgv/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_send_pack_nothing_to_send
test_client.py::DulwichHttpClientTest::test_send_pack_nothing_to_send
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpntrjao2h/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpntrjao2h/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_send_pack_one_error
test_client.py::DulwichHttpClientTest::test_send_pack_one_error
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp8_gp8owh/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp8_gp8owh/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_send_remove_branch
test_client.py::DulwichHttpClientTest::test_send_remove_branch
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp2fzx6451/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp2fzx6451/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTest::test_send_without_report_status
test_client.py::DulwichHttpClientTest::test_send_without_report_status
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmph14ol6iw/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmph14ol6iw/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_archive
test_client.py::DulwichHttpClientTestGitProtov0::test_archive
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpkrwm9m3b/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpkrwm9m3b/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_fetch_empty_pack
test_client.py::DulwichHttpClientTestGitProtov0::test_fetch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpauiqikn8/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpauiqikn8/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_fetch_pack
test_client.py::DulwichHttpClientTestGitProtov0::test_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpp36dv3u6/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpp36dv3u6/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_fetch_pack_depth
test_client.py::DulwichHttpClientTestGitProtov0::test_fetch_pack_depth
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmppxlx139h/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmppxlx139h/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_fetch_pack_no_side_band_64k
test_client.py::DulwichHttpClientTestGitProtov0::test_fetch_pack_no_side_band_64k
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpnihd07o7/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpnihd07o7/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_fetch_pack_zero_sha
test_client.py::DulwichHttpClientTestGitProtov0::test_fetch_pack_zero_sha
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp14l5oe3w/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp14l5oe3w/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_get_refs
test_client.py::DulwichHttpClientTestGitProtov0::test_get_refs
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp9tuborlq/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp9tuborlq/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_incremental_fetch_pack
test_client.py::DulwichHttpClientTestGitProtov0::test_incremental_fetch_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpxtksxoot/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpxtksxoot/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_repeat
test_client.py::DulwichHttpClientTestGitProtov0::test_repeat
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp293as3da/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp293as3da/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_send_new_branch_empty_pack
test_client.py::DulwichHttpClientTestGitProtov0::test_send_new_branch_empty_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp_xjw2sfp/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp_xjw2sfp/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_send_pack
test_client.py::DulwichHttpClientTestGitProtov0::test_send_pack
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpngsvci0e/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpngsvci0e/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_send_pack_from_shallow_clone
test_client.py::DulwichHttpClientTestGitProtov0::test_send_pack_from_shallow_clone
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpkxrt3ojv/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpkxrt3ojv/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_send_pack_multiple_errors
test_client.py::DulwichHttpClientTestGitProtov0::test_send_pack_multiple_errors
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpj0mrqzuk/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpj0mrqzuk/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_send_pack_nothing_to_send
test_client.py::DulwichHttpClientTestGitProtov0::test_send_pack_nothing_to_send
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp5nxv1gch/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp5nxv1gch/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_send_pack_one_error
test_client.py::DulwichHttpClientTestGitProtov0::test_send_pack_one_error
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpdvgp5u3i/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpdvgp5u3i/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_send_remove_branch
test_client.py::DulwichHttpClientTestGitProtov0::test_send_remove_branch
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmp5zv6fsn1/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp5zv6fsn1/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_client.py::DulwichHttpClientTestGitProtov0::test_send_without_report_status
test_client.py::DulwichHttpClientTestGitProtov0::test_send_without_report_status
self =
def setUp(self):
CompatTestCase.setUp(self)
> DulwichClientTestBase.setUp(self)
tests/compat/test_client.py:672:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_client.py:64: in setUp
run_git_or_fail(["init", "--quiet", "--bare"], cwd=self.dest)
tests/compat/utils.py:163: in run_git_or_fail
returncode, stdout, stderr = run_git(
tests/compat/utils.py:154: in run_git
p = subprocess.Popen(args, env=env, **popen_kwargs)
.venv/lib/python3.10/site-packages/gevent/subprocess.py:808: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
args = ['git', 'init', '--quiet', '--bare'], executable = 'git'
preexec_fn = None, close_fds = True, pass_fds = ()
cwd = '/tmp/tmpqlhrnzoi/dest'
env = {'LANG': 'C', 'LC_ALL': 'C', 'PATH': '/testbed/.venv/bin:/root/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
universal_newlines = None, startupinfo = None, creationflags = 0, shell = False
p2cread = 13, p2cwrite = 14, c2pread = 15, c2pwrite = 16, errread = 17
errwrite = 18, restore_signals = True, gid = None, gids = None, uid = None
umask = -1, start_new_session = False, process_group = None
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
gid, gids, uid, umask,
start_new_session, process_group):
"""Execute program (POSIX version)"""
if isinstance(args, (str, bytes)):
args = [args]
elif isinstance(args, PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = [fsencode(args)] # os.PathLike -> [str]
else:
args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
unix_shell = (
'/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh'
)
args = [unix_shell, "-c"] + args
if executable:
args[0] = executable
if executable is None:
executable = args[0]
self._loop.install_sigchld()
# For transferring possible exec failure from child to parent
# The first char specifies the exception type: 0 means
# OSError, 1 means some other error.
errpipe_read, errpipe_write = self.pipe_cloexec()
# errpipe_write must not be in the standard io 0, 1, or 2 fd range.
low_fds_to_close = []
while errpipe_write < 3:
low_fds_to_close.append(errpipe_write)
errpipe_write = os.dup(errpipe_write)
for low_fd in low_fds_to_close:
os.close(low_fd)
try:
try:
gc_was_enabled = gc.isenabled()
# Disable gc to avoid bug where gc -> file_dealloc ->
# write to stderr -> hang. http://bugs.python.org/issue1336
gc.disable()
try:
self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
except:
if gc_was_enabled:
gc.enable()
raise
if self.pid == 0:
# Child
# In various places on the child side of things, we catch OSError
# and add attributes to it that detail where in the process we failed;
# like all exceptions until we have exec'd, this exception is pickled
# and sent to the parent to raise in the calling process.
# The parent uses this to decide how to treat that exception,
# adjusting certain information about it as needed.
#
# Python 3.11.8 --- yes, a minor patch release --- stopped
# letting the 'filename' parameter get set in the resulting
# exception for many cases. We're not quite interpreting this
# the same way the stdlib is, I'm sure, but this makes the stdlib
# tests pass.
# XXX: Technically we're doing a lot of stuff here that
# may not be safe to do before a exec(), depending on the OS.
# CPython 3 goes to great lengths to precompute a lot
# of this info before the fork and pass it all to C functions that
# try hard not to call things like malloc(). (Of course,
# CPython 2 pretty much did what we're doing.)
try:
# Close parent's pipe ends
if p2cwrite != -1:
os.close(p2cwrite)
if c2pread != -1:
os.close(c2pread)
if errread != -1:
os.close(errread)
os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child
def _dup2(existing, desired):
# dup2() removes the CLOEXEC flag but
# we must do it ourselves if dup2()
# would be a no-op (issue #10806).
if existing == desired:
self._set_cloexec_flag(existing, False)
elif existing != -1:
os.dup2(existing, desired)
try:
self._remove_nonblock_flag(desired)
except OSError:
# Ignore EBADF, it may not actually be
# open yet.
# Tested beginning in 3.7.0b3 test_subprocess.py
pass
_dup2(p2cread, 0)
_dup2(c2pwrite, 1)
_dup2(errwrite, 2)
# Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None:
try:
os.chdir(cwd)
except OSError as e:
e._failed_chdir = True
raise
# Python 3.9
if umask >= 0:
os.umask(umask)
# XXX: CPython does _Py_RestoreSignals here.
# Then setsid() based on ???
try:
if gids:
os.setgroups(gids)
if gid:
os.setregid(gid, gid)
if uid:
os.setreuid(uid, uid)
if process_group is not None:
os.setpgid(0, process_group)
except OSError as e:
e._failed_chuser = True
raise
if preexec_fn:
preexec_fn()
# Close all other fds, if asked for. This must be done
# after preexec_fn runs.
if close_fds:
fds_to_keep = set(pass_fds)
fds_to_keep.add(errpipe_write)
self._close_fds(fds_to_keep, errpipe_write)
if restore_signals:
# restore the documented signals back to sig_dfl;
# not all will be defined on every platform
for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
sig = getattr(signal, sig, None)
if sig is not None:
signal.signal(sig, signal.SIG_DFL)
if start_new_session:
os.setsid()
try:
if env is None:
os.execvp(executable, args)
else:
# Python 3.6 started testing for
# bytes values in the env; it also
# started encoding strs using
# fsencode and using a lower-level
# API that takes a list of keys
# and values. We don't have access
# to that API, so we go the reverse direction.
env = {os.fsdecode(k) if isinstance(k, bytes) else k:
os.fsdecode(v) if isinstance(v, bytes) else v
for k, v in env.items()}
os.execvpe(executable, args, env)
except OSError as e:
e._failed_exec = True
raise
except:
exc_type, exc_value, tb = sys.exc_info()
# Save the traceback and attach it to the exception object
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
exc_value.child_traceback = ''.join(exc_lines)
os.write(errpipe_write, pickle.dumps(exc_value))
finally:
# Make sure that the process exits no matter what.
# The return code does not matter much as it won't be
# reported to the application
os._exit(1)
# Parent
self._child_created = True
if gc_was_enabled:
gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
# self._devnull is not always defined.
devnull_fd = getattr(self, '_devnull', None)
if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
os.close(p2cread)
if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
os.close(c2pwrite)
if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
os.close(errwrite)
if devnull_fd is not None:
os.close(devnull_fd)
# Prevent a double close of these fds from __init__ on error.
self._closed_child_pipe_fds = True
# Wait for exec to fail or succeed; possibly raising exception
errpipe_read = FileObject(errpipe_read, 'rb')
data = errpipe_read.read()
finally:
try:
if hasattr(errpipe_read, 'close'):
errpipe_read.close()
else:
os.close(errpipe_read)
except OSError:
# Especially on PyPy, we sometimes see the above
# `os.close(errpipe_read)` raise an OSError.
# It's not entirely clear why, but it happens in
# InterprocessSignalTests.test_main sometimes, which must mean
# we have some sort of race condition.
pass
finally:
errpipe_read = -1
if data != b"":
self.wait()
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None and fd != -1:
os.close(fd)
if isinstance(child_exception, OSError):
child_exception.filename = executable
if hasattr(child_exception, '_failed_chdir'):
child_exception.filename = cwd
if getattr(child_exception, '_failed_chuser', False):
child_exception.filename = None
> raise child_exception
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpqlhrnzoi/dest'
.venv/lib/python3.10/site-packages/gevent/subprocess.py:1838: FileNotFoundError
test_pack.py::TestPack::test_copy
test_pack.py::TestPack::test_copy
self =
def test_copy(self):
with self.get_pack(pack1_sha) as origpack:
> self.assertSucceeds(origpack.index.check)
E AttributeError: 'NoneType' object has no attribute 'check'
tests/compat/test_pack.py:62: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_copy(self):
> with self.get_pack(pack1_sha) as origpack:
tests/compat/test_pack.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'NoneType' object has no attribute 'check'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_delta_medium_object
test_pack.py::TestPack::test_delta_medium_object
self =
def test_delta_medium_object(self):
# This tests an object set that will have a copy operation
# 2**20 in size.
with self.get_pack(pack1_sha) as orig_pack:
> orig_blob = orig_pack[a_sha]
tests/compat/test_pack.py:98:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
sha1 = b'6f670c0fb53f9463760b7295fbb814e965fb20c8'
def __getitem__(self, sha1: bytes) -> ShaFile:
"""Retrieve the specified SHA1."""
> type, uncomp = self.get_raw(sha1)
E AttributeError: 'Pack' object has no attribute 'get_raw'. Did you mean: 'get_ref'?
dulwich/pack.py:1188: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_delta_medium_object(self):
# This tests an object set that will have a copy operation
# 2**20 in size.
> with self.get_pack(pack1_sha) as orig_pack:
tests/compat/test_pack.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'Pack' object has no attribute 'get_raw'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_deltas_work
test_pack.py::TestPack::test_deltas_work
self =
def test_deltas_work(self):
with self.get_pack(pack1_sha) as orig_pack:
> orig_blob = orig_pack[a_sha]
tests/compat/test_pack.py:71:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
sha1 = b'6f670c0fb53f9463760b7295fbb814e965fb20c8'
def __getitem__(self, sha1: bytes) -> ShaFile:
"""Retrieve the specified SHA1."""
> type, uncomp = self.get_raw(sha1)
E AttributeError: 'Pack' object has no attribute 'get_raw'. Did you mean: 'get_ref'?
dulwich/pack.py:1188: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_deltas_work(self):
> with self.get_pack(pack1_sha) as orig_pack:
tests/compat/test_pack.py:70:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'Pack' object has no attribute 'get_raw'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_repository.py::ObjectStoreTestCase::test_all_objects
test_repository.py::ObjectStoreTestCase::test_all_objects
self =
def setUp(self):
super().setUp()
> self._repo = self.import_repo("server_new.export")
tests/compat/test_repository.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpatuv43p1/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::ObjectStoreTestCase::test_bare
test_repository.py::ObjectStoreTestCase::test_bare
self =
def setUp(self):
super().setUp()
> self._repo = self.import_repo("server_new.export")
tests/compat/test_repository.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpiq_w2aa6/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::ObjectStoreTestCase::test_head
test_repository.py::ObjectStoreTestCase::test_head
self =
def setUp(self):
super().setUp()
> self._repo = self.import_repo("server_new.export")
tests/compat/test_repository.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpfvvba5k2/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::ObjectStoreTestCase::test_loose_objects
test_repository.py::ObjectStoreTestCase::test_loose_objects
self =
def setUp(self):
super().setUp()
> self._repo = self.import_repo("server_new.export")
tests/compat/test_repository.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpatolzfg8/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::ObjectStoreTestCase::test_packed_objects
test_repository.py::ObjectStoreTestCase::test_packed_objects
self =
def setUp(self):
super().setUp()
> self._repo = self.import_repo("server_new.export")
tests/compat/test_repository.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmphhsupavg/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::ObjectStoreTestCase::test_refs
test_repository.py::ObjectStoreTestCase::test_refs
self =
def setUp(self):
super().setUp()
> self._repo = self.import_repo("server_new.export")
tests/compat/test_repository.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpulw63vru/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::WorkingTreeTestCase::test_all_objects
test_repository.py::WorkingTreeTestCase::test_all_objects
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpr4ltxoes/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::WorkingTreeTestCase::test_bare
test_repository.py::WorkingTreeTestCase::test_bare
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpt0hg8erg/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::WorkingTreeTestCase::test_git_worktree_config
test_repository.py::WorkingTreeTestCase::test_git_worktree_config
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmprj7q1d67/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::WorkingTreeTestCase::test_git_worktree_list
test_repository.py::WorkingTreeTestCase::test_git_worktree_list
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpwigie8kq/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::WorkingTreeTestCase::test_head
test_repository.py::WorkingTreeTestCase::test_head
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpvy3jbueo/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::WorkingTreeTestCase::test_head_equality
test_repository.py::WorkingTreeTestCase::test_head_equality
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpul1gc70w/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::WorkingTreeTestCase::test_loose_objects
test_repository.py::WorkingTreeTestCase::test_loose_objects
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmp_npaidsc/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::WorkingTreeTestCase::test_packed_objects
test_repository.py::WorkingTreeTestCase::test_packed_objects
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmp08pe_5f_/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::WorkingTreeTestCase::test_refs
test_repository.py::WorkingTreeTestCase::test_refs
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpkg40_kbg/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::InitNewWorkingDirectoryTestCase::test_all_objects
test_repository.py::InitNewWorkingDirectoryTestCase::test_all_objects
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:140: in setUp
super().setUp()
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpzy1bk5qn/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::InitNewWorkingDirectoryTestCase::test_bare
test_repository.py::InitNewWorkingDirectoryTestCase::test_bare
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:140: in setUp
super().setUp()
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpyavn32ob/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::InitNewWorkingDirectoryTestCase::test_git_worktree_config
test_repository.py::InitNewWorkingDirectoryTestCase::test_git_worktree_config
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:140: in setUp
super().setUp()
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpqdj6ukfd/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::InitNewWorkingDirectoryTestCase::test_git_worktree_list
test_repository.py::InitNewWorkingDirectoryTestCase::test_git_worktree_list
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:140: in setUp
super().setUp()
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpi3q20qsv/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::InitNewWorkingDirectoryTestCase::test_head
test_repository.py::InitNewWorkingDirectoryTestCase::test_head
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:140: in setUp
super().setUp()
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpq5k18_i5/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::InitNewWorkingDirectoryTestCase::test_head_equality
test_repository.py::InitNewWorkingDirectoryTestCase::test_head_equality
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:140: in setUp
super().setUp()
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpxvrb8flo/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::InitNewWorkingDirectoryTestCase::test_loose_objects
test_repository.py::InitNewWorkingDirectoryTestCase::test_loose_objects
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:140: in setUp
super().setUp()
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpy5rhh7a7/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::InitNewWorkingDirectoryTestCase::test_packed_objects
test_repository.py::InitNewWorkingDirectoryTestCase::test_packed_objects
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:140: in setUp
super().setUp()
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpjzge7px2/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_repository.py::InitNewWorkingDirectoryTestCase::test_refs
test_repository.py::InitNewWorkingDirectoryTestCase::test_refs
self =
def setUp(self):
> super().setUp()
tests/compat/test_repository.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_repository.py:140: in setUp
super().setUp()
tests/compat/test_repository.py:39: in setUp
self._repo = self.import_repo("server_new.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmp8y_mipr6/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_clone_from_dulwich_empty
test_server.py::GitServerTestCase::test_clone_from_dulwich_empty
self =
def test_clone_from_dulwich_empty(self):
old_repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, old_repo_dir)
self._old_repo = Repo.init_bare(old_repo_dir)
> port = self._start_server(self._old_repo)
tests/compat/server_utils.py:153:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_server.py:58: in _start_server
dul_server = TCPGitServer(backend, b"localhost", 0, handlers=self._handlers())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = b'localhost', port = 0
handlers = {b'git-receive-pack': }
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_server.py::GitServerTestCase::test_fetch_from_dulwich
test_server.py::GitServerTestCase::test_fetch_from_dulwich
self =
def test_fetch_from_dulwich(self):
> self.import_repos()
tests/compat/server_utils.py:123:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/server_utils.py:78: in import_repos
self._old_repo = self.import_repo("server_old.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpaw5iwmba/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_fetch_from_dulwich_issue_88_alternative
test_server.py::GitServerTestCase::test_fetch_from_dulwich_issue_88_alternative
self =
def test_fetch_from_dulwich_issue_88_alternative(self):
# likewise, but the case where the two repos have no common parent
> self._source_repo = self.import_repo("issue88_expect_ack_nak_other.export")
tests/compat/server_utils.py:311:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpbvrc1kjx/issue88_expect_ack_nak_other.export'
object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_fetch_from_dulwich_issue_88_standard
test_server.py::GitServerTestCase::test_fetch_from_dulwich_issue_88_standard
self =
def test_fetch_from_dulwich_issue_88_standard(self):
# Basically an integration test to see that the ACK/NAK
# generation works on repos with common head.
> self._source_repo = self.import_repo("issue88_expect_ack_nak_server.export")
tests/compat/server_utils.py:300:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpa0dtblvc/issue88_expect_ack_nak_server.export'
object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_fetch_from_dulwich_no_op
test_server.py::GitServerTestCase::test_fetch_from_dulwich_no_op
self =
def test_fetch_from_dulwich_no_op(self):
> self._old_repo = self.import_repo("server_old.export")
tests/compat/server_utils.py:136:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpu2qpqaip/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_fetch_full_depth_into_shallow_clone_from_dulwich
test_server.py::GitServerTestCase::test_fetch_full_depth_into_shallow_clone_from_dulwich
self =
def test_fetch_full_depth_into_shallow_clone_from_dulwich(self):
require_git_version(self.min_single_branch_version)
> self._source_repo = self.import_repo("server_new.export")
tests/compat/server_utils.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmptbti5reo/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_fetch_same_depth_into_shallow_clone_from_dulwich
test_server.py::GitServerTestCase::test_fetch_same_depth_into_shallow_clone_from_dulwich
self =
def test_fetch_same_depth_into_shallow_clone_from_dulwich(self):
require_git_version(self.min_single_branch_version)
> self._source_repo = self.import_repo("server_new.export")
tests/compat/server_utils.py:233:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpsxsfvzhu/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_lsremote_from_dulwich
test_server.py::GitServerTestCase::test_lsremote_from_dulwich
self =
def test_lsremote_from_dulwich(self):
> self._repo = self.import_repo("server_old.export")
tests/compat/server_utils.py:163:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpmtm2pugf/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_new_shallow_clone_from_dulwich
test_server.py::GitServerTestCase::test_new_shallow_clone_from_dulwich
self =
def test_new_shallow_clone_from_dulwich(self):
require_git_version(self.min_single_branch_version)
> self._source_repo = self.import_repo("server_new.export")
tests/compat/server_utils.py:170:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmp62jgsfar/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_push_to_dulwich
test_server.py::GitServerTestCase::test_push_to_dulwich
self =
def test_push_to_dulwich(self):
> self.import_repos()
tests/compat/server_utils.py:90:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/server_utils.py:78: in import_repos
self._old_repo = self.import_repo("server_old.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpplozwia1/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_push_to_dulwich_issue_88_standard
test_server.py::GitServerTestCase::test_push_to_dulwich_issue_88_standard
self =
def test_push_to_dulwich_issue_88_standard(self):
# Same thing, but we reverse the role of the server/client
# and do a push instead.
> self._source_repo = self.import_repo("issue88_expect_ack_nak_client.export")
tests/compat/server_utils.py:331:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmp_e57l5wm/issue88_expect_ack_nak_client.export'
object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_push_to_dulwich_no_op
test_server.py::GitServerTestCase::test_push_to_dulwich_no_op
self =
def test_push_to_dulwich_no_op(self):
> self._old_repo = self.import_repo("server_old.export")
tests/compat/server_utils.py:101:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpw0f17hee/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_push_to_dulwich_remove_branch
test_server.py::GitServerTestCase::test_push_to_dulwich_remove_branch
self =
def test_push_to_dulwich_remove_branch(self):
> self._old_repo = self.import_repo("server_old.export")
tests/compat/server_utils.py:113:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpvz0wogzn/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerTestCase::test_shallow_clone_from_git_is_identical
test_server.py::GitServerTestCase::test_shallow_clone_from_git_is_identical
self =
def test_shallow_clone_from_git_is_identical(self):
require_git_version(self.min_single_branch_version)
> self._source_repo = self.import_repo("server_new.export")
tests/compat/server_utils.py:196:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpeezbi80_/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_clone_from_dulwich_empty
test_server.py::GitServerSideBand64kTestCase::test_clone_from_dulwich_empty
self =
def test_clone_from_dulwich_empty(self):
old_repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, old_repo_dir)
self._old_repo = Repo.init_bare(old_repo_dir)
> port = self._start_server(self._old_repo)
tests/compat/server_utils.py:153:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/test_server.py:58: in _start_server
dul_server = TCPGitServer(backend, b"localhost", 0, handlers=self._handlers())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = b'localhost', port = 0, handlers = None
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_fetch_from_dulwich
test_server.py::GitServerSideBand64kTestCase::test_fetch_from_dulwich
self =
def test_fetch_from_dulwich(self):
> self.import_repos()
tests/compat/server_utils.py:123:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/server_utils.py:78: in import_repos
self._old_repo = self.import_repo("server_old.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmp_yv5hig5/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_fetch_from_dulwich_issue_88_alternative
test_server.py::GitServerSideBand64kTestCase::test_fetch_from_dulwich_issue_88_alternative
self =
def test_fetch_from_dulwich_issue_88_alternative(self):
# likewise, but the case where the two repos have no common parent
> self._source_repo = self.import_repo("issue88_expect_ack_nak_other.export")
tests/compat/server_utils.py:311:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpd1gr3bor/issue88_expect_ack_nak_other.export'
object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_fetch_from_dulwich_issue_88_standard
test_server.py::GitServerSideBand64kTestCase::test_fetch_from_dulwich_issue_88_standard
self =
def test_fetch_from_dulwich_issue_88_standard(self):
# Basically an integration test to see that the ACK/NAK
# generation works on repos with common head.
> self._source_repo = self.import_repo("issue88_expect_ack_nak_server.export")
tests/compat/server_utils.py:300:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpt7ylsal3/issue88_expect_ack_nak_server.export'
object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_fetch_from_dulwich_no_op
test_server.py::GitServerSideBand64kTestCase::test_fetch_from_dulwich_no_op
self =
def test_fetch_from_dulwich_no_op(self):
> self._old_repo = self.import_repo("server_old.export")
tests/compat/server_utils.py:136:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpa94tnxgv/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_fetch_full_depth_into_shallow_clone_from_dulwich
test_server.py::GitServerSideBand64kTestCase::test_fetch_full_depth_into_shallow_clone_from_dulwich
self =
def test_fetch_full_depth_into_shallow_clone_from_dulwich(self):
require_git_version(self.min_single_branch_version)
> self._source_repo = self.import_repo("server_new.export")
tests/compat/server_utils.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpzc00s95s/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_fetch_same_depth_into_shallow_clone_from_dulwich
test_server.py::GitServerSideBand64kTestCase::test_fetch_same_depth_into_shallow_clone_from_dulwich
self =
def test_fetch_same_depth_into_shallow_clone_from_dulwich(self):
require_git_version(self.min_single_branch_version)
> self._source_repo = self.import_repo("server_new.export")
tests/compat/server_utils.py:233:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmp0juc9m1k/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_lsremote_from_dulwich
test_server.py::GitServerSideBand64kTestCase::test_lsremote_from_dulwich
self =
def test_lsremote_from_dulwich(self):
> self._repo = self.import_repo("server_old.export")
tests/compat/server_utils.py:163:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmp9lzb94d7/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_new_shallow_clone_from_dulwich
test_server.py::GitServerSideBand64kTestCase::test_new_shallow_clone_from_dulwich
self =
def test_new_shallow_clone_from_dulwich(self):
require_git_version(self.min_single_branch_version)
> self._source_repo = self.import_repo("server_new.export")
tests/compat/server_utils.py:170:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpbnj0uprd/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_push_to_dulwich
test_server.py::GitServerSideBand64kTestCase::test_push_to_dulwich
self =
def test_push_to_dulwich(self):
> self.import_repos()
tests/compat/server_utils.py:90:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/server_utils.py:78: in import_repos
self._old_repo = self.import_repo("server_old.export")
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmptddisd2l/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_push_to_dulwich_issue_88_standard
test_server.py::GitServerSideBand64kTestCase::test_push_to_dulwich_issue_88_standard
self =
def test_push_to_dulwich_issue_88_standard(self):
# Same thing, but we reverse the role of the server/client
# and do a push instead.
> self._source_repo = self.import_repo("issue88_expect_ack_nak_client.export")
tests/compat/server_utils.py:331:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpch4y0jjp/issue88_expect_ack_nak_client.export'
object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_push_to_dulwich_no_op
test_server.py::GitServerSideBand64kTestCase::test_push_to_dulwich_no_op
self =
def test_push_to_dulwich_no_op(self):
> self._old_repo = self.import_repo("server_old.export")
tests/compat/server_utils.py:101:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpdl40tx4t/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_push_to_dulwich_remove_branch
test_server.py::GitServerSideBand64kTestCase::test_push_to_dulwich_remove_branch
self =
def test_push_to_dulwich_remove_branch(self):
> self._old_repo = self.import_repo("server_old.export")
tests/compat/server_utils.py:113:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmp65hjoode/server_old.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_server.py::GitServerSideBand64kTestCase::test_shallow_clone_from_git_is_identical
test_server.py::GitServerSideBand64kTestCase::test_shallow_clone_from_git_is_identical
self =
def test_shallow_clone_from_git_is_identical(self):
require_git_version(self.min_single_branch_version)
> self._source_repo = self.import_repo("server_new.export")
tests/compat/server_utils.py:196:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/compat/utils.py:269: in import_repo
repo = Repo(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = '/tmp/tmpuyx7_zyt/server_new.export', object_store = None, bare = True
def __init__(self, root: str, object_store: Optional[PackBasedObjectStore]=None, bare: Optional[bool]=None) -> None:
hidden_path = os.path.join(root, CONTROLDIR)
if bare is None:
if os.path.isfile(hidden_path) or os.path.isdir(os.path.join(hidden_path, OBJECTDIR)):
bare = False
elif os.path.isdir(os.path.join(root, OBJECTDIR)) and os.path.isdir(os.path.join(root, REFSDIR)):
bare = True
else:
raise NotGitRepository('No git repository was found at {path}'.format(**dict(path=root)))
self.bare = bare
if bare is False:
if os.path.isfile(hidden_path):
with open(hidden_path) as f:
path = read_gitfile(f)
self._controldir = os.path.join(root, path)
else:
self._controldir = hidden_path
else:
self._controldir = root
commondir = self.get_named_file(COMMONDIR)
if commondir is not None:
with commondir:
self._commondir = os.path.join(self.controldir(), os.fsdecode(commondir.read().rstrip(b'\r\n')))
else:
self._commondir = self._controldir
self.path = root
config = self.get_config()
try:
> repository_format_version = config.get('core', 'repositoryformatversion')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/repo.py:589: AttributeError
test_release_robot.py::GetRecentTagsTest::test_get_recent_tags
cls =
@classmethod
def setUpClass(cls):
cls.projdir = tempfile.mkdtemp() # temporary project directory
cls.repo = Repo.init(cls.projdir) # test repo
> obj_store = cls.repo.object_store # test repo object store
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/contrib/test_release_robot.py:83: AttributeError
test_swift.py::TestSwiftRepo::test_init_bare
test_swift.py::TestSwiftRepo::test_init_bare
self =
def test_init_bare(self):
fsc = FakeSwiftConnector("fakeroot", conf=self.conf)
with patch(
"dulwich.contrib.swift.SwiftConnector",
new_callable=create_swift_connector,
store=fsc.store,
):
swift.SwiftRepo.init_bare(fsc, conf=self.conf)
> self.assertIn("fakeroot/objects/pack", fsc.store)
E AssertionError: 'fakeroot/objects/pack' not found in {}
tests/contrib/test_swift.py:285: AssertionError
test_swift.py::TestSwiftRepo::test_put_named_file
test_swift.py::TestSwiftRepo::test_put_named_file
self =
def test_put_named_file(self):
store = {"fakerepo/objects/pack": ""}
with patch(
"dulwich.contrib.swift.SwiftConnector",
new_callable=create_swift_connector,
store=store,
):
repo = swift.SwiftRepo("fakerepo", conf=self.conf)
desc = b"Fake repo"
repo._put_named_file("description", desc)
> self.assertEqual(repo.scon.store["fakerepo/description"], desc)
E KeyError: 'fakerepo/description'
tests/contrib/test_swift.py:275: KeyError
test_swift.py::TestSwiftInfoRefsContainer::test_init
test_swift.py::TestSwiftInfoRefsContainer::test_init
self =
def test_init(self):
"""info/refs does not exists."""
irc = swift.SwiftInfoRefsContainer(self.fsc, self.object_store)
self.assertEqual(len(irc._refs), 0)
self.fsc.store = self.store
> irc = swift.SwiftInfoRefsContainer(self.fsc, self.object_store)
tests/contrib/test_swift.py:308:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/contrib/swift.py:304: in __init__
super().__init__(f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
f = <_io.BytesIO object at 0x7eec1f169e40>
def __init__(self, f) -> None:
self._refs = {}
self._peeled = {}
for line in f.readlines():
sha, name = line.rstrip(b'\n').split(b'\t')
if name.endswith(PEELED_TAG_SUFFIX):
name = name[:-3]
if not check_ref_format(name):
raise ValueError(f'invalid ref name {name!r}')
self._peeled[name] = sha
else:
if not check_ref_format(name):
> raise ValueError(f'invalid ref name {name!r}')
E ValueError: invalid ref name b'refs/heads/master'
dulwich/refs.py:302: ValueError
test_swift.py::TestSwiftInfoRefsContainer::test_remove_if_equals
test_swift.py::TestSwiftInfoRefsContainer::test_remove_if_equals
self =
def test_remove_if_equals(self):
self.fsc.store = self.store
> irc = swift.SwiftInfoRefsContainer(self.fsc, self.object_store)
tests/contrib/test_swift.py:324:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/contrib/swift.py:304: in __init__
super().__init__(f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
f = <_io.BytesIO object at 0x7eec20822110>
def __init__(self, f) -> None:
self._refs = {}
self._peeled = {}
for line in f.readlines():
sha, name = line.rstrip(b'\n').split(b'\t')
if name.endswith(PEELED_TAG_SUFFIX):
name = name[:-3]
if not check_ref_format(name):
raise ValueError(f'invalid ref name {name!r}')
self._peeled[name] = sha
else:
if not check_ref_format(name):
> raise ValueError(f'invalid ref name {name!r}')
E ValueError: invalid ref name b'refs/heads/master'
dulwich/refs.py:302: ValueError
test_swift.py::TestSwiftInfoRefsContainer::test_set_if_equals
test_swift.py::TestSwiftInfoRefsContainer::test_set_if_equals
self =
def test_set_if_equals(self):
self.fsc.store = self.store
> irc = swift.SwiftInfoRefsContainer(self.fsc, self.object_store)
tests/contrib/test_swift.py:314:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/contrib/swift.py:304: in __init__
super().__init__(f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
f = <_io.BytesIO object at 0x7eec1f157650>
def __init__(self, f) -> None:
self._refs = {}
self._peeled = {}
for line in f.readlines():
sha, name = line.rstrip(b'\n').split(b'\t')
if name.endswith(PEELED_TAG_SUFFIX):
name = name[:-3]
if not check_ref_format(name):
raise ValueError(f'invalid ref name {name!r}')
self._peeled[name] = sha
else:
if not check_ref_format(name):
> raise ValueError(f'invalid ref name {name!r}')
E ValueError: invalid ref name b'refs/heads/master'
dulwich/refs.py:302: ValueError
test_swift.py::TestSwiftConnector::test_create_root
test_swift.py::TestSwiftConnector::test_create_root
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_create_root_fails
test_swift.py::TestSwiftConnector::test_create_root_fails
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_del_object
test_swift.py::TestSwiftConnector::test_del_object
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_del_root
test_swift.py::TestSwiftConnector::test_del_root
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_get_container_objects
test_swift.py::TestSwiftConnector::test_get_container_objects
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_get_container_objects_fails
test_swift.py::TestSwiftConnector::test_get_container_objects_fails
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_get_object
test_swift.py::TestSwiftConnector::test_get_object
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_get_object_fails
test_swift.py::TestSwiftConnector::test_get_object_fails
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_get_object_stat
test_swift.py::TestSwiftConnector::test_get_object_stat
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_get_object_stat_fails
test_swift.py::TestSwiftConnector::test_get_object_stat_fails
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_init_connector
test_swift.py::TestSwiftConnector::test_init_connector
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_put_object
test_swift.py::TestSwiftConnector::test_put_object
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_put_object_fails
test_swift.py::TestSwiftConnector::test_put_object_fails
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_root_exists
test_swift.py::TestSwiftConnector::test_root_exists
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift.py::TestSwiftConnector::test_root_not_exists
test_swift.py::TestSwiftConnector::test_root_not_exists
self =
def setUp(self):
super().setUp()
self.conf = swift.load_conf(file=StringIO(config_file % def_config_file))
with patch("geventhttpclient.HTTPClient.request", fake_auth_request_v1):
> self.conn = swift.SwiftConnector("fakerepo", conf=self.conf)
tests/contrib/test_swift.py:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
root = 'fakerepo', conf = None
def __init__(self, root, conf) -> None:
"""Initialize a SwiftConnector.
Args:
root: The swift container that will act as Git bare repository
conf: A ConfigParser Object
"""
self.conf = conf
> self.auth_ver = self.conf.get('swift', 'auth_ver')
E AttributeError: 'NoneType' object has no attribute 'get'
dulwich/contrib/swift.py:60: AttributeError
test_swift_smoke.py::SwiftRepoSmokeTest::test_clone_bare
test_swift_smoke.py::SwiftRepoSmokeTest::test_clone_bare
cls =
@classmethod
def setUpClass(cls):
cls.backend = SwiftSystemBackend()
cls.port = 9148
cls.server_address = "localhost"
cls.fakerepo = "fakerepo"
cls.th_server = DulwichServer(cls.backend, cls.port)
> cls.th_server.run()
tests/contrib/test_swift_smoke.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/contrib/test_swift_smoke.py:58: in run
self.server = server.TCPGitServer(self.backend, "localhost", port=self.port)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = 'localhost', port = 9148, handlers = None
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_swift_smoke.py::SwiftRepoSmokeTest::test_clone_then_push_data
test_swift_smoke.py::SwiftRepoSmokeTest::test_clone_then_push_data
cls =
@classmethod
def setUpClass(cls):
cls.backend = SwiftSystemBackend()
cls.port = 9148
cls.server_address = "localhost"
cls.fakerepo = "fakerepo"
cls.th_server = DulwichServer(cls.backend, cls.port)
> cls.th_server.run()
tests/contrib/test_swift_smoke.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/contrib/test_swift_smoke.py:58: in run
self.server = server.TCPGitServer(self.backend, "localhost", port=self.port)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = 'localhost', port = 9148, handlers = None
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_swift_smoke.py::SwiftRepoSmokeTest::test_init_bare
test_swift_smoke.py::SwiftRepoSmokeTest::test_init_bare
cls =
@classmethod
def setUpClass(cls):
cls.backend = SwiftSystemBackend()
cls.port = 9148
cls.server_address = "localhost"
cls.fakerepo = "fakerepo"
cls.th_server = DulwichServer(cls.backend, cls.port)
> cls.th_server.run()
tests/contrib/test_swift_smoke.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/contrib/test_swift_smoke.py:58: in run
self.server = server.TCPGitServer(self.backend, "localhost", port=self.port)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = 'localhost', port = 9148, handlers = None
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_annotated_tag
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_annotated_tag
cls =
@classmethod
def setUpClass(cls):
cls.backend = SwiftSystemBackend()
cls.port = 9148
cls.server_address = "localhost"
cls.fakerepo = "fakerepo"
cls.th_server = DulwichServer(cls.backend, cls.port)
> cls.th_server.run()
tests/contrib/test_swift_smoke.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/contrib/test_swift_smoke.py:58: in run
self.server = server.TCPGitServer(self.backend, "localhost", port=self.port)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = 'localhost', port = 9148, handlers = None
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_branch
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_branch
cls =
@classmethod
def setUpClass(cls):
cls.backend = SwiftSystemBackend()
cls.port = 9148
cls.server_address = "localhost"
cls.fakerepo = "fakerepo"
cls.th_server = DulwichServer(cls.backend, cls.port)
> cls.th_server.run()
tests/contrib/test_swift_smoke.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/contrib/test_swift_smoke.py:58: in run
self.server = server.TCPGitServer(self.backend, "localhost", port=self.port)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = 'localhost', port = 9148, handlers = None
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_commit
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_commit
cls =
@classmethod
def setUpClass(cls):
cls.backend = SwiftSystemBackend()
cls.port = 9148
cls.server_address = "localhost"
cls.fakerepo = "fakerepo"
cls.th_server = DulwichServer(cls.backend, cls.port)
> cls.th_server.run()
tests/contrib/test_swift_smoke.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/contrib/test_swift_smoke.py:58: in run
self.server = server.TCPGitServer(self.backend, "localhost", port=self.port)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = 'localhost', port = 9148, handlers = None
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_data_branch
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_data_branch
cls =
@classmethod
def setUpClass(cls):
cls.backend = SwiftSystemBackend()
cls.port = 9148
cls.server_address = "localhost"
cls.fakerepo = "fakerepo"
cls.th_server = DulwichServer(cls.backend, cls.port)
> cls.th_server.run()
tests/contrib/test_swift_smoke.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/contrib/test_swift_smoke.py:58: in run
self.server = server.TCPGitServer(self.backend, "localhost", port=self.port)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = 'localhost', port = 9148, handlers = None
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_multiple_branch
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_multiple_branch
cls =
@classmethod
def setUpClass(cls):
cls.backend = SwiftSystemBackend()
cls.port = 9148
cls.server_address = "localhost"
cls.fakerepo = "fakerepo"
cls.th_server = DulwichServer(cls.backend, cls.port)
> cls.th_server.run()
tests/contrib/test_swift_smoke.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/contrib/test_swift_smoke.py:58: in run
self.server = server.TCPGitServer(self.backend, "localhost", port=self.port)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = 'localhost', port = 9148, handlers = None
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_remove_branch
test_swift_smoke.py::SwiftRepoSmokeTest::test_push_remove_branch
cls =
@classmethod
def setUpClass(cls):
cls.backend = SwiftSystemBackend()
cls.port = 9148
cls.server_address = "localhost"
cls.fakerepo = "fakerepo"
cls.th_server = DulwichServer(cls.backend, cls.port)
> cls.th_server.run()
tests/contrib/test_swift_smoke.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/contrib/test_swift_smoke.py:58: in run
self.server = server.TCPGitServer(self.backend, "localhost", port=self.port)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
backend =
listen_addr = 'localhost', port = 9148, handlers = None
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None) -> None:
self.handlers = dict(DEFAULT_HANDLERS)
if handlers is not None:
self.handlers.update(handlers)
self.backend = backend
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
> socketserver.TCPServer.__init__(self, (listen_addr, port), self._make_handler)
E AttributeError: 'TCPGitServer' object has no attribute '_make_handler'
dulwich/server.py:331: AttributeError
test_archive.py::ArchiveTests::test_empty
test_archive.py::ArchiveTests::test_empty
self =
def test_empty(self):
store = MemoryObjectStore()
> c1, c2, c3 = build_commit_graph(store, [[1], [2, 1], [3, 1, 2]])
E TypeError: cannot unpack non-iterable NoneType object
tests/test_archive.py:44: TypeError
test_archive.py::ArchiveTests::test_gzip_mtime
test_archive.py::ArchiveTests::test_gzip_mtime
self =
def test_gzip_mtime(self):
> stream = self._get_example_tar_stream(mtime=1234, format="gz")
tests/test_archive.py:87:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
tar_stream_args = (), tar_stream_kwargs = {'format': 'gz', 'mtime': 1234}
store =
b1 = None, t1 =
def _get_example_tar_stream(self, *tar_stream_args, **tar_stream_kwargs):
store = MemoryObjectStore()
b1 = Blob.from_string(b"somedata")
store.add_object(b1)
t1 = Tree()
> t1.add(b"somename", 0o100644, b1.id)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_archive.py:57: AttributeError
test_archive.py::ArchiveTests::test_prefix
test_archive.py::ArchiveTests::test_prefix
self =
def test_prefix(self):
> stream = self._get_example_tar_stream(mtime=0, prefix=b"blah")
tests/test_archive.py:81:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
tar_stream_args = (), tar_stream_kwargs = {'mtime': 0, 'prefix': b'blah'}
store =
b1 = None, t1 =
def _get_example_tar_stream(self, *tar_stream_args, **tar_stream_kwargs):
store = MemoryObjectStore()
b1 = Blob.from_string(b"somedata")
store.add_object(b1)
t1 = Tree()
> t1.add(b"somename", 0o100644, b1.id)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_archive.py:57: AttributeError
test_archive.py::ArchiveTests::test_same_file
test_archive.py::ArchiveTests::test_same_file
self =
@skipUnless(patch, "Required mock.patch")
def test_same_file(self):
contents = [None, None]
for format in ["", "gz", "bz2"]:
for i in [0, 1]:
with patch("time.time", return_value=i):
> stream = self._get_example_tar_stream(mtime=0, format=format)
tests/test_archive.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
tar_stream_args = (), tar_stream_kwargs = {'format': '', 'mtime': 0}
store =
b1 = None, t1 =
def _get_example_tar_stream(self, *tar_stream_args, **tar_stream_kwargs):
store = MemoryObjectStore()
b1 = Blob.from_string(b"somedata")
store.add_object(b1)
t1 = Tree()
> t1.add(b"somename", 0o100644, b1.id)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_archive.py:57: AttributeError
test_archive.py::ArchiveTests::test_simple
test_archive.py::ArchiveTests::test_simple
self =
def test_simple(self):
> stream = self._get_example_tar_stream(mtime=0)
tests/test_archive.py:63:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
tar_stream_args = (), tar_stream_kwargs = {'mtime': 0}
store =
b1 = None, t1 =
def _get_example_tar_stream(self, *tar_stream_args, **tar_stream_kwargs):
store = MemoryObjectStore()
b1 = Blob.from_string(b"somedata")
store.add_object(b1)
t1 = Tree()
> t1.add(b"somename", 0o100644, b1.id)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_archive.py:57: AttributeError
test_archive.py::ArchiveTests::test_unicode
test_archive.py::ArchiveTests::test_unicode
self =
def test_unicode(self):
store = MemoryObjectStore()
b1 = Blob.from_string(b"somedata")
store.add_object(b1)
t1 = Tree()
> t1.add("Å‘".encode(), 0o100644, b1.id)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_archive.py:73: AttributeError
test_bundle.py::BundleTests::test_roundtrip_bundle
test_bundle.py::BundleTests::test_roundtrip_bundle
self =
def test_roundtrip_bundle(self):
origbundle = Bundle()
origbundle.version = 3
origbundle.capabilities = {"foo": None}
origbundle.references = {b"refs/heads/master": b"ab" * 20}
origbundle.prerequisites = [(b"cc" * 20, "comment")]
b = BytesIO()
write_pack_objects(b.write, [])
b.seek(0)
> origbundle.pack_data = PackData.from_file(b)
E AttributeError: type object 'PackData' has no attribute 'from_file'
tests/test_bundle.py:43: AttributeError
test_config.py::ConfigFileTests::test_closing_bracket_within_section_string
test_config.py::ConfigFileTests::test_closing_bracket_within_section_string
self =
def test_closing_bracket_within_section_string(self):
cf = self.from_file(b'[branch "foo]bar"] # a comment\nbar= foo\n')
> self.assertEqual(ConfigFile({(b"branch", b"foo]bar"): {b"bar": b"foo"}}), cf)
tests/test_config.py:108:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec207f8fd0>
values = {(b'branch', b'foo]bar'): {b'bar': b'foo'}}, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_comment_after_section
self =
def test_comment_after_section(self):
cf = self.from_file(b"[section] # foo\n")
> self.assertEqual(ConfigFile({(b"section",): {}}), cf)
tests/test_config.py:92:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1fcc8370>
values = {(b'section',): {}}, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_comment_after_variable
self =
def test_comment_after_variable(self):
cf = self.from_file(b"[section]\nbar= foo # a comment\n")
> self.assertEqual(ConfigFile({(b"section",): {b"bar": b"foo"}}), cf)
tests/test_config.py:96:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1f6a9a50>
values = {(b'section',): {b'bar': b'foo'}}, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_comment_before_section
self =
def test_comment_before_section(self):
cf = self.from_file(b"# foo\n[section]\n")
> self.assertEqual(ConfigFile({(b"section",): {}}), cf)
tests/test_config.py:88:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1fca7520>
values = {(b'section',): {}}, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_comment_character_within_section_string
self =
def test_comment_character_within_section_string(self):
cf = self.from_file(b'[branch "foo#bar"] # a comment\nbar= foo\n')
> self.assertEqual(ConfigFile({(b"branch", b"foo#bar"): {b"bar": b"foo"}}), cf)
tests/test_config.py:104:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec219b3340>
values = {(b'branch', b'foo#bar'): {b'bar': b'foo'}}, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_comment_character_within_value_string
self =
def test_comment_character_within_value_string(self):
cf = self.from_file(b'[section]\nbar= "foo#bar"\n')
> self.assertEqual(ConfigFile({(b"section",): {b"bar": b"foo#bar"}}), cf)
tests/test_config.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec208f4f70>
values = {(b'section',): {b'bar': b'foo#bar'}}, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_default_config
test_config.py::ConfigFileTests::test_default_config
self =
def test_default_config(self):
cf = self.from_file(
b"""[core]
\trepositoryformatversion = 0
\tfilemode = true
\tbare = false
\tlogallrefupdates = true
"""
)
self.assertEqual(
> ConfigFile(
{
(b"core",): {
b"repositoryformatversion": b"0",
b"filemode": b"true",
b"bare": b"false",
b"logallrefupdates": b"true",
}
}
),
cf,
)
tests/test_config.py:65:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1f7bb880>
values = {(b'core',): {b'bare': b'false', b'filemode': b'true', b'logallrefupdates': b'true', b'repositoryformatversion': b'0'}}
encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_empty
test_config.py::ConfigFileTests::test_empty
self =
def test_empty(self):
> ConfigFile()
tests/test_config.py:50:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1fc97b20>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_empty_line_before_section
test_config.py::ConfigFileTests::test_empty_line_before_section
self =
def test_empty_line_before_section(self):
cf = self.from_file(b"\n[section]\n")
> self.assertEqual(ConfigFile({(b"section",): {}}), cf)
tests/test_config.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1fcac9a0>
values = {(b'section',): {}}, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_eq
test_config.py::ConfigFileTests::test_eq
self =
def test_eq(self):
> self.assertEqual(ConfigFile(), ConfigFile())
tests/test_config.py:53:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1f9f3a00>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_from_file_empty
test_config.py::ConfigFileTests::test_from_file_empty
self =
def test_from_file_empty(self):
cf = self.from_file(b"")
> self.assertEqual(ConfigFile(), cf)
tests/test_config.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1fb4a530>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_from_file_multiple
test_config.py::ConfigFileTests::test_from_file_multiple
self =
def test_from_file_multiple(self):
cf = self.from_file(b"[core]\nfoo = bar\nfoo = blah\n")
> self.assertEqual([b"bar", b"blah"], list(cf.get_multivar((b"core",), b"foo")))
E AttributeError: 'NoneType' object has no attribute 'get_multivar'
tests/test_config.py:117: AttributeError
test_config.py::ConfigFileTests::test_from_file_section
test_config.py::ConfigFileTests::test_from_file_section
self =
def test_from_file_section(self):
cf = self.from_file(b"[core]\nfoo = bar\n")
> self.assertEqual(b"bar", cf.get((b"core",), b"foo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:112: AttributeError
test_config.py::ConfigFileTests::test_from_file_section_case_insensitive_lower
test_config.py::ConfigFileTests::test_from_file_section_case_insensitive_lower
self =
def test_from_file_section_case_insensitive_lower(self):
cf = self.from_file(b"[cOre]\nfOo = bar\n")
> self.assertEqual(b"bar", cf.get((b"core",), b"foo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:127: AttributeError
test_config.py::ConfigFileTests::test_from_file_section_case_insensitive_mixed
test_config.py::ConfigFileTests::test_from_file_section_case_insensitive_mixed
self =
def test_from_file_section_case_insensitive_mixed(self):
cf = self.from_file(b"[cOre]\nfOo = bar\n")
> self.assertEqual(b"bar", cf.get((b"core",), b"fOo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:132: AttributeError
test_config.py::ConfigFileTests::test_from_file_section_with_open_brackets
test_config.py::ConfigFileTests::test_from_file_section_with_open_brackets
self =
def test_from_file_section_with_open_brackets(self):
> self.assertRaises(ValueError, self.from_file, b"[core\nfoo = bar\n")
E AssertionError: ValueError not raised by from_file
tests/test_config.py:140: AssertionError
test_config.py::ConfigFileTests::test_from_file_subsection
test_config.py::ConfigFileTests::test_from_file_subsection
self =
def test_from_file_subsection(self):
cf = self.from_file(b'[branch "foo"]\nfoo = bar\n')
> self.assertEqual(b"bar", cf.get((b"branch", b"foo"), b"foo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:159: AttributeError
test_config.py::ConfigFileTests::test_from_file_subsection_invalid
test_config.py::ConfigFileTests::test_from_file_subsection_invalid
self =
def test_from_file_subsection_invalid(self):
> self.assertRaises(ValueError, self.from_file, b'[branch "foo]\nfoo = bar\n')
E AssertionError: ValueError not raised by from_file
tests/test_config.py:162: AssertionError
test_config.py::ConfigFileTests::test_from_file_subsection_not_quoted
test_config.py::ConfigFileTests::test_from_file_subsection_not_quoted
self =
def test_from_file_subsection_not_quoted(self):
cf = self.from_file(b"[branch.foo]\nfoo = bar\n")
> self.assertEqual(b"bar", cf.get((b"branch", b"foo"), b"foo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:166: AttributeError
test_config.py::ConfigFileTests::test_from_file_utf8_bom
test_config.py::ConfigFileTests::test_from_file_utf8_bom
self =
def test_from_file_utf8_bom(self):
text = "[core]\nfoo = b\u00e4r\n".encode("utf-8-sig")
cf = self.from_file(text)
> self.assertEqual(b"b\xc3\xa4r", cf.get((b"core",), b"foo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:123: AttributeError
test_config.py::ConfigFileTests::test_from_file_value_with_open_quoted
test_config.py::ConfigFileTests::test_from_file_value_with_open_quoted
self =
def test_from_file_value_with_open_quoted(self):
> self.assertRaises(ValueError, self.from_file, b'[core]\nfoo = "bar\n')
E AssertionError: ValueError not raised by from_file
tests/test_config.py:143: AssertionError
test_config.py::ConfigFileTests::test_from_file_with_boolean_setting
test_config.py::ConfigFileTests::test_from_file_with_boolean_setting
self =
def test_from_file_with_boolean_setting(self):
cf = self.from_file(b"[core]\n" b"foo\n")
> self.assertEqual(b"true", cf.get((b"core",), b"foo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:155: AttributeError
test_config.py::ConfigFileTests::test_from_file_with_interrupted_line
test_config.py::ConfigFileTests::test_from_file_with_interrupted_line
self =
def test_from_file_with_interrupted_line(self):
cf = self.from_file(b"[core]\n" b"foo = bar\\\n" b" la\n")
> self.assertEqual(b"barla", cf.get((b"core",), b"foo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:151: AttributeError
test_config.py::ConfigFileTests::test_from_file_with_mixed_quoted
test_config.py::ConfigFileTests::test_from_file_with_mixed_quoted
self =
def test_from_file_with_mixed_quoted(self):
cf = self.from_file(b'[core]\nfoo = "bar"la\n')
> self.assertEqual(b"barla", cf.get((b"core",), b"foo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:137: AttributeError
test_config.py::ConfigFileTests::test_from_file_with_quotes
test_config.py::ConfigFileTests::test_from_file_with_quotes
self =
def test_from_file_with_quotes(self):
cf = self.from_file(b"[core]\n" b'foo = " bar"\n')
> self.assertEqual(b" bar", cf.get((b"core",), b"foo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:147: AttributeError
test_config.py::ConfigFileTests::test_quoted
test_config.py::ConfigFileTests::test_quoted
self =
def test_quoted(self):
cf = self.from_file(
b"""[gui]
\tfontdiff = -family \\\"Ubuntu Mono\\\" -size 11 -overstrike 0
"""
)
self.assertEqual(
> ConfigFile(
{
(b"gui",): {
b"fontdiff": b'-family "Ubuntu Mono" -size 11 -overstrike 0',
}
}
),
cf,
)
tests/test_config.py:219:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1fb48ac0>
values = {(b'gui',): {b'fontdiff': b'-family "Ubuntu Mono" -size 11 -overstrike 0'}}
encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_quoted_multiline
test_config.py::ConfigFileTests::test_quoted_multiline
self =
def test_quoted_multiline(self):
cf = self.from_file(
b"""[alias]
who = \"!who() {\\
git log --no-merges --pretty=format:'%an - %ae' $@ | uniq -c | sort -rn;\\
};\\
who\"
"""
)
self.assertEqual(
> ConfigFile(
{
(b"alias",): {
b"who": (
b"!who() {git log --no-merges --pretty=format:'%an - "
b"%ae' $@ | uniq -c | sort -rn;};who"
)
}
}
),
cf,
)
tests/test_config.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1f9d8640>
values = {(b'alias',): {b'who': b"!who() {git log --no-merges --pretty=format:'%an - %ae' $@ | uniq -c | sort -rn;};who"}}
encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_quoted_newlines_windows
test_config.py::ConfigFileTests::test_quoted_newlines_windows
self =
def test_quoted_newlines_windows(self):
cf = self.from_file(
b"[alias]\r\n"
b"c = '!f() { \\\r\n"
b' printf \'[git commit -m \\"%s\\"]\\n\' \\"$*\\" && \\\r\n'
b' git commit -m \\"$*\\"; \\\r\n'
b" }; f'\r\n"
)
> self.assertEqual(list(cf.sections()), [(b"alias",)])
E AttributeError: 'NoneType' object has no attribute 'sections'
tests/test_config.py:206: AttributeError
test_config.py::ConfigFileTests::test_same_line
test_config.py::ConfigFileTests::test_same_line
self =
def test_same_line(self):
cf = self.from_file(b"[branch.foo] foo = bar\n")
> self.assertEqual(b"bar", cf.get((b"branch", b"foo"), b"foo"))
E AttributeError: 'NoneType' object has no attribute 'get'
tests/test_config.py:196: AttributeError
test_config.py::ConfigFileTests::test_set_hash_gets_quoted
test_config.py::ConfigFileTests::test_set_hash_gets_quoted
self =
def test_set_hash_gets_quoted(self):
> c = ConfigFile()
tests/test_config.py:253:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1fafca60>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_write_preserve_multivar
test_config.py::ConfigFileTests::test_write_preserve_multivar
self =
def test_write_preserve_multivar(self):
cf = self.from_file(b"[core]\nfoo = bar\nfoo = blah\n")
f = BytesIO()
> cf.write_to_file(f)
E AttributeError: 'NoneType' object has no attribute 'write_to_file'
tests/test_config.py:171: AttributeError
test_config.py::ConfigFileTests::test_write_to_file_empty
test_config.py::ConfigFileTests::test_write_to_file_empty
self =
def test_write_to_file_empty(self):
> c = ConfigFile()
tests/test_config.py:175:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1f9f6a70>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_write_to_file_section
test_config.py::ConfigFileTests::test_write_to_file_section
self =
def test_write_to_file_section(self):
> c = ConfigFile()
tests/test_config.py:181:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1f669090>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigFileTests::test_write_to_file_subsection
test_config.py::ConfigFileTests::test_write_to_file_subsection
self =
def test_write_to_file_subsection(self):
> c = ConfigFile()
tests/test_config.py:188:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/config.py:251: in __init__
super().__init__(values=values, encoding=encoding)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigFile' object has no attribute '_values'") raised in repr()] ConfigFile object at 0x7eec1fb57160>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigDictTests::test_dict
test_config.py::ConfigDictTests::test_dict
self =
def test_dict(self):
> cd = ConfigDict()
tests/test_config.py:279:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigDict' object has no attribute '_values'") raised in repr()] ConfigDict object at 0x7eec1fcaf6d0>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigDictTests::test_get_boolean
test_config.py::ConfigDictTests::test_get_boolean
self =
def test_get_boolean(self):
> cd = ConfigDict()
tests/test_config.py:270:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigDict' object has no attribute '_values'") raised in repr()] ConfigDict object at 0x7eec1fb4a830>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigDictTests::test_get_set
test_config.py::ConfigDictTests::test_get_set
self =
def test_get_set(self):
> cd = ConfigDict()
tests/test_config.py:262:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigDict' object has no attribute '_values'") raised in repr()] ConfigDict object at 0x7eec1f82cee0>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigDictTests::test_items
test_config.py::ConfigDictTests::test_items
self =
def test_items(self):
> cd = ConfigDict()
tests/test_config.py:290:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigDict' object has no attribute '_values'") raised in repr()] ConfigDict object at 0x7eec1f9f6800>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigDictTests::test_items_nonexistant
test_config.py::ConfigDictTests::test_items_nonexistant
self =
def test_items_nonexistant(self):
> cd = ConfigDict()
tests/test_config.py:297:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigDict' object has no attribute '_values'") raised in repr()] ConfigDict object at 0x7eec1f9e6500>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ConfigDictTests::test_sections
test_config.py::ConfigDictTests::test_sections
self =
def test_sections(self):
> cd = ConfigDict()
tests/test_config.py:303:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigDict' object has no attribute '_values'") raised in repr()] ConfigDict object at 0x7eec1faf6500>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::EscapeValueTests::test_backslash
test_config.py::EscapeValueTests::test_backslash
self =
def test_backslash(self):
> self.assertEqual(b"foo\\\\", _escape_value(b"foo\\"))
E AssertionError: b'foo\\\\' != b'foo\\'
tests/test_config.py:357: AssertionError
test_config.py::EscapeValueTests::test_newline
test_config.py::EscapeValueTests::test_newline
self =
def test_newline(self):
> self.assertEqual(b"foo\\n", _escape_value(b"foo\n"))
E AssertionError: b'foo\\n' != b'foo\n'
tests/test_config.py:360: AssertionError
test_config.py::FormatStringTests::test_quoted
self =
def test_quoted(self):
> self.assertEqual(b'" foo"', _format_string(b" foo"))
E AssertionError: b'" foo"' != b' foo'
tests/test_config.py:365: AssertionError
test_config.py::ParseStringTests::test_newline
test_config.py::ParseStringTests::test_newline
self =
def test_newline(self):
> self.assertEqual(b"\nbar\t", _parse_string(b"\\nbar\\t\t"))
E AssertionError: b'\nbar\t' != b'\\nbar\\t\t'
tests/test_config.py:389: AssertionError
test_config.py::ParseStringTests::test_quote
test_config.py::ParseStringTests::test_quote
self =
def test_quote(self):
> self.assertEqual(b'"foo"', _parse_string(b'\\"foo\\"'))
E AssertionError: b'"foo"' != b'\\"foo\\"'
tests/test_config.py:392: AssertionError
test_config.py::ParseStringTests::test_tab
test_config.py::ParseStringTests::test_tab
self =
def test_tab(self):
> self.assertEqual(b"\tbar\t", _parse_string(b"\\tbar\\t"))
E AssertionError: b'\tbar\t' != b'\\tbar\\t'
tests/test_config.py:386: AssertionError
test_config.py::SubmodulesTests::testMalformedSubmodules
self =
def testMalformedSubmodules(self):
cf = ConfigFile.from_file(
BytesIO(
b"""\
[submodule "core/lib"]
\tpath = core/lib
\turl = https://github.com/phhusson/QuasselC.git
[submodule "dulwich"]
\turl = https://github.com/jelmer/dulwich
"""
)
)
> got = list(parse_submodules(cf))
E TypeError: 'NoneType' object is not iterable
tests/test_config.py:455: TypeError
test_config.py::SubmodulesTests::testSubmodules
test_config.py::SubmodulesTests::testSubmodules
self =
def testSubmodules(self):
cf = ConfigFile.from_file(
BytesIO(
b"""\
[submodule "core/lib"]
\tpath = core/lib
\turl = https://github.com/phhusson/QuasselC.git
"""
)
)
> got = list(parse_submodules(cf))
E TypeError: 'NoneType' object is not iterable
tests/test_config.py:430: TypeError
test_config.py::ApplyInsteadOfTests::test_apply
test_config.py::ApplyInsteadOfTests::test_apply
self =
def test_apply(self):
> config = ConfigDict()
tests/test_config.py:476:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigDict' object has no attribute '_values'") raised in repr()] ConfigDict object at 0x7eec1fc44760>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ApplyInsteadOfTests::test_apply_multiple
test_config.py::ApplyInsteadOfTests::test_apply_multiple
self =
def test_apply_multiple(self):
> config = ConfigDict()
tests/test_config.py:483:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigDict' object has no attribute '_values'") raised in repr()] ConfigDict object at 0x7eec1fa1e230>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_config.py::ApplyInsteadOfTests::test_none
test_config.py::ApplyInsteadOfTests::test_none
self =
def test_none(self):
> config = ConfigDict()
tests/test_config.py:470:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigDict' object has no attribute '_values'") raised in repr()] ConfigDict object at 0x7eec208567a0>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_credentials.py::TestCredentialHelpersUtils::test_match_partial_url
test_credentials.py::TestCredentialHelpersUtils::test_match_partial_url
self =
def test_match_partial_url(self):
url = urlparse("https://github.com/jelmer/dulwich/")
> self.assertTrue(match_partial_url(url, "github.com"))
E AssertionError: False is not true
tests/test_credentials.py:49: AssertionError
test_credentials.py::TestCredentialHelpersUtils::test_match_urls
test_credentials.py::TestCredentialHelpersUtils::test_match_urls
self =
def test_match_urls(self):
url = urlparse("https://github.com/jelmer/dulwich/")
url_1 = urlparse("https://github.com/jelmer/dulwich")
url_2 = urlparse("https://github.com/jelmer")
url_3 = urlparse("https://github.com")
> self.assertTrue(match_urls(url, url_1))
tests/test_credentials.py:40:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/credentials.py:19: in match_urls
parsed1 = urlparse(url1)
/usr/lib/python3.10/urllib/parse.py:399: in urlparse
url, scheme, _coerce_result = _coerce_args(url, scheme)
/usr/lib/python3.10/urllib/parse.py:136: in _coerce_args
return _decode_args(args) + (_encode_result,)
/usr/lib/python3.10/urllib/parse.py:120: in _decode_args
return tuple(x.decode(encoding, errors) if x else '' for x in args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 =
> return tuple(x.decode(encoding, errors) if x else '' for x in args)
E AttributeError: 'ParseResult' object has no attribute 'decode'. Did you mean: 'encode'?
/usr/lib/python3.10/urllib/parse.py:120: AttributeError
test_credentials.py::TestCredentialHelpersUtils::test_urlmatch_credential_sections
test_credentials.py::TestCredentialHelpersUtils::test_urlmatch_credential_sections
self =
def test_urlmatch_credential_sections(self):
> config = ConfigDict()
tests/test_credentials.py:56:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ConfigDict' object has no attribute '_values'") raised in repr()] ConfigDict object at 0x7eec1fcca3e0>
values = None, encoding = 'utf-8'
def __init__(self, values: Union[MutableMapping[Section, MutableMapping[Name, Value]], None]=None, encoding: Union[str, None]=None) -> None:
"""Create a new ConfigDict."""
if encoding is None:
encoding = sys.getdefaultencoding()
self.encoding = encoding
> self._values = CaseInsensitiveOrderedMultiDict.make(values)
E AttributeError: type object 'CaseInsensitiveOrderedMultiDict' has no attribute 'make'
dulwich/config.py:135: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_add_delete
test_diff_tree.py::TreeChangesTest::test_tree_changes_add_delete
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_change_type
test_diff_tree.py::TreeChangesTest::test_tree_changes_change_type
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_change_type_same
test_diff_tree.py::TreeChangesTest::test_tree_changes_change_type_same
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_complex
test_diff_tree.py::TreeChangesTest::test_tree_changes_complex
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_empty
test_diff_tree.py::TreeChangesTest::test_tree_changes_empty
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_add_add_same_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_add_add_same_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_add_content_rename_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_add_content_rename_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_add_exact_rename_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_add_exact_rename_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_add_modify_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_add_modify_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_add_no_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_add_no_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_delete_delete_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_delete_delete_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_delete_no_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_delete_no_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_modify_modify_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_modify_modify_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_modify_no_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_modify_no_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_modify_rename_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_modify_rename_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_octopus_delete
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_octopus_delete
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_octopus_modify_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_octopus_modify_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_octopus_no_conflict
test_diff_tree.py::TreeChangesTest::test_tree_changes_for_merge_octopus_no_conflict
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_modify_contents
test_diff_tree.py::TreeChangesTest::test_tree_changes_modify_contents
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_modify_mode
test_diff_tree.py::TreeChangesTest::test_tree_changes_modify_mode
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_name_order
test_diff_tree.py::TreeChangesTest::test_tree_changes_name_order
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_no_changes
test_diff_tree.py::TreeChangesTest::test_tree_changes_no_changes
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_prune
test_diff_tree.py::TreeChangesTest::test_tree_changes_prune
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_rename_detector
test_diff_tree.py::TreeChangesTest::test_tree_changes_rename_detector
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::TreeChangesTest::test_tree_changes_to_tree
test_diff_tree.py::TreeChangesTest::test_tree_changes_to_tree
self =
def setUp(self):
> super().setUp()
tests/test_diff_tree.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:55: in setUp
self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_content_rename_gitlink
test_diff_tree.py::RenameDetectionTest::test_content_rename_gitlink
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_content_rename_many_to_many
test_diff_tree.py::RenameDetectionTest::test_content_rename_many_to_many
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_content_rename_many_to_one
test_diff_tree.py::RenameDetectionTest::test_content_rename_many_to_one
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_content_rename_max_files
test_diff_tree.py::RenameDetectionTest::test_content_rename_max_files
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_content_rename_one_to_many
test_diff_tree.py::RenameDetectionTest::test_content_rename_one_to_many
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_content_rename_one_to_one
test_diff_tree.py::RenameDetectionTest::test_content_rename_one_to_one
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_content_rename_one_to_one_ordering
test_diff_tree.py::RenameDetectionTest::test_content_rename_one_to_one_ordering
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_content_rename_swap
test_diff_tree.py::RenameDetectionTest::test_content_rename_swap
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_content_rename_with_more_deletions
test_diff_tree.py::RenameDetectionTest::test_content_rename_with_more_deletions
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_exact_copy_change_mode
test_diff_tree.py::RenameDetectionTest::test_exact_copy_change_mode
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_exact_copy_modify
test_diff_tree.py::RenameDetectionTest::test_exact_copy_modify
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_exact_rename_and_different_type
test_diff_tree.py::RenameDetectionTest::test_exact_rename_and_different_type
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_exact_rename_many_to_many
test_diff_tree.py::RenameDetectionTest::test_exact_rename_many_to_many
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_exact_rename_many_to_one
test_diff_tree.py::RenameDetectionTest::test_exact_rename_many_to_one
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_exact_rename_one_to_many
test_diff_tree.py::RenameDetectionTest::test_exact_rename_one_to_many
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_exact_rename_one_to_one
test_diff_tree.py::RenameDetectionTest::test_exact_rename_one_to_one
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_exact_rename_split_different_type
test_diff_tree.py::RenameDetectionTest::test_exact_rename_split_different_type
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_exact_rename_swap
test_diff_tree.py::RenameDetectionTest::test_exact_rename_swap
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_find_copies_harder_content
test_diff_tree.py::RenameDetectionTest::test_find_copies_harder_content
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_find_copies_harder_exact
test_diff_tree.py::RenameDetectionTest::test_find_copies_harder_exact
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_find_copies_harder_with_rewrites
test_diff_tree.py::RenameDetectionTest::test_find_copies_harder_with_rewrites
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_no_renames
test_diff_tree.py::RenameDetectionTest::test_no_renames
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_rename_threshold
test_diff_tree.py::RenameDetectionTest::test_rename_threshold
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_reuse_detector
test_diff_tree.py::RenameDetectionTest::test_reuse_detector
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_rewrite_threshold
test_diff_tree.py::RenameDetectionTest::test_rewrite_threshold
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_similarity_score
test_diff_tree.py::RenameDetectionTest::test_similarity_score
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_similarity_score_cache
test_diff_tree.py::RenameDetectionTest::test_similarity_score_cache
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_tree_entry_sort
test_diff_tree.py::RenameDetectionTest::test_tree_entry_sort
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_diff_tree.py::RenameDetectionTest::test_want_unchanged
test_diff_tree.py::RenameDetectionTest::test_want_unchanged
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
> self.empty_tree = self.commit_tree([])
tests/test_diff_tree.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_diff_tree.py:71: in commit_tree
return self.store[commit_tree(self.store, commit_blobs)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = None
def __getitem__(self, name: ObjectID):
> return self._data[self._to_hexsha(name)].copy()
E AttributeError: 'MemoryObjectStore' object has no attribute '_to_hexsha'
dulwich/object_store.py:405: AttributeError
test_fastexport.py::GitImportProcessorTests::test_commit_handler
test_fastexport.py::GitImportProcessorTests::test_commit_handler
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_fastexport.py::GitImportProcessorTests::test_commit_handler_markers
test_fastexport.py::GitImportProcessorTests::test_commit_handler_markers
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_fastexport.py::GitImportProcessorTests::test_file_add
test_fastexport.py::GitImportProcessorTests::test_file_add
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_fastexport.py::GitImportProcessorTests::test_file_copy
test_fastexport.py::GitImportProcessorTests::test_file_copy
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_fastexport.py::GitImportProcessorTests::test_file_delete
test_fastexport.py::GitImportProcessorTests::test_file_delete
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_fastexport.py::GitImportProcessorTests::test_file_deleteall
test_fastexport.py::GitImportProcessorTests::test_file_deleteall
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_fastexport.py::GitImportProcessorTests::test_file_move
test_fastexport.py::GitImportProcessorTests::test_file_move
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_fastexport.py::GitImportProcessorTests::test_import_stream
test_fastexport.py::GitImportProcessorTests::test_import_stream
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_fastexport.py::GitImportProcessorTests::test_reset_handler
test_fastexport.py::GitImportProcessorTests::test_reset_handler
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_fastexport.py::GitImportProcessorTests::test_reset_handler_default
test_fastexport.py::GitImportProcessorTests::test_reset_handler_default
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_fastexport.py::GitImportProcessorTests::test_reset_handler_marker
test_fastexport.py::GitImportProcessorTests::test_reset_handler_marker
self =
def setUp(self):
super().setUp()
> self.repo = MemoryRepo()
tests/test_fastexport.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_file.py::FancyRenameTests::test_dest_exists
test_file.py::FancyRenameTests::test_dest_exists
self =
def test_dest_exists(self):
self.create(self.bar, b"bar contents")
_fancy_rename(self.foo, self.bar)
> self.assertFalse(os.path.exists(self.foo))
E AssertionError: True is not false
tests/test_file.py:64: AssertionError
test_file.py::FancyRenameTests::test_no_dest_exists
test_file.py::FancyRenameTests::test_no_dest_exists
self =
def test_no_dest_exists(self):
self.assertFalse(os.path.exists(self.bar))
_fancy_rename(self.foo, self.bar)
> self.assertFalse(os.path.exists(self.foo))
E AssertionError: True is not false
tests/test_file.py:55: AssertionError
test_file.py::GitFileTests::test_abort
test_file.py::GitFileTests::test_abort
self =
def test_abort(self):
foo = self.path("foo")
foo_lock = f"{foo}.lock"
orig_f = open(foo, "rb")
self.assertEqual(orig_f.read(), b"foo contents")
orig_f.close()
f = GitFile(foo, "wb")
> f.write(b"new contents")
E AttributeError: 'NoneType' object has no attribute 'write'
tests/test_file.py:177: AttributeError
test_file.py::GitFileTests::test_abort_close
test_file.py::GitFileTests::test_abort_close
self =
def test_abort_close(self):
foo = self.path("foo")
f = GitFile(foo, "wb")
> f.abort()
E AttributeError: 'NoneType' object has no attribute 'abort'
tests/test_file.py:189: AttributeError
test_file.py::GitFileTests::test_abort_close_removed
test_file.py::GitFileTests::test_abort_close_removed
self =
def test_abort_close_removed(self):
foo = self.path("foo")
f = GitFile(foo, "wb")
> f._file.close()
E AttributeError: 'NoneType' object has no attribute '_file'
tests/test_file.py:206: AttributeError
test_file.py::GitFileTests::test_default_mode
test_file.py::GitFileTests::test_default_mode
self =
def test_default_mode(self):
f = GitFile(self.path("foo"))
> self.assertEqual(b"foo contents", f.read())
E AttributeError: 'NoneType' object has no attribute 'read'
tests/test_file.py:122: AttributeError
test_file.py::GitFileTests::test_invalid
test_file.py::GitFileTests::test_invalid
self =
def test_invalid(self):
foo = self.path("foo")
> self.assertRaises(IOError, GitFile, foo, mode="r")
E AssertionError: OSError not raised by GitFile
tests/test_file.py:105: AssertionError
test_file.py::GitFileTests::test_open_twice
test_file.py::GitFileTests::test_open_twice
self =
def test_open_twice(self):
foo = self.path("foo")
f1 = GitFile(foo, "wb")
> f1.write(b"new")
E AttributeError: 'NoneType' object has no attribute 'write'
tests/test_file.py:152: AttributeError
test_file.py::GitFileTests::test_readonly
test_file.py::GitFileTests::test_readonly
self =
def test_readonly(self):
f = GitFile(self.path("foo"), "rb")
> self.assertIsInstance(f, io.IOBase)
E AssertionError: None is not an instance of
tests/test_file.py:113: AssertionError
test_file.py::GitFileTests::test_write
test_file.py::GitFileTests::test_write
self =
def test_write(self):
foo = self.path("foo")
foo_lock = f"{foo}.lock"
orig_f = open(foo, "rb")
self.assertEqual(orig_f.read(), b"foo contents")
orig_f.close()
self.assertFalse(os.path.exists(foo_lock))
f = GitFile(foo, "wb")
> self.assertFalse(f.closed)
E AttributeError: 'NoneType' object has no attribute 'closed'
tests/test_file.py:135: AttributeError
test_grafts.py::GraftParserTests::test_multiple_hybrid
test_grafts.py::GraftParserTests::test_multiple_hybrid
self =
def test_multiple_hybrid(self):
> self.assertParse(
{
makesha(0): [],
makesha(1): [makesha(2)],
makesha(3): [makesha(4), makesha(5)],
},
[
makesha(0),
b" ".join([makesha(1), makesha(2)]),
b" ".join([makesha(3), makesha(4), makesha(5)]),
],
)
tests/test_grafts.py:54:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_grafts.py:39: in assertParse
self.assertEqual(expected, parse_graftpoints(iter(graftpoints)))
E AssertionError: {b'00000000000000000000000000000000000000[232 chars]55']} != None
test_grafts.py::GraftParserTests::test_no_grafts
test_grafts.py::GraftParserTests::test_no_grafts
self =
def test_no_grafts(self):
> self.assertParse({}, [])
tests/test_grafts.py:42:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_grafts.py:39: in assertParse
self.assertEqual(expected, parse_graftpoints(iter(graftpoints)))
E AssertionError: {} != None
test_grafts.py::GraftParserTests::test_no_parents
test_grafts.py::GraftParserTests::test_no_parents
self =
def test_no_parents(self):
> self.assertParse({makesha(0): []}, [makesha(0)])
tests/test_grafts.py:45:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_grafts.py:39: in assertParse
self.assertEqual(expected, parse_graftpoints(iter(graftpoints)))
E AssertionError: {b'0000000000000000000000000000000000000000': []} != None
test_grafts.py::GraftParserTests::test_parents
test_grafts.py::GraftParserTests::test_parents
self =
def test_parents(self):
> self.assertParse(
{makesha(0): [makesha(1), makesha(2)]},
[b" ".join([makesha(0), makesha(1), makesha(2)])],
)
tests/test_grafts.py:48:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_grafts.py:39: in assertParse
self.assertEqual(expected, parse_graftpoints(iter(graftpoints)))
E AssertionError: {b'00000000000000000000000000000000000000[91 chars]22']} != None
test_grafts.py::GraftSerializerTests::test_multiple_hybrid
test_grafts.py::GraftSerializerTests::test_multiple_hybrid
self =
def test_multiple_hybrid(self):
> self.assertSerialize(
b"\n".join(
[
makesha(0),
b" ".join([makesha(1), makesha(2)]),
b" ".join([makesha(3), makesha(4), makesha(5)]),
]
),
{
makesha(0): [],
makesha(1): [makesha(2)],
makesha(3): [makesha(4), makesha(5)],
},
)
tests/test_grafts.py:85:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
expected = b'0000000000000000000000000000000000000000\n1111111111111111111111111111111111111111 222222222222222222222222222222222...333333333333333333333333333333333333 4444444444444444444444444444444444444444 5555555555555555555555555555555555555555'
graftpoints = {b'0000000000000000000000000000000000000000': [], b'1111111111111111111111111111111111111111': [b'22222222222222222222...3333333333333333333333333': [b'4444444444444444444444444444444444444444', b'5555555555555555555555555555555555555555']}
def assertSerialize(self, expected, graftpoints):
> self.assertEqual(sorted(expected), sorted(serialize_graftpoints(graftpoints)))
E TypeError: 'NoneType' object is not iterable
tests/test_grafts.py:70: TypeError
test_grafts.py::GraftSerializerTests::test_no_grafts
test_grafts.py::GraftSerializerTests::test_no_grafts
self =
def test_no_grafts(self):
> self.assertSerialize(b"", {})
tests/test_grafts.py:73:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
expected = b'', graftpoints = {}
def assertSerialize(self, expected, graftpoints):
> self.assertEqual(sorted(expected), sorted(serialize_graftpoints(graftpoints)))
E TypeError: 'NoneType' object is not iterable
tests/test_grafts.py:70: TypeError
test_grafts.py::GraftSerializerTests::test_no_parents
test_grafts.py::GraftSerializerTests::test_no_parents
self =
def test_no_parents(self):
> self.assertSerialize(makesha(0), {makesha(0): []})
tests/test_grafts.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
expected = b'0000000000000000000000000000000000000000'
graftpoints = {b'0000000000000000000000000000000000000000': []}
def assertSerialize(self, expected, graftpoints):
> self.assertEqual(sorted(expected), sorted(serialize_graftpoints(graftpoints)))
E TypeError: 'NoneType' object is not iterable
tests/test_grafts.py:70: TypeError
test_grafts.py::GraftSerializerTests::test_parents
test_grafts.py::GraftSerializerTests::test_parents
self =
def test_parents(self):
> self.assertSerialize(
b" ".join([makesha(0), makesha(1), makesha(2)]),
{makesha(0): [makesha(1), makesha(2)]},
)
tests/test_grafts.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
expected = b'0000000000000000000000000000000000000000 1111111111111111111111111111111111111111 2222222222222222222222222222222222222222'
graftpoints = {b'0000000000000000000000000000000000000000': [b'1111111111111111111111111111111111111111', b'2222222222222222222222222222222222222222']}
def assertSerialize(self, expected, graftpoints):
> self.assertEqual(sorted(expected), sorted(serialize_graftpoints(graftpoints)))
E TypeError: 'NoneType' object is not iterable
tests/test_grafts.py:70: TypeError
test_grafts.py::GraftsInRepoTests::test_existing_parent_graft
test_grafts.py::GraftsInRepoTests::test_existing_parent_graft
self =
def setUp(self):
super().setUp()
self._repo_dir = os.path.join(tempfile.mkdtemp())
r = self._repo = Repo.init(self._repo_dir)
self.addCleanup(shutil.rmtree, self._repo_dir)
self._shas = []
commit_kwargs = {
"committer": b"Test Committer ",
"author": b"Test Author ",
"commit_timestamp": 12395,
"commit_timezone": 0,
"author_timestamp": 12395,
"author_timezone": 0,
}
> self._shas.append(r.do_commit(b"empty commit", **commit_kwargs))
E AttributeError: 'NoneType' object has no attribute 'do_commit'
tests/test_grafts.py:161: AttributeError
test_grafts.py::GraftsInRepoTests::test_init_with_empty_info_grafts
test_grafts.py::GraftsInRepoTests::test_init_with_empty_info_grafts
self =
def setUp(self):
super().setUp()
self._repo_dir = os.path.join(tempfile.mkdtemp())
r = self._repo = Repo.init(self._repo_dir)
self.addCleanup(shutil.rmtree, self._repo_dir)
self._shas = []
commit_kwargs = {
"committer": b"Test Committer ",
"author": b"Test Author ",
"commit_timestamp": 12395,
"commit_timezone": 0,
"author_timestamp": 12395,
"author_timezone": 0,
}
> self._shas.append(r.do_commit(b"empty commit", **commit_kwargs))
E AttributeError: 'NoneType' object has no attribute 'do_commit'
tests/test_grafts.py:161: AttributeError
test_grafts.py::GraftsInRepoTests::test_init_with_info_grafts
test_grafts.py::GraftsInRepoTests::test_init_with_info_grafts
self =
def setUp(self):
super().setUp()
self._repo_dir = os.path.join(tempfile.mkdtemp())
r = self._repo = Repo.init(self._repo_dir)
self.addCleanup(shutil.rmtree, self._repo_dir)
self._shas = []
commit_kwargs = {
"committer": b"Test Committer ",
"author": b"Test Author ",
"commit_timestamp": 12395,
"commit_timezone": 0,
"author_timestamp": 12395,
"author_timezone": 0,
}
> self._shas.append(r.do_commit(b"empty commit", **commit_kwargs))
E AttributeError: 'NoneType' object has no attribute 'do_commit'
tests/test_grafts.py:161: AttributeError
test_grafts.py::GraftsInRepoTests::test_no_grafts
test_grafts.py::GraftsInRepoTests::test_no_grafts
self =
def setUp(self):
super().setUp()
self._repo_dir = os.path.join(tempfile.mkdtemp())
r = self._repo = Repo.init(self._repo_dir)
self.addCleanup(shutil.rmtree, self._repo_dir)
self._shas = []
commit_kwargs = {
"committer": b"Test Committer ",
"author": b"Test Author ",
"commit_timestamp": 12395,
"commit_timezone": 0,
"author_timestamp": 12395,
"author_timezone": 0,
}
> self._shas.append(r.do_commit(b"empty commit", **commit_kwargs))
E AttributeError: 'NoneType' object has no attribute 'do_commit'
tests/test_grafts.py:161: AttributeError
test_grafts.py::GraftsInRepoTests::test_no_parents_graft
test_grafts.py::GraftsInRepoTests::test_no_parents_graft
self =
def setUp(self):
super().setUp()
self._repo_dir = os.path.join(tempfile.mkdtemp())
r = self._repo = Repo.init(self._repo_dir)
self.addCleanup(shutil.rmtree, self._repo_dir)
self._shas = []
commit_kwargs = {
"committer": b"Test Committer ",
"author": b"Test Author ",
"commit_timestamp": 12395,
"commit_timezone": 0,
"author_timestamp": 12395,
"author_timezone": 0,
}
> self._shas.append(r.do_commit(b"empty commit", **commit_kwargs))
E AttributeError: 'NoneType' object has no attribute 'do_commit'
tests/test_grafts.py:161: AttributeError
test_grafts.py::GraftsInRepoTests::test_object_store_fail_invalid_parents
test_grafts.py::GraftsInRepoTests::test_object_store_fail_invalid_parents
self =
def setUp(self):
super().setUp()
self._repo_dir = os.path.join(tempfile.mkdtemp())
r = self._repo = Repo.init(self._repo_dir)
self.addCleanup(shutil.rmtree, self._repo_dir)
self._shas = []
commit_kwargs = {
"committer": b"Test Committer ",
"author": b"Test Author ",
"commit_timestamp": 12395,
"commit_timezone": 0,
"author_timestamp": 12395,
"author_timezone": 0,
}
> self._shas.append(r.do_commit(b"empty commit", **commit_kwargs))
E AttributeError: 'NoneType' object has no attribute 'do_commit'
tests/test_grafts.py:161: AttributeError
test_grafts.py::GraftsInRepoTests::test_remove_graft
test_grafts.py::GraftsInRepoTests::test_remove_graft
self =
def setUp(self):
super().setUp()
self._repo_dir = os.path.join(tempfile.mkdtemp())
r = self._repo = Repo.init(self._repo_dir)
self.addCleanup(shutil.rmtree, self._repo_dir)
self._shas = []
commit_kwargs = {
"committer": b"Test Committer ",
"author": b"Test Author ",
"commit_timestamp": 12395,
"commit_timezone": 0,
"author_timestamp": 12395,
"author_timezone": 0,
}
> self._shas.append(r.do_commit(b"empty commit", **commit_kwargs))
E AttributeError: 'NoneType' object has no attribute 'do_commit'
tests/test_grafts.py:161: AttributeError
test_grafts.py::GraftsInMemoryRepoTests::test_existing_parent_graft
test_grafts.py::GraftsInMemoryRepoTests::test_existing_parent_graft
self =
def setUp(self):
super().setUp()
> r = self._repo = MemoryRepo()
tests/test_grafts.py:186:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_grafts.py::GraftsInMemoryRepoTests::test_no_grafts
test_grafts.py::GraftsInMemoryRepoTests::test_no_grafts
self =
def setUp(self):
super().setUp()
> r = self._repo = MemoryRepo()
tests/test_grafts.py:186:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_grafts.py::GraftsInMemoryRepoTests::test_no_parents_graft
test_grafts.py::GraftsInMemoryRepoTests::test_no_parents_graft
self =
def setUp(self):
super().setUp()
> r = self._repo = MemoryRepo()
tests/test_grafts.py:186:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_grafts.py::GraftsInMemoryRepoTests::test_object_store_fail_invalid_parents
test_grafts.py::GraftsInMemoryRepoTests::test_object_store_fail_invalid_parents
self =
def setUp(self):
super().setUp()
> r = self._repo = MemoryRepo()
tests/test_grafts.py:186:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_grafts.py::GraftsInMemoryRepoTests::test_remove_graft
test_grafts.py::GraftsInMemoryRepoTests::test_remove_graft
self =
def setUp(self):
super().setUp()
> r = self._repo = MemoryRepo()
tests/test_grafts.py:186:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_graph.py::FindMergeBaseTests::test_ancestor
test_graph.py::FindMergeBaseTests::test_ancestor
self =
def test_ancestor(self):
# ancestor
graph = {
"G": ["D", "F"],
"F": ["E"],
"D": ["C"],
"C": ["B"],
"E": ["B"],
"B": ["A"],
"A": [],
}
> self.assertEqual(self.run_test(graph, ["D", "C"]), {"C"})
tests/test_graph.py:78:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dag = {'A': [], 'B': ['A'], 'C': ['B'], 'D': ['C'], ...}, inputs = ['D', 'C']
@staticmethod
def run_test(dag, inputs):
def lookup_parents(commit_id):
return dag[commit_id]
def lookup_stamp(commit_id):
# any constant timestamp value here will work to force
# this test to test the same behaviour as done previously
return 100
c1 = inputs[0]
c2s = inputs[1:]
> return set(_find_lcas(lookup_parents, c1, c2s, lookup_stamp))
E TypeError: _find_lcas() takes 2 positional arguments but 4 were given
tests/test_graph.py:42: TypeError
test_graph.py::FindMergeBaseTests::test_another_crossover
test_graph.py::FindMergeBaseTests::test_another_crossover
self =
def test_another_crossover(self):
# Another cross over
graph = {
"G": ["D", "F"],
"F": ["E", "C"],
"D": ["C", "E"],
"C": ["B"],
"E": ["B"],
"B": ["A"],
"A": [],
}
> self.assertEqual(self.run_test(graph, ["D", "F"]), {"E", "C"})
tests/test_graph.py:104:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dag = {'A': [], 'B': ['A'], 'C': ['B'], 'D': ['C', 'E'], ...}
inputs = ['D', 'F']
@staticmethod
def run_test(dag, inputs):
def lookup_parents(commit_id):
return dag[commit_id]
def lookup_stamp(commit_id):
# any constant timestamp value here will work to force
# this test to test the same behaviour as done previously
return 100
c1 = inputs[0]
c2s = inputs[1:]
> return set(_find_lcas(lookup_parents, c1, c2s, lookup_stamp))
E TypeError: _find_lcas() takes 2 positional arguments but 4 were given
tests/test_graph.py:42: TypeError
test_graph.py::FindMergeBaseTests::test_direct_parent
test_graph.py::FindMergeBaseTests::test_direct_parent
self =
def test_direct_parent(self):
# parent
graph = {
"G": ["D", "F"],
"F": ["E"],
"D": ["C"],
"C": ["B"],
"E": ["B"],
"B": ["A"],
"A": [],
}
> self.assertEqual(self.run_test(graph, ["G", "D"]), {"D"})
tests/test_graph.py:91:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dag = {'A': [], 'B': ['A'], 'C': ['B'], 'D': ['C'], ...}, inputs = ['G', 'D']
@staticmethod
def run_test(dag, inputs):
def lookup_parents(commit_id):
return dag[commit_id]
def lookup_stamp(commit_id):
# any constant timestamp value here will work to force
# this test to test the same behaviour as done previously
return 100
c1 = inputs[0]
c2s = inputs[1:]
> return set(_find_lcas(lookup_parents, c1, c2s, lookup_stamp))
E TypeError: _find_lcas() takes 2 positional arguments but 4 were given
tests/test_graph.py:42: TypeError
test_graph.py::FindMergeBaseTests::test_multiple_lca
test_graph.py::FindMergeBaseTests::test_multiple_lca
self =
def test_multiple_lca(self):
# two lowest common ancestors
graph = {
"5": ["1", "2"],
"4": ["3", "1"],
"3": ["2"],
"2": ["0"],
"1": [],
"0": [],
}
> self.assertEqual(self.run_test(graph, ["4", "5"]), {"1", "2"})
tests/test_graph.py:54:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dag = {'0': [], '1': [], '2': ['0'], '3': ['2'], ...}, inputs = ['4', '5']
@staticmethod
def run_test(dag, inputs):
def lookup_parents(commit_id):
return dag[commit_id]
def lookup_stamp(commit_id):
# any constant timestamp value here will work to force
# this test to test the same behaviour as done previously
return 100
c1 = inputs[0]
c2s = inputs[1:]
> return set(_find_lcas(lookup_parents, c1, c2s, lookup_stamp))
E TypeError: _find_lcas() takes 2 positional arguments but 4 were given
tests/test_graph.py:42: TypeError
test_graph.py::FindMergeBaseTests::test_no_common_ancestor
test_graph.py::FindMergeBaseTests::test_no_common_ancestor
self =
def test_no_common_ancestor(self):
# no common ancestor
graph = {
"4": ["2"],
"3": ["1"],
"2": [],
"1": ["0"],
"0": [],
}
> self.assertEqual(self.run_test(graph, ["4", "3"]), set())
tests/test_graph.py:65:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dag = {'0': [], '1': ['0'], '2': [], '3': ['1'], ...}, inputs = ['4', '3']
@staticmethod
def run_test(dag, inputs):
def lookup_parents(commit_id):
return dag[commit_id]
def lookup_stamp(commit_id):
# any constant timestamp value here will work to force
# this test to test the same behaviour as done previously
return 100
c1 = inputs[0]
c2s = inputs[1:]
> return set(_find_lcas(lookup_parents, c1, c2s, lookup_stamp))
E TypeError: _find_lcas() takes 2 positional arguments but 4 were given
tests/test_graph.py:42: TypeError
test_graph.py::FindMergeBaseTests::test_octopus
test_graph.py::FindMergeBaseTests::test_octopus
self =
def test_octopus(self):
# octopus algorithm test
# test straight from git docs of A, B, and C
# but this time use octopus to find lcas of A, B, and C simultaneously
graph = {
"C": ["C1"],
"C1": ["C2"],
"C2": ["C3"],
"C3": ["C4"],
"C4": ["2"],
"B": ["B1"],
"B1": ["B2"],
"B2": ["B3"],
"B3": ["1"],
"A": ["A1"],
"A1": ["A2"],
"A2": ["A3"],
"A3": ["1"],
"1": ["2"],
"2": [],
}
def lookup_parents(cid):
return graph[cid]
def lookup_stamp(commit_id):
# any constant timestamp value here will work to force
# this test to test the same behaviour as done previously
return 100
lcas = ["A"]
others = ["B", "C"]
for cmt in others:
next_lcas = []
for ca in lcas:
> res = _find_lcas(lookup_parents, cmt, [ca], lookup_stamp)
E TypeError: _find_lcas() takes 2 positional arguments but 4 were given
tests/test_graph.py:164: TypeError
test_graph.py::FindMergeBaseTests::test_three_way_merge_lca
test_graph.py::FindMergeBaseTests::test_three_way_merge_lca
self =
def test_three_way_merge_lca(self):
# three way merge commit straight from git docs
graph = {
"C": ["C1"],
"C1": ["C2"],
"C2": ["C3"],
"C3": ["C4"],
"C4": ["2"],
"B": ["B1"],
"B1": ["B2"],
"B2": ["B3"],
"B3": ["1"],
"A": ["A1"],
"A1": ["A2"],
"A2": ["A3"],
"A3": ["1"],
"1": ["2"],
"2": [],
}
# assumes a theoretical merge M exists that merges B and C first
# which actually means find the first LCA from either of B OR C with A
> self.assertEqual(self.run_test(graph, ["A", "B", "C"]), {"1"})
tests/test_graph.py:127:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dag = {'1': ['2'], '2': [], 'A': ['A1'], 'A1': ['A2'], ...}
inputs = ['A', 'B', 'C']
@staticmethod
def run_test(dag, inputs):
def lookup_parents(commit_id):
return dag[commit_id]
def lookup_stamp(commit_id):
# any constant timestamp value here will work to force
# this test to test the same behaviour as done previously
return 100
c1 = inputs[0]
c2s = inputs[1:]
> return set(_find_lcas(lookup_parents, c1, c2s, lookup_stamp))
E TypeError: _find_lcas() takes 2 positional arguments but 4 were given
tests/test_graph.py:42: TypeError
test_graph.py::CanFastForwardTests::test_diverged
test_graph.py::CanFastForwardTests::test_diverged
self =
def test_diverged(self):
> r = MemoryRepo()
tests/test_graph.py:183:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_graph.py::CanFastForwardTests::test_ff
test_graph.py::CanFastForwardTests::test_ff
self =
def test_ff(self):
> r = MemoryRepo()
tests/test_graph.py:172:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_graph.py::WorkListTest::test_WorkList
test_graph.py::WorkListTest::test_WorkList
self =
def test_WorkList(self):
# tuples of (timestamp, value) are stored in a Priority MaxQueue
# repeated use of get should return them in maxheap timestamp
# order: largest time value (most recent in time) first then earlier/older
wlst = WorkList()
> wlst.add((100, "Test Value 1"))
E AttributeError: 'WorkList' object has no attribute 'add'
tests/test_graph.py:201: AttributeError
test_greenthreads.py::TestGreenThreadsMissingObjectFinder::test_finder
test_greenthreads.py::TestGreenThreadsMissingObjectFinder::test_finder
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
self.cmt_amount = 10
> self.objs = init_store(self.store, self.cmt_amount)
tests/test_greenthreads.py:73:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_greenthreads.py:60: in init_store
objs = create_commit(marker=("%d" % i).encode("ascii"))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
marker = b'0'
def create_commit(marker=None):
blob = Blob.from_string(b"The blob content " + marker)
tree = Tree()
> tree.add(b"thefile " + marker, 0o100644, blob.id)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_greenthreads.py:46: AttributeError
test_hooks.py::ShellHookTests::test_hook_commit_msg
test_hooks.py::ShellHookTests::test_hook_commit_msg
self =
def test_hook_commit_msg(self):
repo_dir = os.path.join(tempfile.mkdtemp())
os.mkdir(os.path.join(repo_dir, "hooks"))
self.addCleanup(shutil.rmtree, repo_dir)
commit_msg_fail = """#!/bin/sh
exit 1
"""
commit_msg_success = """#!/bin/sh
exit 0
"""
commit_msg_cwd = (
"""#!/bin/sh
if [ "$(pwd)" = '"""
+ repo_dir
+ "' ]; then exit 0; else exit 1; fi\n"
)
commit_msg = os.path.join(repo_dir, "hooks", "commit-msg")
hook = CommitMsgShellHook(repo_dir)
with open(commit_msg, "w") as f:
f.write(commit_msg_fail)
os.chmod(commit_msg, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
> self.assertRaises(errors.HookError, hook.execute, b"failed commit")
E AssertionError: HookError not raised by execute
tests/test_hooks.py:119: AssertionError
test_hooks.py::ShellHookTests::test_hook_post_commit
test_hooks.py::ShellHookTests::test_hook_post_commit
self =
def test_hook_post_commit(self):
(fd, path) = tempfile.mkstemp()
os.close(fd)
repo_dir = os.path.join(tempfile.mkdtemp())
os.mkdir(os.path.join(repo_dir, "hooks"))
self.addCleanup(shutil.rmtree, repo_dir)
post_commit_success = (
"""#!/bin/sh
rm """
+ path
+ "\n"
)
post_commit_fail = """#!/bin/sh
exit 1
"""
post_commit_cwd = (
"""#!/bin/sh
if [ "$(pwd)" = '"""
+ repo_dir
+ "' ]; then exit 0; else exit 1; fi\n"
)
post_commit = os.path.join(repo_dir, "hooks", "post-commit")
hook = PostCommitShellHook(repo_dir)
with open(post_commit, "w") as f:
f.write(post_commit_fail)
os.chmod(post_commit, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
> self.assertRaises(errors.HookError, hook.execute)
E AssertionError: HookError not raised by execute
tests/test_hooks.py:169: AssertionError
test_hooks.py::ShellHookTests::test_hook_pre_commit
test_hooks.py::ShellHookTests::test_hook_pre_commit
self =
def test_hook_pre_commit(self):
repo_dir = os.path.join(tempfile.mkdtemp())
os.mkdir(os.path.join(repo_dir, "hooks"))
self.addCleanup(shutil.rmtree, repo_dir)
pre_commit_fail = """#!/bin/sh
exit 1
"""
pre_commit_success = """#!/bin/sh
exit 0
"""
pre_commit_cwd = (
"""#!/bin/sh
if [ "$(pwd)" != '"""
+ repo_dir
+ """' ]; then
echo "Expected path '"""
+ repo_dir
+ """', got '$(pwd)'"
exit 1
fi
exit 0
"""
)
pre_commit = os.path.join(repo_dir, "hooks", "pre-commit")
hook = PreCommitShellHook(repo_dir, repo_dir)
with open(pre_commit, "w") as f:
f.write(pre_commit_fail)
os.chmod(pre_commit, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
> self.assertRaises(errors.HookError, hook.execute)
E AssertionError: HookError not raised by execute
tests/test_hooks.py:75: AssertionError
test_ignore.py::TranslateTests::test_translate
test_ignore.py::TranslateTests::test_translate
self =
def test_translate(self):
for pattern, regex in TRANSLATE_TESTS:
if re.escape(b"/") == b"/":
# Slash is no longer escaped in Python3.7, so undo the escaping
# in the expected return value..
regex = regex.replace(b"\\/", b"/")
> self.assertEqual(
regex,
translate(pattern),
f"orig pattern: {pattern!r}, regex: {translate(pattern)!r}, expected: {regex!r}",
)
E AssertionError: b'(?ms)(.*/)?[^/]*\\.c/?\\Z' != None : orig pattern: b'*.c', regex: None, expected: b'(?ms)(.*/)?[^/]*\\.c/?\\Z'
tests/test_ignore.py:98: AssertionError
test_ignore.py::ReadIgnorePatterns::test_read_file
test_ignore.py::ReadIgnorePatterns::test_read_file
self =
def test_read_file(self):
f = BytesIO(
b"""
# a comment
\x20\x20
# and an empty line:
\\#not a comment
!negative
with trailing whitespace
with escaped trailing whitespace\\
"""
)
self.assertEqual(
> list(read_ignore_patterns(f)),
[
b"\\#not a comment",
b"!negative",
b"with trailing whitespace",
b"with escaped trailing whitespace ",
],
)
E TypeError: 'NoneType' object is not iterable
tests/test_ignore.py:120: TypeError
test_ignore.py::MatchPatternTests::test_matches
test_ignore.py::MatchPatternTests::test_matches
self =
def test_matches(self):
for path, pattern in POSITIVE_MATCH_TESTS:
> self.assertTrue(
match_pattern(path, pattern),
f"path: {path!r}, pattern: {pattern!r}",
)
E AssertionError: None is not true : path: b'foo.c', pattern: b'*.c'
tests/test_ignore.py:133: AssertionError
test_ignore.py::IgnoreFilterTests::test_excluded
test_ignore.py::IgnoreFilterTests::test_excluded
self =
def test_excluded(self):
filter = IgnoreFilter([b"a.c", b"b.c", b"!c.c"])
self.assertFalse(filter.is_ignored(b"c.c"))
self.assertIs(None, filter.is_ignored(b"d.c"))
> self.assertEqual([Pattern(b"!c.c")], list(filter.find_matching(b"c.c")))
tests/test_ignore.py:167:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dulwich/ignore.py:60: in __init__
self._re = re.compile(translate(pattern), flags)
/usr/lib/python3.10/re.py:251: in compile
return _compile(pattern, flags)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pattern = None, flags = 0
def _compile(pattern, flags):
# internal: compile pattern
if isinstance(flags, RegexFlag):
flags = flags.value
try:
return _cache[type(pattern), pattern, flags]
except KeyError:
pass
if isinstance(pattern, Pattern):
if flags:
raise ValueError(
"cannot process flags argument with a compiled pattern")
return pattern
if not sre_compile.isstring(pattern):
> raise TypeError("first argument must be string or compiled pattern")
E TypeError: first argument must be string or compiled pattern
/usr/lib/python3.10/re.py:302: TypeError
test_ignore.py::IgnoreFilterTests::test_include_exclude_include
test_ignore.py::IgnoreFilterTests::test_include_exclude_include
self =
def test_include_exclude_include(self):
filter = IgnoreFilter([b"a.c", b"!a.c", b"a.c"])
> self.assertTrue(filter.is_ignored(b"a.c"))
E AssertionError: None is not true
tests/test_ignore.py:172: AssertionError
test_ignore.py::IgnoreFilterTests::test_included
test_ignore.py::IgnoreFilterTests::test_included
self =
def test_included(self):
filter = IgnoreFilter([b"a.c", b"b.c"])
> self.assertTrue(filter.is_ignored(b"a.c"))
E AssertionError: None is not true
tests/test_ignore.py:149: AssertionError
test_ignore.py::IgnoreFilterTests::test_included_ignorecase
test_ignore.py::IgnoreFilterTests::test_included_ignorecase
self =
def test_included_ignorecase(self):
filter = IgnoreFilter([b"a.c", b"b.c"], ignorecase=False)
> self.assertTrue(filter.is_ignored(b"a.c"))
E AssertionError: None is not true
tests/test_ignore.py:156: AssertionError
test_ignore.py::IgnoreFilterTests::test_manpage
test_ignore.py::IgnoreFilterTests::test_manpage
self =
def test_manpage(self):
# A specific example from the gitignore manpage
filter = IgnoreFilter([b"/*", b"!/foo", b"/foo/*", b"!/foo/bar"])
> self.assertTrue(filter.is_ignored(b"a.c"))
E AssertionError: None is not true
tests/test_ignore.py:181: AssertionError
test_ignore.py::IgnoreFilterTests::test_regex_special
test_ignore.py::IgnoreFilterTests::test_regex_special
self =
def test_regex_special(self):
# See https://github.com/dulwich/dulwich/issues/930#issuecomment-1026166429
filter = IgnoreFilter([b"/foo\\[bar\\]", b"/foo"])
> self.assertTrue(filter.is_ignored("foo"))
E AssertionError: None is not true
tests/test_ignore.py:191: AssertionError
test_ignore.py::IgnoreFilterStackTests::test_stack_first
test_ignore.py::IgnoreFilterStackTests::test_stack_first
self =
def test_stack_first(self):
filter1 = IgnoreFilter([b"[a].c", b"[b].c", b"![d].c"])
filter2 = IgnoreFilter([b"[a].c", b"![b],c", b"[c].c", b"[d].c"])
stack = IgnoreFilterStack([filter1, filter2])
> self.assertIs(True, stack.is_ignored(b"a.c"))
E AssertionError: True is not None
tests/test_ignore.py:200: AssertionError
test_ignore.py::IgnoreFilterManagerTests::test_ignored_contents
test_ignore.py::IgnoreFilterManagerTests::test_ignored_contents
self =
def test_ignored_contents(self):
tmp_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp_dir)
repo = Repo.init(tmp_dir)
> with open(os.path.join(repo.path, ".gitignore"), "wb") as f:
E AttributeError: 'NoneType' object has no attribute 'path'
tests/test_ignore.py:272: AttributeError
test_ignore.py::IgnoreFilterManagerTests::test_load_ignore
test_ignore.py::IgnoreFilterManagerTests::test_load_ignore
self =
def test_load_ignore(self):
tmp_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp_dir)
repo = Repo.init(tmp_dir)
> with open(os.path.join(repo.path, ".gitignore"), "wb") as f:
E AttributeError: 'NoneType' object has no attribute 'path'
tests/test_ignore.py:212: AttributeError
test_ignore.py::IgnoreFilterManagerTests::test_load_ignore_ignorecase
test_ignore.py::IgnoreFilterManagerTests::test_load_ignore_ignorecase
self =
def test_load_ignore_ignorecase(self):
tmp_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp_dir)
repo = Repo.init(tmp_dir)
> config = repo.get_config()
E AttributeError: 'NoneType' object has no attribute 'get_config'
tests/test_ignore.py:258: AttributeError
test_ignore.py::IgnoreFilterManagerTests::test_nested_gitignores
test_ignore.py::IgnoreFilterManagerTests::test_nested_gitignores
self =
def test_nested_gitignores(self):
tmp_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp_dir)
repo = Repo.init(tmp_dir)
> with open(os.path.join(repo.path, ".gitignore"), "wb") as f:
E AttributeError: 'NoneType' object has no attribute 'path'
tests/test_ignore.py:240: AttributeError
test_index.py::SimpleIndexTestCase::test_against_empty_tree
test_index.py::SimpleIndexTestCase::test_against_empty_tree
self =
def test_against_empty_tree(self):
i = self.get_simple_index("index")
> changes = list(i.changes_from_tree(MemoryObjectStore(), None))
E TypeError: 'NoneType' object is not iterable
tests/test_index.py:115: TypeError
test_index.py::SimpleIndexTestCase::test_empty
test_index.py::SimpleIndexTestCase::test_empty
self =
def test_empty(self):
i = self.get_simple_index("notanindex")
> self.assertEqual(0, len(i))
tests/test_index.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Index('/testbed/tests/../testdata/indexes/notanindex')
def __len__(self) -> int:
"""Number of entries in this index file."""
> return len(self._byname)
E AttributeError: 'Index' object has no attribute '_byname'
dulwich/index.py:198: AttributeError
test_index.py::SimpleIndexTestCase::test_getitem
test_index.py::SimpleIndexTestCase::test_getitem
self =
def test_getitem(self):
self.assertEqual(
IndexEntry(
(1230680220, 0),
(1230680220, 0),
2050,
3761020,
33188,
1000,
1000,
0,
b"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
),
> self.get_simple_index("index")[b"bla"],
)
tests/test_index.py:105:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Index('/testbed/tests/../testdata/indexes/index'), key = b'bla'
def __getitem__(self, key: bytes) -> Union[IndexEntry, ConflictedIndexEntry]:
"""Retrieve entry by relative path and stage.
Returns: Either a IndexEntry or a ConflictedIndexEntry
Raises KeyError: if the entry does not exist
"""
> return self._byname[key]
E AttributeError: 'Index' object has no attribute '_byname'
dulwich/index.py:206: AttributeError
test_index.py::SimpleIndexTestCase::test_iter
test_index.py::SimpleIndexTestCase::test_iter
self =
def test_iter(self):
> self.assertEqual([b"bla"], list(self.get_simple_index("index")))
tests/test_index.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Index('/testbed/tests/../testdata/indexes/index')
def __iter__(self) -> Iterator[bytes]:
"""Iterate over the paths and stages in this index."""
> return iter(self._byname)
E AttributeError: 'Index' object has no attribute '_byname'
dulwich/index.py:210: AttributeError
test_index.py::SimpleIndexTestCase::test_iterobjects
test_index.py::SimpleIndexTestCase::test_iterobjects
self =
def test_iterobjects(self):
self.assertEqual(
[(b"bla", b"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", 33188)],
> list(self.get_simple_index("index").iterobjects()),
)
E TypeError: 'NoneType' object is not iterable
tests/test_index.py:89: TypeError
test_index.py::SimpleIndexTestCase::test_len
test_index.py::SimpleIndexTestCase::test_len
self =
def test_len(self):
> self.assertEqual(1, len(self.get_simple_index("index")))
tests/test_index.py:81:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Index('/testbed/tests/../testdata/indexes/index')
def __len__(self) -> int:
"""Number of entries in this index file."""
> return len(self._byname)
E AttributeError: 'Index' object has no attribute '_byname'
dulwich/index.py:198: AttributeError
test_index.py::SimpleIndexWriterTestCase::test_simple_write
test_index.py::SimpleIndexWriterTestCase::test_simple_write
self =
def test_simple_write(self):
entries = [
(
SerializedIndexEntry(
b"barbla",
(1230680220, 0),
(1230680220, 0),
2050,
3761020,
33188,
1000,
1000,
0,
b"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
0,
0,
)
)
]
filename = os.path.join(self.tempdir, "test-simple-write-index")
with open(filename, "wb+") as x:
write_index(x, entries)
with open(filename, "rb") as x:
> self.assertEqual(entries, list(read_index(x)))
E TypeError: 'NoneType' object is not iterable
tests/test_index.py:155: TypeError
test_index.py::ReadIndexDictTests::test_simple_write
test_index.py::ReadIndexDictTests::test_simple_write
self =
def test_simple_write(self):
entries = {
b"barbla": IndexEntry(
(1230680220, 0),
(1230680220, 0),
2050,
3761020,
33188,
1000,
1000,
0,
b"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
)
}
filename = os.path.join(self.tempdir, "test-simple-write-index")
with open(filename, "wb+") as x:
write_index_dict(x, entries)
with open(filename, "rb") as x:
> self.assertEqual(entries, read_index_dict(x))
E AssertionError: {b'barbla': IndexEntry(ctime=(1230680220,[135 chars]91')} != None
tests/test_index.py:186: AssertionError
test_index.py::CommitTreeTests::test_nested
test_index.py::CommitTreeTests::test_nested
self =
def test_nested(self):
blob = Blob()
blob.data = b"foo"
self.store.add_object(blob)
blobs = [(b"bla/bar", blob.id, stat.S_IFREG)]
rootid = commit_tree(self.store, blobs)
> self.assertEqual(rootid, b"d92b959b216ad0d044671981196781b3258fa537")
E AssertionError: None != b'd92b959b216ad0d044671981196781b3258fa537'
tests/test_index.py:210: AssertionError
test_index.py::CommitTreeTests::test_single_blob
test_index.py::CommitTreeTests::test_single_blob
self =
def test_single_blob(self):
blob = Blob()
blob.data = b"foo"
self.store.add_object(blob)
blobs = [(b"bla", blob.id, stat.S_IFREG)]
rootid = commit_tree(self.store, blobs)
> self.assertEqual(rootid, b"1a1e80437220f9312e855c37ac4398b68e5c1d50")
E AssertionError: None != b'1a1e80437220f9312e855c37ac4398b68e5c1d50'
tests/test_index.py:200: AssertionError
test_index.py::CleanupModeTests::test_dir
test_index.py::CleanupModeTests::test_dir
self =
def test_dir(self):
> self.assertModeEqual(0o040000, cleanup_mode(0o40531))
tests/test_index.py:233:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , expected = 16384
got = None
def assertModeEqual(self, expected, got):
> self.assertEqual(expected, got, f"{expected:o} != {got:o}")
E TypeError: unsupported format string passed to NoneType.__format__
tests/test_index.py:220: TypeError
test_index.py::CleanupModeTests::test_executable
test_index.py::CleanupModeTests::test_executable
self =
def test_executable(self):
> self.assertModeEqual(0o100755, cleanup_mode(0o100711))
tests/test_index.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
expected = 33261, got = None
def assertModeEqual(self, expected, got):
> self.assertEqual(expected, got, f"{expected:o} != {got:o}")
E TypeError: unsupported format string passed to NoneType.__format__
tests/test_index.py:220: TypeError
test_index.py::CleanupModeTests::test_file
test_index.py::CleanupModeTests::test_file
self =
def test_file(self):
> self.assertModeEqual(0o100644, cleanup_mode(0o100000))
tests/test_index.py:223:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
expected = 33188, got = None
def assertModeEqual(self, expected, got):
> self.assertEqual(expected, got, f"{expected:o} != {got:o}")
E TypeError: unsupported format string passed to NoneType.__format__
tests/test_index.py:220: TypeError
test_index.py::CleanupModeTests::test_submodule
test_index.py::CleanupModeTests::test_submodule
self =
def test_submodule(self):
> self.assertModeEqual(0o160000, cleanup_mode(0o160744))
tests/test_index.py:236:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
expected = 57344, got = None
def assertModeEqual(self, expected, got):
> self.assertEqual(expected, got, f"{expected:o} != {got:o}")
E TypeError: unsupported format string passed to NoneType.__format__
tests/test_index.py:220: TypeError
test_index.py::CleanupModeTests::test_symlink
test_index.py::CleanupModeTests::test_symlink
self =
def test_symlink(self):
> self.assertModeEqual(0o120000, cleanup_mode(0o120711))
tests/test_index.py:230:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
expected = 40960, got = None
def assertModeEqual(self, expected, got):
> self.assertEqual(expected, got, f"{expected:o} != {got:o}")
E TypeError: unsupported format string passed to NoneType.__format__
tests/test_index.py:220: TypeError
test_index.py::WriteCacheTimeTests::test_write_float
test_index.py::WriteCacheTimeTests::test_write_float
self =
def test_write_float(self):
f = BytesIO()
write_cache_time(f, 434343.000000021)
> self.assertEqual(struct.pack(">LL", 434343, 21), f.getvalue())
E AssertionError: b'\x00\x06\xa0\xa7\x00\x00\x00\x15' != b''
tests/test_index.py:257: AssertionError
test_index.py::WriteCacheTimeTests::test_write_int
test_index.py::WriteCacheTimeTests::test_write_int
self =
def test_write_int(self):
f = BytesIO()
write_cache_time(f, 434343)
> self.assertEqual(struct.pack(">LL", 434343, 0), f.getvalue())
E AssertionError: b'\x00\x06\xa0\xa7\x00\x00\x00\x00' != b''
tests/test_index.py:247: AssertionError
test_index.py::WriteCacheTimeTests::test_write_string
test_index.py::WriteCacheTimeTests::test_write_string
self =
def test_write_string(self):
f = BytesIO()
> self.assertRaises(TypeError, write_cache_time, f, "foo")
E AssertionError: TypeError not raised by write_cache_time
tests/test_index.py:242: AssertionError
test_index.py::WriteCacheTimeTests::test_write_tuple
test_index.py::WriteCacheTimeTests::test_write_tuple
self =
def test_write_tuple(self):
f = BytesIO()
write_cache_time(f, (434343, 21))
> self.assertEqual(struct.pack(">LL", 434343, 21), f.getvalue())
E AssertionError: b'\x00\x06\xa0\xa7\x00\x00\x00\x15' != b''
tests/test_index.py:252: AssertionError
test_index.py::IndexEntryFromStatTests::test_override_mode
test_index.py::IndexEntryFromStatTests::test_override_mode
self =
def test_override_mode(self):
st = os.stat_result(
(
stat.S_IFREG + 0o644,
131078,
64769,
154,
1000,
1000,
12288,
1323629595,
1324180496,
1324180496,
)
)
entry = index_entry_from_stat(st, b"22" * 20, mode=stat.S_IFREG + 0o755)
> self.assertEqual(
entry,
IndexEntry(
1324180496,
1324180496,
64769,
131078,
33261,
1000,
1000,
12288,
b"2222222222222222222222222222222222222222",
),
)
E AssertionError: None != IndexEntry(ctime=1324180496, mtime=132418[116 chars]222')
tests/test_index.py:308: AssertionError
test_index.py::IndexEntryFromStatTests::test_simple
test_index.py::IndexEntryFromStatTests::test_simple
self =
def test_simple(self):
st = os.stat_result(
(
16877,
131078,
64769,
154,
1000,
1000,
12288,
1323629595,
1324180496,
1324180496,
)
)
entry = index_entry_from_stat(st, b"22" * 20)
> self.assertEqual(
entry,
IndexEntry(
1324180496,
1324180496,
64769,
131078,
16384,
1000,
1000,
12288,
b"2222222222222222222222222222222222222222",
),
)
E AssertionError: None != IndexEntry(ctime=1324180496, mtime=132418[116 chars]222')
tests/test_index.py:277: AssertionError
test_index.py::BuildIndexTests::test_empty
test_index.py::BuildIndexTests::test_empty
self =
def test_empty(self):
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:340: AttributeError
test_index.py::BuildIndexTests::test_git_dir
test_index.py::BuildIndexTests::test_git_dir
self =
def test_git_dir(self):
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:358: AttributeError
test_index.py::BuildIndexTests::test_git_submodule
test_index.py::BuildIndexTests::test_git_submodule
self =
def test_git_submodule(self):
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:563: AttributeError
test_index.py::BuildIndexTests::test_git_submodule_exists
test_index.py::BuildIndexTests::test_git_submodule_exists
self =
def test_git_submodule_exists(self):
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:603: AttributeError
test_index.py::BuildIndexTests::test_no_decode_encode
test_index.py::BuildIndexTests::test_no_decode_encode
self =
def test_no_decode_encode(self):
repo_dir = tempfile.mkdtemp()
repo_dir_bytes = os.fsencode(repo_dir)
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:522: AttributeError
test_index.py::BuildIndexTests::test_nonempty
test_index.py::BuildIndexTests::test_nonempty
self =
def test_nonempty(self):
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:392: AttributeError
test_index.py::BuildIndexTests::test_norewrite
test_index.py::BuildIndexTests::test_norewrite
self =
@skipIf(not getattr(os, "sync", None), "Requires sync support")
def test_norewrite(self):
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:447: AttributeError
test_index.py::BuildIndexTests::test_symlink
test_index.py::BuildIndexTests::test_symlink
self =
@skipIf(not can_symlink(), "Requires symlink support")
def test_symlink(self):
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:489: AttributeError
test_index.py::GetUnstagedChangesTests::test_get_unstaged_changes
test_index.py::GetUnstagedChangesTests::test_get_unstaged_changes
self =
def test_get_unstaged_changes(self):
"""Unit test for get_unstaged_changes."""
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:647: AttributeError
test_index.py::GetUnstagedChangesTests::test_get_unstaged_changes_removed_replaced_by_directory
test_index.py::GetUnstagedChangesTests::test_get_unstaged_changes_removed_replaced_by_directory
self =
def test_get_unstaged_changes_removed_replaced_by_directory(self):
"""Unit test for get_unstaged_changes."""
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:701: AttributeError
test_index.py::GetUnstagedChangesTests::test_get_unstaged_changes_removed_replaced_by_link
test_index.py::GetUnstagedChangesTests::test_get_unstaged_changes_removed_replaced_by_link
self =
@skipIf(not can_symlink(), "Requires symlink support")
def test_get_unstaged_changes_removed_replaced_by_link(self):
"""Unit test for get_unstaged_changes."""
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:726: AttributeError
test_index.py::GetUnstagedChangesTests::test_get_unstaged_deleted_changes
test_index.py::GetUnstagedChangesTests::test_get_unstaged_deleted_changes
self =
def test_get_unstaged_deleted_changes(self):
"""Unit test for get_unstaged_changes."""
repo_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, repo_dir)
> with Repo.init(repo_dir) as repo:
E AttributeError: __enter__
tests/test_index.py:678: AttributeError
test_index.py::TestValidatePathElement::test_default
test_index.py::TestValidatePathElement::test_default
self =
def test_default(self):
self.assertTrue(validate_path_element_default(b"bla"))
self.assertTrue(validate_path_element_default(b".bla"))
self.assertFalse(validate_path_element_default(b".git"))
> self.assertFalse(validate_path_element_default(b".giT"))
E AssertionError: True is not false
tests/test_index.py:752: AssertionError
test_index.py::TestValidatePathElement::test_ntfs
test_index.py::TestValidatePathElement::test_ntfs
self =
def test_ntfs(self):
self.assertTrue(validate_path_element_ntfs(b"bla"))
self.assertTrue(validate_path_element_ntfs(b".bla"))
self.assertFalse(validate_path_element_ntfs(b".git"))
> self.assertFalse(validate_path_element_ntfs(b".giT"))
E AssertionError: True is not false
tests/test_index.py:760: AssertionError
test_index.py::TestTreeFSPathConversion::test_fs_to_tree_path_bytes
test_index.py::TestTreeFSPathConversion::test_fs_to_tree_path_bytes
self =
def test_fs_to_tree_path_bytes(self):
fs_path = os.path.join(os.fsencode(os.path.join("délwÃçh", "foo")))
tree_path = _fs_to_tree_path(fs_path)
> self.assertEqual(tree_path, "délwÃçh/foo".encode())
E AssertionError: None != b'd\xc3\xa9lw\xc3\xad\xc3\xa7h/foo'
tests/test_index.py:782: AssertionError
test_index.py::TestTreeFSPathConversion::test_fs_to_tree_path_str
test_index.py::TestTreeFSPathConversion::test_fs_to_tree_path_str
self =
def test_fs_to_tree_path_str(self):
fs_path = os.path.join(os.path.join("délwÃçh", "foo"))
tree_path = _fs_to_tree_path(fs_path)
> self.assertEqual(tree_path, "délwÃçh/foo".encode())
E AssertionError: None != b'd\xc3\xa9lw\xc3\xad\xc3\xa7h/foo'
tests/test_index.py:777: AssertionError
test_index.py::TestTreeFSPathConversion::test_tree_to_fs_path
test_index.py::TestTreeFSPathConversion::test_tree_to_fs_path
self =
def test_tree_to_fs_path(self):
tree_path = "délwÃçh/foo".encode()
fs_path = _tree_to_fs_path(b"/prefix/path", tree_path)
> self.assertEqual(
fs_path,
os.fsencode(os.path.join("/prefix/path", "délwÃçh", "foo")),
)
E AssertionError: None != b'/prefix/path/d\xc3\xa9lw\xc3\xad\xc3\xa7h/foo'
tests/test_index.py:769: AssertionError
test_lfs.py::LFSTests::test_create
test_lfs.py::LFSTests::test_create
self =
def setUp(self):
super().setUp()
self.test_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.test_dir)
> self.lfs = LFSStore.create(self.test_dir)
E AttributeError: type object 'LFSStore' has no attribute 'create'
tests/test_lfs.py:36: AttributeError
test_lfs.py::LFSTests::test_missing
test_lfs.py::LFSTests::test_missing
self =
def setUp(self):
super().setUp()
self.test_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.test_dir)
> self.lfs = LFSStore.create(self.test_dir)
E AttributeError: type object 'LFSStore' has no attribute 'create'
tests/test_lfs.py:36: AttributeError
test_line_ending.py::LineEndingConversion::test_convert_crlf_to_lf
test_line_ending.py::LineEndingConversion::test_convert_crlf_to_lf
self =
def test_convert_crlf_to_lf(self):
> self.assertEqual(convert_crlf_to_lf(b"line1\r\nline2"), b"line1\nline2")
E AssertionError: None != b'line1\nline2'
tests/test_line_ending.py:42: AssertionError
test_line_ending.py::LineEndingConversion::test_convert_crlf_to_lf_mixed
test_line_ending.py::LineEndingConversion::test_convert_crlf_to_lf_mixed
self =
def test_convert_crlf_to_lf_mixed(self):
> self.assertEqual(convert_crlf_to_lf(b"line1\r\n\nline2"), b"line1\n\nline2")
E AssertionError: None != b'line1\n\nline2'
tests/test_line_ending.py:45: AssertionError
test_line_ending.py::LineEndingConversion::test_convert_crlf_to_lf_no_op
test_line_ending.py::LineEndingConversion::test_convert_crlf_to_lf_no_op
self =
def test_convert_crlf_to_lf_no_op(self):
> self.assertEqual(convert_crlf_to_lf(b"foobar"), b"foobar")
E AssertionError: None != b'foobar'
tests/test_line_ending.py:39: AssertionError
test_line_ending.py::LineEndingConversion::test_convert_lf_to_crlf
test_line_ending.py::LineEndingConversion::test_convert_lf_to_crlf
self =
def test_convert_lf_to_crlf(self):
> self.assertEqual(convert_lf_to_crlf(b"line1\nline2"), b"line1\r\nline2")
E AssertionError: None != b'line1\r\nline2'
tests/test_line_ending.py:51: AssertionError
test_line_ending.py::LineEndingConversion::test_convert_lf_to_crlf_mixed
test_line_ending.py::LineEndingConversion::test_convert_lf_to_crlf_mixed
self =
def test_convert_lf_to_crlf_mixed(self):
> self.assertEqual(convert_lf_to_crlf(b"line1\r\n\nline2"), b"line1\r\n\r\nline2")
E AssertionError: None != b'line1\r\n\r\nline2'
tests/test_line_ending.py:54: AssertionError
test_line_ending.py::LineEndingConversion::test_convert_lf_to_crlf_no_op
test_line_ending.py::LineEndingConversion::test_convert_lf_to_crlf_no_op
self =
def test_convert_lf_to_crlf_no_op(self):
> self.assertEqual(convert_lf_to_crlf(b"foobar"), b"foobar")
E AssertionError: None != b'foobar'
tests/test_line_ending.py:48: AssertionError
test_line_ending.py::GetLineEndingAutocrlfFilters::test_get_checkin_filter_autocrlf_input
self =
def test_get_checkin_filter_autocrlf_input(self):
checkin_filter = get_checkin_filter_autocrlf(b"input")
> self.assertEqual(checkin_filter, convert_crlf_to_lf)
E AssertionError: None !=
tests/test_line_ending.py:71: AssertionError
test_line_ending.py::GetLineEndingAutocrlfFilters::test_get_checkin_filter_autocrlf_true
test_line_ending.py::GetLineEndingAutocrlfFilters::test_get_checkin_filter_autocrlf_true
self =
def test_get_checkin_filter_autocrlf_true(self):
checkin_filter = get_checkin_filter_autocrlf(b"true")
> self.assertEqual(checkin_filter, convert_crlf_to_lf)
E AssertionError: None !=
tests/test_line_ending.py:66: AssertionError
test_line_ending.py::GetLineEndingAutocrlfFilters::test_get_checkout_filter_autocrlf_true
test_line_ending.py::GetLineEndingAutocrlfFilters::test_get_checkout_filter_autocrlf_true
self =
def test_get_checkout_filter_autocrlf_true(self):
checkout_filter = get_checkout_filter_autocrlf(b"true")
> self.assertEqual(checkout_filter, convert_lf_to_crlf)
E AssertionError: None !=
tests/test_line_ending.py:81: AssertionError
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_crlf
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_crlf
self =
def test_normalize_to_crlf(self):
base_content = b"line1\nline2"
base_sha = "f8be7bb828880727816015d21abcbc37d033f233"
base_blob = Blob()
base_blob.set_raw_string(base_content)
> self.assertEqual(base_blob.as_raw_chunks(), [base_content])
E AssertionError: None != [b'line1\nline2']
tests/test_line_ending.py:168: AssertionError
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_crlf_binary
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_crlf_binary
self =
def test_normalize_to_crlf_binary(self):
base_content = b"line1\r\nline2\0"
base_sha = "b44504193b765f7cd79673812de8afb55b372ab2"
base_blob = Blob()
base_blob.set_raw_string(base_content)
> self.assertEqual(base_blob.as_raw_chunks(), [base_content])
E AssertionError: None != [b'line1\r\nline2\x00']
tests/test_line_ending.py:188: AssertionError
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_crlf_no_op
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_crlf_no_op
self =
def test_normalize_to_crlf_no_op(self):
base_content = b"line1\r\nline2"
base_sha = "3a1bd7a52799fe5cf6411f1d35f4c10bacb1db96"
base_blob = Blob()
base_blob.set_raw_string(base_content)
> self.assertEqual(base_blob.as_raw_chunks(), [base_content])
E AssertionError: None != [b'line1\r\nline2']
tests/test_line_ending.py:151: AssertionError
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_lf
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_lf
self =
def test_normalize_to_lf(self):
base_content = b"line1\r\nline2"
base_sha = "3a1bd7a52799fe5cf6411f1d35f4c10bacb1db96"
base_blob = Blob()
base_blob.set_raw_string(base_content)
> self.assertEqual(base_blob.as_raw_chunks(), [base_content])
E AssertionError: None != [b'line1\r\nline2']
tests/test_line_ending.py:114: AssertionError
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_lf_binary
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_lf_binary
self =
def test_normalize_to_lf_binary(self):
base_content = b"line1\r\nline2\0"
base_sha = "b44504193b765f7cd79673812de8afb55b372ab2"
base_blob = Blob()
base_blob.set_raw_string(base_content)
> self.assertEqual(base_blob.as_raw_chunks(), [base_content])
E AssertionError: None != [b'line1\r\nline2\x00']
tests/test_line_ending.py:134: AssertionError
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_lf_no_op
test_line_ending.py::NormalizeBlobTestCase::test_normalize_to_lf_no_op
self =
def test_normalize_to_lf_no_op(self):
base_content = b"line1\nline2"
base_sha = "f8be7bb828880727816015d21abcbc37d033f233"
base_blob = Blob()
base_blob.set_raw_string(base_content)
> self.assertEqual(base_blob.as_raw_chunks(), [base_content])
E AssertionError: None != [b'line1\nline2']
tests/test_line_ending.py:97: AssertionError
test_lru_cache.py::TestLRUCache::test_add__null_key
test_lru_cache.py::TestLRUCache::test_add__null_key
self =
def test_add__null_key(self):
> cache = lru_cache.LRUCache(max_cache=10)
tests/test_lru_cache.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 10
after_cleanup_count = None
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_after_cleanup_larger_than_max
test_lru_cache.py::TestLRUCache::test_after_cleanup_larger_than_max
self =
def test_after_cleanup_larger_than_max(self):
> cache = lru_cache.LRUCache(max_cache=5, after_cleanup_count=10)
tests/test_lru_cache.py:186:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 5
after_cleanup_count = 10
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_after_cleanup_none
test_lru_cache.py::TestLRUCache::test_after_cleanup_none
self =
def test_after_cleanup_none(self):
> cache = lru_cache.LRUCache(max_cache=5, after_cleanup_count=None)
tests/test_lru_cache.py:190:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 5
after_cleanup_count = None
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_by_usage
test_lru_cache.py::TestLRUCache::test_by_usage
self =
def test_by_usage(self):
"""Accessing entries bumps them up in priority."""
> cache = lru_cache.LRUCache(max_cache=2)
tests/test_lru_cache.py:87:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 2
after_cleanup_count = None
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_cache_size
test_lru_cache.py::TestLRUCache::test_cache_size
self =
def test_cache_size(self):
> cache = lru_cache.LRUCache(max_cache=10)
tests/test_lru_cache.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 10
after_cleanup_count = None
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_cleanup
test_lru_cache.py::TestLRUCache::test_cleanup
self =
def test_cleanup(self):
"""Test that we can use a cleanup function."""
cleanup_called = []
def cleanup_func(key, val):
cleanup_called.append((key, val))
> cache = lru_cache.LRUCache(max_cache=2, after_cleanup_count=2)
tests/test_lru_cache.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 2
after_cleanup_count = 2
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_cleanup_2
test_lru_cache.py::TestLRUCache::test_cleanup_2
self =
def test_cleanup_2(self):
> cache = lru_cache.LRUCache(max_cache=5, after_cleanup_count=2)
tests/test_lru_cache.py:195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 5
after_cleanup_count = 2
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_cleanup_on_replace
test_lru_cache.py::TestLRUCache::test_cleanup_on_replace
self =
def test_cleanup_on_replace(self):
"""Replacing an object should cleanup the old value."""
cleanup_called = []
def cleanup_func(key, val):
cleanup_called.append((key, val))
> cache = lru_cache.LRUCache(max_cache=2)
tests/test_lru_cache.py:126:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 2
after_cleanup_count = None
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_cleanup_shrinks_to_after_clean_count
test_lru_cache.py::TestLRUCache::test_cleanup_shrinks_to_after_clean_count
self =
def test_cleanup_shrinks_to_after_clean_count(self):
> cache = lru_cache.LRUCache(max_cache=5, after_cleanup_count=3)
tests/test_lru_cache.py:171:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 5
after_cleanup_count = 3
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_get
test_lru_cache.py::TestLRUCache::test_get
self =
def test_get(self):
> cache = lru_cache.LRUCache(max_cache=5)
tests/test_lru_cache.py:229:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 5
after_cleanup_count = None
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_keys
test_lru_cache.py::TestLRUCache::test_keys
self =
def test_keys(self):
> cache = lru_cache.LRUCache(max_cache=5, after_cleanup_count=5)
tests/test_lru_cache.py:242:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 5
after_cleanup_count = 5
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_len
test_lru_cache.py::TestLRUCache::test_len
self =
def test_len(self):
> cache = lru_cache.LRUCache(max_cache=10, after_cleanup_count=10)
tests/test_lru_cache.py:139:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 10
after_cleanup_count = 10
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_map_None
test_lru_cache.py::TestLRUCache::test_map_None
self =
def test_map_None(self):
# Make sure that we can properly map None as a key.
> cache = lru_cache.LRUCache(max_cache=10)
tests/test_lru_cache.py:53:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 10
after_cleanup_count = None
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_missing
test_lru_cache.py::TestLRUCache::test_missing
self =
def test_missing(self):
> cache = lru_cache.LRUCache(max_cache=10)
tests/test_lru_cache.py:41:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 10
after_cleanup_count = None
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_overflow
test_lru_cache.py::TestLRUCache::test_overflow
self =
def test_overflow(self):
"""Adding extra entries will pop out old ones."""
> cache = lru_cache.LRUCache(max_cache=1, after_cleanup_count=1)
tests/test_lru_cache.py:74:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 1
after_cleanup_count = 1
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_preserve_last_access_order
test_lru_cache.py::TestLRUCache::test_preserve_last_access_order
self =
def test_preserve_last_access_order(self):
> cache = lru_cache.LRUCache(max_cache=5)
tests/test_lru_cache.py:210:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 5
after_cleanup_count = None
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_resize_larger
test_lru_cache.py::TestLRUCache::test_resize_larger
self =
def test_resize_larger(self):
> cache = lru_cache.LRUCache(max_cache=5, after_cleanup_count=4)
tests/test_lru_cache.py:273:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 5
after_cleanup_count = 4
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUCache::test_resize_smaller
test_lru_cache.py::TestLRUCache::test_resize_smaller
self =
def test_resize_smaller(self):
> cache = lru_cache.LRUCache(max_cache=5, after_cleanup_count=4)
tests/test_lru_cache.py:254:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_cache = 5
after_cleanup_count = 4
def __init__(self, max_cache: int=100, after_cleanup_count: Optional[int]=None) -> None:
self._cache: Dict[K, _LRUNode[K, V]] = {}
self._most_recently_used = None
self._least_recently_used = None
> self._update_max_cache(max_cache, after_cleanup_count)
E AttributeError: 'LRUCache' object has no attribute '_update_max_cache'
dulwich/lru_cache.py:38: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_add__null_key
test_lru_cache.py::TestLRUSizeCache::test_add__null_key
self =
def test_add__null_key(self):
> cache = lru_cache.LRUSizeCache()
tests/test_lru_cache.py:301:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
max_size = 1048576, after_cleanup_size = None, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_add_tracks_size
test_lru_cache.py::TestLRUSizeCache::test_add_tracks_size
self =
def test_add_tracks_size(self):
> cache = lru_cache.LRUSizeCache()
tests/test_lru_cache.py:305:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
max_size = 1048576, after_cleanup_size = None, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_adding_clears_cache_based_on_size
test_lru_cache.py::TestLRUSizeCache::test_adding_clears_cache_based_on_size
self =
def test_adding_clears_cache_based_on_size(self):
"""The cache is cleared in LRU order until small enough."""
> cache = lru_cache.LRUSizeCache(max_size=20)
tests/test_lru_cache.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_size = 20
after_cleanup_size = None, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_adding_clears_to_after_cleanup_size
test_lru_cache.py::TestLRUSizeCache::test_adding_clears_to_after_cleanup_size
self =
def test_adding_clears_to_after_cleanup_size(self):
> cache = lru_cache.LRUSizeCache(max_size=20, after_cleanup_size=10)
tests/test_lru_cache.py:371:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_size = 20
after_cleanup_size = 10, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_basic_init
test_lru_cache.py::TestLRUSizeCache::test_basic_init
self =
def test_basic_init(self):
> cache = lru_cache.LRUSizeCache()
tests/test_lru_cache.py:295:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
max_size = 1048576, after_cleanup_size = None, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_cleanup
test_lru_cache.py::TestLRUSizeCache::test_cleanup
self =
def test_cleanup(self):
> cache = lru_cache.LRUSizeCache(max_size=20, after_cleanup_size=10)
tests/test_lru_cache.py:401:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_size = 20
after_cleanup_size = 10, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_custom_sizes
test_lru_cache.py::TestLRUSizeCache::test_custom_sizes
self =
def test_custom_sizes(self):
def size_of_list(lst):
return sum(len(x) for x in lst)
> cache = lru_cache.LRUSizeCache(
max_size=20, after_cleanup_size=10, compute_size=size_of_list
)
tests/test_lru_cache.py:386:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_size = 20
after_cleanup_size = 10
compute_size = .size_of_list at 0x7eec1ee88040>
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_keys
test_lru_cache.py::TestLRUSizeCache::test_keys
self =
def test_keys(self):
> cache = lru_cache.LRUSizeCache(max_size=10)
tests/test_lru_cache.py:414:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_size = 10
after_cleanup_size = None, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_no_add_over_size
test_lru_cache.py::TestLRUSizeCache::test_no_add_over_size
self =
def test_no_add_over_size(self):
"""Adding a large value may not be cached at all."""
> cache = lru_cache.LRUSizeCache(max_size=10, after_cleanup_size=5)
tests/test_lru_cache.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_size = 10
after_cleanup_size = 5, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_no_add_over_size_cleanup
test_lru_cache.py::TestLRUSizeCache::test_no_add_over_size_cleanup
self =
def test_no_add_over_size_cleanup(self):
"""If a large value is not cached, we will call cleanup right away."""
cleanup_calls = []
def cleanup(key, value):
cleanup_calls.append((key, value))
> cache = lru_cache.LRUSizeCache(max_size=10, after_cleanup_size=5)
tests/test_lru_cache.py:347:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_size = 10
after_cleanup_size = 5, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_remove_tracks_size
test_lru_cache.py::TestLRUSizeCache::test_remove_tracks_size
self =
def test_remove_tracks_size(self):
> cache = lru_cache.LRUSizeCache()
tests/test_lru_cache.py:311:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
max_size = 1048576, after_cleanup_size = None, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_resize_larger
test_lru_cache.py::TestLRUSizeCache::test_resize_larger
self =
def test_resize_larger(self):
> cache = lru_cache.LRUSizeCache(max_size=10, after_cleanup_size=9)
tests/test_lru_cache.py:439:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_size = 10
after_cleanup_size = 9, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_lru_cache.py::TestLRUSizeCache::test_resize_smaller
test_lru_cache.py::TestLRUSizeCache::test_resize_smaller
self =
def test_resize_smaller(self):
> cache = lru_cache.LRUSizeCache(max_size=10, after_cleanup_size=9)
tests/test_lru_cache.py:422:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , max_size = 10
after_cleanup_size = 9, compute_size = None
def __init__(self, max_size: int=1024 * 1024, after_cleanup_size: Optional[int]=None, compute_size: Optional[Callable[[V], int]]=None) -> None:
"""Create a new LRUSizeCache.
Args:
max_size: The max number of bytes to store before we start
clearing out entries.
after_cleanup_size: After cleaning up, shrink everything to this
size.
compute_size: A function to compute the size of the values. We
use a function here, so that you can pass 'len' if you are just
using simple strings, or a more complex function if you are using
something like a list of strings, or even a custom object.
The function should take the form "compute_size(value) => integer".
If not supplied, it defaults to 'len()'
"""
self._value_size = 0
if compute_size is None:
self._compute_size = len
else:
self._compute_size = compute_size
> self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)
E AttributeError: 'LRUSizeCache' object has no attribute '_update_max_size'
dulwich/lru_cache.py:168: AttributeError
test_mailmap.py::ReadMailmapTests::test_read
test_mailmap.py::ReadMailmapTests::test_read
self =
def test_read(self):
b = BytesIO(
b"""\
Jane Doe
Joe R. Developer
# A comment
# Comment
Some Dude nick1
Other Author nick2
Other Author
Santa Claus
"""
)
self.assertEqual(
[
((b"Jane Doe", b"jane@desktop.(none)"), None),
((b"Joe R. Developer", b"joe@example.com"), None),
((None, b"cto@company.xx"), (None, b"cto@coompany.xx")),
(
(b"Some Dude", b"some@dude.xx"),
(b"nick1", b"bugs@company.xx"),
),
(
(b"Other Author", b"other@author.xx"),
(b"nick2", b"bugs@company.xx"),
),
(
(b"Other Author", b"other@author.xx"),
(None, b"nick2@company.xx"),
),
(
(b"Santa Claus", b"santa.claus@northpole.xx"),
(None, b"me@company.xx"),
),
],
> list(read_mailmap(b)),
)
E TypeError: 'NoneType' object is not iterable
tests/test_mailmap.py:65: TypeError
test_mailmap.py::MailmapTests::test_lookup
test_mailmap.py::MailmapTests::test_lookup
self =
def test_lookup(self):
m = Mailmap()
m.add_entry((b"Jane Doe", b"jane@desktop.(none)"), (None, None))
m.add_entry((b"Joe R. Developer", b"joe@example.com"), None)
m.add_entry((None, b"cto@company.xx"), (None, b"cto@coompany.xx"))
m.add_entry((b"Some Dude", b"some@dude.xx"), (b"nick1", b"bugs@company.xx"))
m.add_entry(
(b"Other Author", b"other@author.xx"),
(b"nick2", b"bugs@company.xx"),
)
m.add_entry((b"Other Author", b"other@author.xx"), (None, b"nick2@company.xx"))
m.add_entry(
(b"Santa Claus", b"santa.claus@northpole.xx"),
(None, b"me@company.xx"),
)
> self.assertEqual(
b"Jane Doe ",
m.lookup(b"Jane Doe "),
)
E AssertionError: b'Jane Doe ' != None
tests/test_mailmap.py:85: AssertionError
test_missing_obj_finder.py::MOFLinearRepoTest::test_1_to_2
test_missing_obj_finder.py::MOFLinearRepoTest::test_1_to_2
self =
def setUp(self):
super().setUp()
# present in 1, removed in 3
f1_1 = make_object(Blob, data=b"f1")
# present in all revisions, changed in 2 and 3
f2_1 = make_object(Blob, data=b"f2")
f2_2 = make_object(Blob, data=b"f2-changed")
f2_3 = make_object(Blob, data=b"f2-changed-again")
# added in 2, left unmodified in 3
f3_2 = make_object(Blob, data=b"f3")
commit_spec = [[1], [2, 1], [3, 2]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_1), (b"f2", f2_2), (b"f3", f3_2)],
3: [(b"f2", f2_3), (b"f3", f3_2)],
}
# commit 1: f1 and f2
# commit 2: f3 added, f2 changed. Missing shall report commit id and a
# tree referenced by commit
# commit 3: f1 removed, f2 changed. Commit sha and root tree sha shall
# be reported as modified
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.missing_1_2 = [self.cmt(2).id, self.cmt(2).tree, f2_2.id, f3_2.id]
tests/test_missing_obj_finder.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 2
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_missing_obj_finder.py::MOFLinearRepoTest::test_1_to_3
test_missing_obj_finder.py::MOFLinearRepoTest::test_1_to_3
self =
def setUp(self):
super().setUp()
# present in 1, removed in 3
f1_1 = make_object(Blob, data=b"f1")
# present in all revisions, changed in 2 and 3
f2_1 = make_object(Blob, data=b"f2")
f2_2 = make_object(Blob, data=b"f2-changed")
f2_3 = make_object(Blob, data=b"f2-changed-again")
# added in 2, left unmodified in 3
f3_2 = make_object(Blob, data=b"f3")
commit_spec = [[1], [2, 1], [3, 2]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_1), (b"f2", f2_2), (b"f3", f3_2)],
3: [(b"f2", f2_3), (b"f3", f3_2)],
}
# commit 1: f1 and f2
# commit 2: f3 added, f2 changed. Missing shall report commit id and a
# tree referenced by commit
# commit 3: f1 removed, f2 changed. Commit sha and root tree sha shall
# be reported as modified
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.missing_1_2 = [self.cmt(2).id, self.cmt(2).tree, f2_2.id, f3_2.id]
tests/test_missing_obj_finder.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 2
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_missing_obj_finder.py::MOFLinearRepoTest::test_2_to_3
test_missing_obj_finder.py::MOFLinearRepoTest::test_2_to_3
self =
def setUp(self):
super().setUp()
# present in 1, removed in 3
f1_1 = make_object(Blob, data=b"f1")
# present in all revisions, changed in 2 and 3
f2_1 = make_object(Blob, data=b"f2")
f2_2 = make_object(Blob, data=b"f2-changed")
f2_3 = make_object(Blob, data=b"f2-changed-again")
# added in 2, left unmodified in 3
f3_2 = make_object(Blob, data=b"f3")
commit_spec = [[1], [2, 1], [3, 2]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_1), (b"f2", f2_2), (b"f3", f3_2)],
3: [(b"f2", f2_3), (b"f3", f3_2)],
}
# commit 1: f1 and f2
# commit 2: f3 added, f2 changed. Missing shall report commit id and a
# tree referenced by commit
# commit 3: f1 removed, f2 changed. Commit sha and root tree sha shall
# be reported as modified
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.missing_1_2 = [self.cmt(2).id, self.cmt(2).tree, f2_2.id, f3_2.id]
tests/test_missing_obj_finder.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 2
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_missing_obj_finder.py::MOFLinearRepoTest::test_bogus_haves
test_missing_obj_finder.py::MOFLinearRepoTest::test_bogus_haves
self =
def setUp(self):
super().setUp()
# present in 1, removed in 3
f1_1 = make_object(Blob, data=b"f1")
# present in all revisions, changed in 2 and 3
f2_1 = make_object(Blob, data=b"f2")
f2_2 = make_object(Blob, data=b"f2-changed")
f2_3 = make_object(Blob, data=b"f2-changed-again")
# added in 2, left unmodified in 3
f3_2 = make_object(Blob, data=b"f3")
commit_spec = [[1], [2, 1], [3, 2]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_1), (b"f2", f2_2), (b"f3", f3_2)],
3: [(b"f2", f2_3), (b"f3", f3_2)],
}
# commit 1: f1 and f2
# commit 2: f3 added, f2 changed. Missing shall report commit id and a
# tree referenced by commit
# commit 3: f1 removed, f2 changed. Commit sha and root tree sha shall
# be reported as modified
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.missing_1_2 = [self.cmt(2).id, self.cmt(2).tree, f2_2.id, f3_2.id]
tests/test_missing_obj_finder.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 2
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_missing_obj_finder.py::MOFLinearRepoTest::test_bogus_wants_failure
test_missing_obj_finder.py::MOFLinearRepoTest::test_bogus_wants_failure
self =
def setUp(self):
super().setUp()
# present in 1, removed in 3
f1_1 = make_object(Blob, data=b"f1")
# present in all revisions, changed in 2 and 3
f2_1 = make_object(Blob, data=b"f2")
f2_2 = make_object(Blob, data=b"f2-changed")
f2_3 = make_object(Blob, data=b"f2-changed-again")
# added in 2, left unmodified in 3
f3_2 = make_object(Blob, data=b"f3")
commit_spec = [[1], [2, 1], [3, 2]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_1), (b"f2", f2_2), (b"f3", f3_2)],
3: [(b"f2", f2_3), (b"f3", f3_2)],
}
# commit 1: f1 and f2
# commit 2: f3 added, f2 changed. Missing shall report commit id and a
# tree referenced by commit
# commit 3: f1 removed, f2 changed. Commit sha and root tree sha shall
# be reported as modified
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.missing_1_2 = [self.cmt(2).id, self.cmt(2).tree, f2_2.id, f3_2.id]
tests/test_missing_obj_finder.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 2
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_missing_obj_finder.py::MOFLinearRepoTest::test_no_changes
test_missing_obj_finder.py::MOFLinearRepoTest::test_no_changes
self =
def setUp(self):
super().setUp()
# present in 1, removed in 3
f1_1 = make_object(Blob, data=b"f1")
# present in all revisions, changed in 2 and 3
f2_1 = make_object(Blob, data=b"f2")
f2_2 = make_object(Blob, data=b"f2-changed")
f2_3 = make_object(Blob, data=b"f2-changed-again")
# added in 2, left unmodified in 3
f3_2 = make_object(Blob, data=b"f3")
commit_spec = [[1], [2, 1], [3, 2]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_1), (b"f2", f2_2), (b"f3", f3_2)],
3: [(b"f2", f2_3), (b"f3", f3_2)],
}
# commit 1: f1 and f2
# commit 2: f3 added, f2 changed. Missing shall report commit id and a
# tree referenced by commit
# commit 3: f1 removed, f2 changed. Commit sha and root tree sha shall
# be reported as modified
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.missing_1_2 = [self.cmt(2).id, self.cmt(2).tree, f2_2.id, f3_2.id]
tests/test_missing_obj_finder.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 2
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_missing_obj_finder.py::MOFMergeForkRepoTest::test_have1_want6
test_missing_obj_finder.py::MOFMergeForkRepoTest::test_have1_want6
self =
def setUp(self):
super().setUp()
f1_1 = make_object(Blob, data=b"f1")
f1_2 = make_object(Blob, data=b"f1-2")
f1_4 = make_object(Blob, data=b"f1-4")
f1_7 = make_object(Blob, data=b"f1-2") # same data as in rev 2
f2_1 = make_object(Blob, data=b"f2")
f2_3 = make_object(Blob, data=b"f2-3")
f3_3 = make_object(Blob, data=b"f3")
f3_5 = make_object(Blob, data=b"f3-5")
commit_spec = [[1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3, 4], [7, 6]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_2), (b"f2", f2_1)], # f1 changed
# f3 added, f2 changed
3: [(b"f1", f1_2), (b"f2", f2_3), (b"f3", f3_3)],
4: [(b"f1", f1_4), (b"f2", f2_1)], # f1 changed
5: [(b"f1", f1_2), (b"f3", f3_5)], # f2 removed, f3 changed
# merged 3 and 4
6: [(b"f1", f1_4), (b"f2", f2_3), (b"f3", f3_3)],
# f1 changed to match rev2. f3 removed
7: [(b"f1", f1_7), (b"f2", f2_3)],
}
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.f1_2_id = f1_2.id
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_missing_obj_finder.py:148: AttributeError
test_missing_obj_finder.py::MOFMergeForkRepoTest::test_have3_want6
test_missing_obj_finder.py::MOFMergeForkRepoTest::test_have3_want6
self =
def setUp(self):
super().setUp()
f1_1 = make_object(Blob, data=b"f1")
f1_2 = make_object(Blob, data=b"f1-2")
f1_4 = make_object(Blob, data=b"f1-4")
f1_7 = make_object(Blob, data=b"f1-2") # same data as in rev 2
f2_1 = make_object(Blob, data=b"f2")
f2_3 = make_object(Blob, data=b"f2-3")
f3_3 = make_object(Blob, data=b"f3")
f3_5 = make_object(Blob, data=b"f3-5")
commit_spec = [[1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3, 4], [7, 6]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_2), (b"f2", f2_1)], # f1 changed
# f3 added, f2 changed
3: [(b"f1", f1_2), (b"f2", f2_3), (b"f3", f3_3)],
4: [(b"f1", f1_4), (b"f2", f2_1)], # f1 changed
5: [(b"f1", f1_2), (b"f3", f3_5)], # f2 removed, f3 changed
# merged 3 and 4
6: [(b"f1", f1_4), (b"f2", f2_3), (b"f3", f3_3)],
# f1 changed to match rev2. f3 removed
7: [(b"f1", f1_7), (b"f2", f2_3)],
}
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.f1_2_id = f1_2.id
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_missing_obj_finder.py:148: AttributeError
test_missing_obj_finder.py::MOFMergeForkRepoTest::test_have4_want7
test_missing_obj_finder.py::MOFMergeForkRepoTest::test_have4_want7
self =
def setUp(self):
super().setUp()
f1_1 = make_object(Blob, data=b"f1")
f1_2 = make_object(Blob, data=b"f1-2")
f1_4 = make_object(Blob, data=b"f1-4")
f1_7 = make_object(Blob, data=b"f1-2") # same data as in rev 2
f2_1 = make_object(Blob, data=b"f2")
f2_3 = make_object(Blob, data=b"f2-3")
f3_3 = make_object(Blob, data=b"f3")
f3_5 = make_object(Blob, data=b"f3-5")
commit_spec = [[1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3, 4], [7, 6]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_2), (b"f2", f2_1)], # f1 changed
# f3 added, f2 changed
3: [(b"f1", f1_2), (b"f2", f2_3), (b"f3", f3_3)],
4: [(b"f1", f1_4), (b"f2", f2_1)], # f1 changed
5: [(b"f1", f1_2), (b"f3", f3_5)], # f2 removed, f3 changed
# merged 3 and 4
6: [(b"f1", f1_4), (b"f2", f2_3), (b"f3", f3_3)],
# f1 changed to match rev2. f3 removed
7: [(b"f1", f1_7), (b"f2", f2_3)],
}
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.f1_2_id = f1_2.id
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_missing_obj_finder.py:148: AttributeError
test_missing_obj_finder.py::MOFMergeForkRepoTest::test_have5_want7
test_missing_obj_finder.py::MOFMergeForkRepoTest::test_have5_want7
self =
def setUp(self):
super().setUp()
f1_1 = make_object(Blob, data=b"f1")
f1_2 = make_object(Blob, data=b"f1-2")
f1_4 = make_object(Blob, data=b"f1-4")
f1_7 = make_object(Blob, data=b"f1-2") # same data as in rev 2
f2_1 = make_object(Blob, data=b"f2")
f2_3 = make_object(Blob, data=b"f2-3")
f3_3 = make_object(Blob, data=b"f3")
f3_5 = make_object(Blob, data=b"f3-5")
commit_spec = [[1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3, 4], [7, 6]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_2), (b"f2", f2_1)], # f1 changed
# f3 added, f2 changed
3: [(b"f1", f1_2), (b"f2", f2_3), (b"f3", f3_3)],
4: [(b"f1", f1_4), (b"f2", f2_1)], # f1 changed
5: [(b"f1", f1_2), (b"f3", f3_5)], # f2 removed, f3 changed
# merged 3 and 4
6: [(b"f1", f1_4), (b"f2", f2_3), (b"f3", f3_3)],
# f1 changed to match rev2. f3 removed
7: [(b"f1", f1_7), (b"f2", f2_3)],
}
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.f1_2_id = f1_2.id
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_missing_obj_finder.py:148: AttributeError
test_missing_obj_finder.py::MOFMergeForkRepoTest::test_have6_want7
test_missing_obj_finder.py::MOFMergeForkRepoTest::test_have6_want7
self =
def setUp(self):
super().setUp()
f1_1 = make_object(Blob, data=b"f1")
f1_2 = make_object(Blob, data=b"f1-2")
f1_4 = make_object(Blob, data=b"f1-4")
f1_7 = make_object(Blob, data=b"f1-2") # same data as in rev 2
f2_1 = make_object(Blob, data=b"f2")
f2_3 = make_object(Blob, data=b"f2-3")
f3_3 = make_object(Blob, data=b"f3")
f3_5 = make_object(Blob, data=b"f3-5")
commit_spec = [[1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3, 4], [7, 6]]
trees = {
1: [(b"f1", f1_1), (b"f2", f2_1)],
2: [(b"f1", f1_2), (b"f2", f2_1)], # f1 changed
# f3 added, f2 changed
3: [(b"f1", f1_2), (b"f2", f2_3), (b"f3", f3_3)],
4: [(b"f1", f1_4), (b"f2", f2_1)], # f1 changed
5: [(b"f1", f1_2), (b"f3", f3_5)], # f2 removed, f3 changed
# merged 3 and 4
6: [(b"f1", f1_4), (b"f2", f2_3), (b"f3", f3_3)],
# f1 changed to match rev2. f3 removed
7: [(b"f1", f1_7), (b"f2", f2_3)],
}
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self.f1_2_id = f1_2.id
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_missing_obj_finder.py:148: AttributeError
test_missing_obj_finder.py::MOFTagsTest::test_tagged_blob
self =
def setUp(self):
super().setUp()
f1_1 = make_object(Blob, data=b"f1")
commit_spec = [[1]]
trees = {1: [(b"f1", f1_1)]}
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self._normal_tag = make_tag(self.cmt(1))
tests/test_missing_obj_finder.py:256:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 1
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_missing_obj_finder.py::MOFTagsTest::test_tagged_commit
self =
def setUp(self):
super().setUp()
f1_1 = make_object(Blob, data=b"f1")
commit_spec = [[1]]
trees = {1: [(b"f1", f1_1)]}
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self._normal_tag = make_tag(self.cmt(1))
tests/test_missing_obj_finder.py:256:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 1
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_missing_obj_finder.py::MOFTagsTest::test_tagged_tag
self =
def setUp(self):
super().setUp()
f1_1 = make_object(Blob, data=b"f1")
commit_spec = [[1]]
trees = {1: [(b"f1", f1_1)]}
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self._normal_tag = make_tag(self.cmt(1))
tests/test_missing_obj_finder.py:256:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 1
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_missing_obj_finder.py::MOFTagsTest::test_tagged_tagged_blob
self =
def setUp(self):
super().setUp()
f1_1 = make_object(Blob, data=b"f1")
commit_spec = [[1]]
trees = {1: [(b"f1", f1_1)]}
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self._normal_tag = make_tag(self.cmt(1))
tests/test_missing_obj_finder.py:256:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 1
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_missing_obj_finder.py::MOFTagsTest::test_tagged_tree
self =
def setUp(self):
super().setUp()
f1_1 = make_object(Blob, data=b"f1")
commit_spec = [[1]]
trees = {1: [(b"f1", f1_1)]}
self.commits = build_commit_graph(self.store, commit_spec, trees)
> self._normal_tag = make_tag(self.cmt(1))
tests/test_missing_obj_finder.py:256:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 1
def cmt(self, n):
> return self.commits[n - 1]
E TypeError: 'NoneType' object is not subscriptable
tests/test_missing_obj_finder.py:35: TypeError
test_object_store.py::MemoryObjectStoreTests::test_add_pack
test_object_store.py::MemoryObjectStoreTests::test_add_pack
self =
def test_add_pack(self):
o = MemoryObjectStore()
> f, commit, abort = o.add_pack()
E TypeError: cannot unpack non-iterable NoneType object
tests/test_object_store.py:74: TypeError
test_object_store.py::MemoryObjectStoreTests::test_add_pack_emtpy
test_object_store.py::MemoryObjectStoreTests::test_add_pack_emtpy
self =
def test_add_pack_emtpy(self):
o = MemoryObjectStore()
> f, commit, abort = o.add_pack()
E TypeError: cannot unpack non-iterable NoneType object
tests/test_object_store.py:86: TypeError
test_object_store.py::MemoryObjectStoreTests::test_add_thin_pack
test_object_store.py::MemoryObjectStoreTests::test_add_thin_pack
self =
def test_add_thin_pack(self):
o = MemoryObjectStore()
blob = make_object(Blob, data=b"yummy data")
o.add_object(blob)
f = BytesIO()
entries = build_pack(
f,
[
> (REF_DELTA, (blob.id, b"more yummy data")),
],
store=o,
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_object_store.py:98: AttributeError
test_object_store.py::MemoryObjectStoreTests::test_add_thin_pack_empty
test_object_store.py::MemoryObjectStoreTests::test_add_thin_pack_empty
self =
def test_add_thin_pack_empty(self):
o = MemoryObjectStore()
f = BytesIO()
entries = build_pack(f, [], store=o)
> self.assertEqual([], entries)
E AssertionError: [] != None
tests/test_object_store.py:113: AssertionError
test_object_store.py::DiskObjectStoreTests::test_add_alternate_path
test_object_store.py::DiskObjectStoreTests::test_add_alternate_path
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_add_pack
test_object_store.py::DiskObjectStoreTests::test_add_pack
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_add_thin_pack
test_object_store.py::DiskObjectStoreTests::test_add_thin_pack
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_add_thin_pack_empty
test_object_store.py::DiskObjectStoreTests::test_add_thin_pack_empty
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_alternates
test_object_store.py::DiskObjectStoreTests::test_alternates
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_corrupted_object_raise_exception
test_object_store.py::DiskObjectStoreTests::test_corrupted_object_raise_exception
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_file_modes
test_object_store.py::DiskObjectStoreTests::test_file_modes
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_loose_compression_level
test_object_store.py::DiskObjectStoreTests::test_loose_compression_level
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_pack_dir
test_object_store.py::DiskObjectStoreTests::test_pack_dir
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_read_alternate_paths
test_object_store.py::DiskObjectStoreTests::test_read_alternate_paths
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_rel_alternative_path
test_object_store.py::DiskObjectStoreTests::test_rel_alternative_path
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_store_resilience
test_object_store.py::DiskObjectStoreTests::test_store_resilience
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::DiskObjectStoreTests::test_tempfile_in_loose_store
test_object_store.py::DiskObjectStoreTests::test_tempfile_in_loose_store
self =
def setUp(self):
TestCase.setUp(self)
self.store_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.store_dir)
> self.store = DiskObjectStore.init(self.store_dir)
E AttributeError: type object 'DiskObjectStore' has no attribute 'init'
tests/test_object_store.py:122: AttributeError
test_object_store.py::TreeLookupPathTests::test_lookup_blob
test_object_store.py::TreeLookupPathTests::test_lookup_blob
self =
def setUp(self):
TestCase.setUp(self)
self.store = MemoryObjectStore()
blob_a = make_object(Blob, data=b"a")
blob_b = make_object(Blob, data=b"b")
blob_c = make_object(Blob, data=b"c")
for blob in [blob_a, blob_b, blob_c]:
self.store.add_object(blob)
blobs = [
> (b"a", blob_a.id, 0o100644),
(b"ad/b", blob_b.id, 0o100644),
(b"ad/bd/c", blob_c.id, 0o100755),
(b"ad/c", blob_c.id, 0o100644),
(b"c", blob_c.id, 0o100644),
(b"d", blob_c.id, S_IFGITLINK),
]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_object_store.py:306: AttributeError
test_object_store.py::TreeLookupPathTests::test_lookup_nonexistent
test_object_store.py::TreeLookupPathTests::test_lookup_nonexistent
self =
def setUp(self):
TestCase.setUp(self)
self.store = MemoryObjectStore()
blob_a = make_object(Blob, data=b"a")
blob_b = make_object(Blob, data=b"b")
blob_c = make_object(Blob, data=b"c")
for blob in [blob_a, blob_b, blob_c]:
self.store.add_object(blob)
blobs = [
> (b"a", blob_a.id, 0o100644),
(b"ad/b", blob_b.id, 0o100644),
(b"ad/bd/c", blob_c.id, 0o100755),
(b"ad/c", blob_c.id, 0o100644),
(b"c", blob_c.id, 0o100644),
(b"d", blob_c.id, S_IFGITLINK),
]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_object_store.py:306: AttributeError
test_object_store.py::TreeLookupPathTests::test_lookup_not_tree
test_object_store.py::TreeLookupPathTests::test_lookup_not_tree
self =
def setUp(self):
TestCase.setUp(self)
self.store = MemoryObjectStore()
blob_a = make_object(Blob, data=b"a")
blob_b = make_object(Blob, data=b"b")
blob_c = make_object(Blob, data=b"c")
for blob in [blob_a, blob_b, blob_c]:
self.store.add_object(blob)
blobs = [
> (b"a", blob_a.id, 0o100644),
(b"ad/b", blob_b.id, 0o100644),
(b"ad/bd/c", blob_c.id, 0o100755),
(b"ad/c", blob_c.id, 0o100644),
(b"c", blob_c.id, 0o100644),
(b"d", blob_c.id, S_IFGITLINK),
]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_object_store.py:306: AttributeError
test_object_store.py::TreeLookupPathTests::test_lookup_submodule
test_object_store.py::TreeLookupPathTests::test_lookup_submodule
self =
def setUp(self):
TestCase.setUp(self)
self.store = MemoryObjectStore()
blob_a = make_object(Blob, data=b"a")
blob_b = make_object(Blob, data=b"b")
blob_c = make_object(Blob, data=b"c")
for blob in [blob_a, blob_b, blob_c]:
self.store.add_object(blob)
blobs = [
> (b"a", blob_a.id, 0o100644),
(b"ad/b", blob_b.id, 0o100644),
(b"ad/bd/c", blob_c.id, 0o100755),
(b"ad/c", blob_c.id, 0o100644),
(b"c", blob_c.id, 0o100644),
(b"d", blob_c.id, S_IFGITLINK),
]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_object_store.py:306: AttributeError
test_object_store.py::TreeLookupPathTests::test_lookup_tree
test_object_store.py::TreeLookupPathTests::test_lookup_tree
self =
def setUp(self):
TestCase.setUp(self)
self.store = MemoryObjectStore()
blob_a = make_object(Blob, data=b"a")
blob_b = make_object(Blob, data=b"b")
blob_c = make_object(Blob, data=b"c")
for blob in [blob_a, blob_b, blob_c]:
self.store.add_object(blob)
blobs = [
> (b"a", blob_a.id, 0o100644),
(b"ad/b", blob_b.id, 0o100644),
(b"ad/bd/c", blob_c.id, 0o100755),
(b"ad/c", blob_c.id, 0o100644),
(b"c", blob_c.id, 0o100644),
(b"d", blob_c.id, S_IFGITLINK),
]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_object_store.py:306: AttributeError
test_object_store.py::ObjectStoreGraphWalkerTests::test_ack_invalid_value
test_object_store.py::ObjectStoreGraphWalkerTests::test_ack_invalid_value
self =
def test_ack_invalid_value(self):
gw = self.get_walker([], {})
> self.assertRaises(ValueError, gw.ack, "tooshort")
E AssertionError: ValueError not raised by ack
tests/test_object_store.py:366: AssertionError
test_object_store.py::ObjectStoreGraphWalkerTests::test_child_ack_later
test_object_store.py::ObjectStoreGraphWalkerTests::test_child_ack_later
self =
def test_child_ack_later(self):
gw = self.get_walker([b"a"], {b"a": [b"b"], b"b": [b"c"], b"c": []})
> self.assertEqual(b"a" * 40, next(gw))
E AssertionError: b'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' != None
tests/test_object_store.py:392: AssertionError
test_object_store.py::ObjectStoreGraphWalkerTests::test_descends
test_object_store.py::ObjectStoreGraphWalkerTests::test_descends
self =
def test_descends(self):
gw = self.get_walker([b"a"], {b"a": [b"b"], b"b": []})
> self.assertEqual(b"a" * 40, next(gw))
E AssertionError: b'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' != None
tests/test_object_store.py:376: AssertionError
test_object_store.py::ObjectStoreGraphWalkerTests::test_only_once
test_object_store.py::ObjectStoreGraphWalkerTests::test_only_once
self =
def test_only_once(self):
# a b
# | |
# c d
# \ /
# e
gw = self.get_walker(
[b"a", b"b"],
{
b"a": [b"c"],
b"b": [b"d"],
b"c": [b"e"],
b"d": [b"e"],
b"e": [],
},
)
walk = []
acked = False
walk.append(next(gw))
walk.append(next(gw))
# A branch (a, c) or (b, d) may be done after 2 steps or 3 depending on
# the order walked: 3-step walks include (a, b, c) and (b, a, d), etc.
if walk == [b"a" * 40, b"c" * 40] or walk == [b"b" * 40, b"d" * 40]:
gw.ack(walk[0])
acked = True
walk.append(next(gw))
if not acked and walk[2] == b"c" * 40:
gw.ack(b"a" * 40)
elif not acked and walk[2] == b"d" * 40:
gw.ack(b"b" * 40)
walk.append(next(gw))
self.assertIs(None, next(gw))
> self.assertEqual([b"a" * 40, b"b" * 40, b"c" * 40, b"d" * 40], sorted(walk))
E TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'
tests/test_object_store.py:431: TypeError
test_object_store.py::ObjectStoreGraphWalkerTests::test_parent_present
test_object_store.py::ObjectStoreGraphWalkerTests::test_parent_present
self =
def test_parent_present(self):
gw = self.get_walker([b"a"], {b"a": [b"b"], b"b": []})
> self.assertEqual(b"a" * 40, next(gw))
E AssertionError: b'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' != None
tests/test_object_store.py:386: AssertionError
test_object_store.py::CommitTreeChangesTests::test_add_blob
test_object_store.py::CommitTreeChangesTests::test_add_blob
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
self.blob_a = make_object(Blob, data=b"a")
self.blob_b = make_object(Blob, data=b"b")
self.blob_c = make_object(Blob, data=b"c")
for blob in [self.blob_a, self.blob_b, self.blob_c]:
self.store.add_object(blob)
blobs = [
> (b"a", self.blob_a.id, 0o100644),
(b"ad/b", self.blob_b.id, 0o100644),
(b"ad/bd/c", self.blob_c.id, 0o100755),
(b"ad/c", self.blob_c.id, 0o100644),
(b"c", self.blob_c.id, 0o100644),
]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_object_store.py:447: AttributeError
test_object_store.py::CommitTreeChangesTests::test_add_blob_in_dir
test_object_store.py::CommitTreeChangesTests::test_add_blob_in_dir
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
self.blob_a = make_object(Blob, data=b"a")
self.blob_b = make_object(Blob, data=b"b")
self.blob_c = make_object(Blob, data=b"c")
for blob in [self.blob_a, self.blob_b, self.blob_c]:
self.store.add_object(blob)
blobs = [
> (b"a", self.blob_a.id, 0o100644),
(b"ad/b", self.blob_b.id, 0o100644),
(b"ad/bd/c", self.blob_c.id, 0o100755),
(b"ad/c", self.blob_c.id, 0o100644),
(b"c", self.blob_c.id, 0o100644),
]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_object_store.py:447: AttributeError
test_object_store.py::CommitTreeChangesTests::test_delete_blob
test_object_store.py::CommitTreeChangesTests::test_delete_blob
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
self.blob_a = make_object(Blob, data=b"a")
self.blob_b = make_object(Blob, data=b"b")
self.blob_c = make_object(Blob, data=b"c")
for blob in [self.blob_a, self.blob_b, self.blob_c]:
self.store.add_object(blob)
blobs = [
> (b"a", self.blob_a.id, 0o100644),
(b"ad/b", self.blob_b.id, 0o100644),
(b"ad/bd/c", self.blob_c.id, 0o100755),
(b"ad/c", self.blob_c.id, 0o100644),
(b"c", self.blob_c.id, 0o100644),
]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_object_store.py:447: AttributeError
test_object_store.py::CommitTreeChangesTests::test_no_changes
test_object_store.py::CommitTreeChangesTests::test_no_changes
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
self.blob_a = make_object(Blob, data=b"a")
self.blob_b = make_object(Blob, data=b"b")
self.blob_c = make_object(Blob, data=b"c")
for blob in [self.blob_a, self.blob_b, self.blob_c]:
self.store.add_object(blob)
blobs = [
> (b"a", self.blob_a.id, 0o100644),
(b"ad/b", self.blob_b.id, 0o100644),
(b"ad/bd/c", self.blob_c.id, 0o100755),
(b"ad/c", self.blob_c.id, 0o100644),
(b"c", self.blob_c.id, 0o100644),
]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_object_store.py:447: AttributeError
test_object_store.py::TestReadPacksFile::test_read_packs
test_object_store.py::TestReadPacksFile::test_read_packs
self =
def test_read_packs(self):
self.assertEqual(
["pack-1.pack"],
> list(
read_packs_file(
BytesIO(
b"""P pack-1.pack
"""
)
)
),
)
E TypeError: 'NoneType' object is not iterable
tests/test_object_store.py:525: TypeError
test_objects.py::BlobReadTests::test_chunks
test_objects.py::BlobReadTests::test_chunks
self =
def test_chunks(self):
string = b"test 5\n"
b = Blob.from_string(string)
> self.assertEqual([string], b.chunked)
E AttributeError: 'NoneType' object has no attribute 'chunked'
tests/test_objects.py:136: AttributeError
test_objects.py::BlobReadTests::test_create_blob_from_string
test_objects.py::BlobReadTests::test_create_blob_from_string
self =
def test_create_blob_from_string(self):
string = b"test 2\n"
b = Blob.from_string(string)
> self.assertEqual(b.data, string)
E AttributeError: 'NoneType' object has no attribute 'data'
tests/test_objects.py:118: AttributeError
test_objects.py::BlobReadTests::test_decompress_simple_blob
test_objects.py::BlobReadTests::test_decompress_simple_blob
self =
def test_decompress_simple_blob(self):
> b = self.get_blob(a_sha)
tests/test_objects.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:88: in get_blob
return self.get_sha_file(Blob, "blobs", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/blobs', b'6f')
hasstr = True, hasbytes = True, s = b'6f'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_eq
test_objects.py::BlobReadTests::test_eq
self =
def test_eq(self):
> blob1 = self.get_blob(a_sha)
tests/test_objects.py:169:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:88: in get_blob
return self.get_sha_file(Blob, "blobs", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/blobs', b'6f')
hasstr = True, hasbytes = True, s = b'6f'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_hash
test_objects.py::BlobReadTests::test_hash
self =
def test_hash(self):
> b = self.get_blob(a_sha)
tests/test_objects.py:105:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:88: in get_blob
return self.get_sha_file(Blob, "blobs", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/blobs', b'6f')
hasstr = True, hasbytes = True, s = b'6f'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_legacy_from_file
test_objects.py::BlobReadTests::test_legacy_from_file
self =
def test_legacy_from_file(self):
b1 = Blob.from_string(b"foo")
> b_raw = b1.as_legacy_object()
E AttributeError: 'NoneType' object has no attribute 'as_legacy_object'
tests/test_objects.py:123: AttributeError
test_objects.py::BlobReadTests::test_legacy_from_file_compression_level
test_objects.py::BlobReadTests::test_legacy_from_file_compression_level
self =
def test_legacy_from_file_compression_level(self):
b1 = Blob.from_string(b"foo")
> b_raw = b1.as_legacy_object(compression_level=6)
E AttributeError: 'NoneType' object has no attribute 'as_legacy_object'
tests/test_objects.py:129: AttributeError
test_objects.py::BlobReadTests::test_parse_empty_blob_object
test_objects.py::BlobReadTests::test_parse_empty_blob_object
self =
def test_parse_empty_blob_object(self):
sha = b"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"
> b = self.get_blob(sha)
tests/test_objects.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:88: in get_blob
return self.get_sha_file(Blob, "blobs", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/blobs', b'e6')
hasstr = True, hasbytes = True, s = b'e6'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_parse_legacy_blob
test_objects.py::BlobReadTests::test_parse_legacy_blob
self =
def test_parse_legacy_blob(self):
string = b"test 3\n"
> b = self.get_blob(c_sha)
tests/test_objects.py:164:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:88: in get_blob
return self.get_sha_file(Blob, "blobs", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/blobs', b'95')
hasstr = True, hasbytes = True, s = b'95'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_read_commit_from_file
test_objects.py::BlobReadTests::test_read_commit_from_file
self =
def test_read_commit_from_file(self):
sha = b"60dacdc733de308bb77bb76ce0fb0f9b44c9769e"
> c = self.commit(sha)
tests/test_objects.py:220:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:97: in commit
return self.get_sha_file(Commit, "commits", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/commits', b'60')
hasstr = True, hasbytes = True, s = b'60'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_read_commit_no_parents
test_objects.py::BlobReadTests::test_read_commit_no_parents
self =
def test_read_commit_no_parents(self):
sha = b"0d89f20333fbb1d2f3a94da77f4981373d8f4310"
> c = self.commit(sha)
tests/test_objects.py:232:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:97: in commit
return self.get_sha_file(Commit, "commits", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/commits', b'0d')
hasstr = True, hasbytes = True, s = b'0d'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_read_commit_two_parents
test_objects.py::BlobReadTests::test_read_commit_two_parents
self =
def test_read_commit_two_parents(self):
sha = b"5dac377bdded4c9aeb8dff595f0faeebcc8498cc"
> c = self.commit(sha)
tests/test_objects.py:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:97: in commit
return self.get_sha_file(Commit, "commits", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/commits', b'5d')
hasstr = True, hasbytes = True, s = b'5d'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_read_tag_from_file
test_objects.py::BlobReadTests::test_read_tag_from_file
self =
def test_read_tag_from_file(self):
> t = self.get_tag(tag_sha)
tests/test_objects.py:198:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:94: in get_tag
return self.get_sha_file(Tag, "tags", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/tags', b'71')
hasstr = True, hasbytes = True, s = b'71'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_read_tree_from_file
test_objects.py::BlobReadTests::test_read_tree_from_file
self =
def test_read_tree_from_file(self):
> t = self.get_tree(tree_sha)
tests/test_objects.py:174:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:91: in get_tree
return self.get_sha_file(Tree, "trees", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/trees', b'70')
hasstr = True, hasbytes = True, s = b'70'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_read_tree_from_file_parse_count
test_objects.py::BlobReadTests::test_read_tree_from_file_parse_count
self =
def test_read_tree_from_file_parse_count(self):
old_deserialize = Tree._deserialize
def reset_deserialize():
Tree._deserialize = old_deserialize
self.addCleanup(reset_deserialize)
self.deserialize_count = 0
def counting_deserialize(*args, **kwargs):
self.deserialize_count += 1
return old_deserialize(*args, **kwargs)
Tree._deserialize = counting_deserialize
> t = self.get_tree(tree_sha)
tests/test_objects.py:192:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:91: in get_tree
return self.get_sha_file(Tree, "trees", sha)
tests/test_objects.py:84: in get_sha_file
return cls.from_path(hex_to_filename(dir, sha))
dulwich/objects.py:55: in hex_to_filename
dir = os.path.join(path, hex[:2])
/usr/lib/python3.10/posixpath.py:90: in join
genericpath._check_arg_types('join', a, *p)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
funcname = 'join', args = ('/testbed/tests/../testdata/trees', b'70')
hasstr = True, hasbytes = True, s = b'70'
def _check_arg_types(funcname, *args):
hasstr = hasbytes = False
for s in args:
if isinstance(s, str):
hasstr = True
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
> raise TypeError("Can't mix strings and bytes in path components") from None
E TypeError: Can't mix strings and bytes in path components
/usr/lib/python3.10/genericpath.py:155: TypeError
test_objects.py::BlobReadTests::test_set_chunks
test_objects.py::BlobReadTests::test_set_chunks
self =
def test_set_chunks(self):
b = Blob()
b.chunked = [b"te", b"st", b" 5\n"]
self.assertEqual(b"test 5\n", b.data)
b.chunked = [b"te", b"st", b" 6\n"]
> self.assertEqual(b"test 6\n", b.as_raw_string())
E AssertionError: b'test 6\n' != None
tests/test_objects.py:159: AssertionError
test_objects.py::BlobReadTests::test_splitlines
test_objects.py::BlobReadTests::test_splitlines
self =
def test_splitlines(self):
for case in [
[],
[b"foo\nbar\n"],
[b"bl\na", b"blie"],
[b"bl\na", b"blie", b"bloe\n"],
[b"", b"bl\na", b"blie", b"bloe\n"],
[b"", b"", b"", b"bla\n"],
[b"", b"", b"", b"bla\n", b""],
[b"bl", b"", b"a\naaa"],
[b"a\naaa", b"a"],
]:
b = Blob()
b.chunked = case
> self.assertEqual(b.data.splitlines(True), b.splitlines())
E AssertionError: Lists differ: [] != [b'']
E
E Second list contains 1 additional elements.
E First extra element 0:
E b''
E
E - []
E + [b'']
tests/test_objects.py:152: AssertionError
test_objects.py::BlobReadTests::test_stub_sha
test_objects.py::BlobReadTests::test_stub_sha
self =
def test_stub_sha(self):
sha = b"5" * 40
c = make_commit(id=sha, message=b"foo")
> self.assertIsInstance(c, Commit)
E AssertionError: None is not an instance of
tests/test_objects.py:263: AssertionError
test_objects.py::ShaFileTests::test_deflated_smaller_window_buffer
test_objects.py::ShaFileTests::test_deflated_smaller_window_buffer
self =
def test_deflated_smaller_window_buffer(self):
# zlib on some systems uses smaller buffers,
# resulting in a different header.
# See https://github.com/libgit2/libgit2/pull/464
sf = ShaFile.from_file(BytesIO(small_buffer_zlib_object))
> self.assertEqual(sf.type_name, b"tag")
E AttributeError: 'NoneType' object has no attribute 'type_name'
tests/test_objects.py:304: AttributeError
test_objects.py::CommitSerializationTests::test_deserialize
test_objects.py::CommitSerializationTests::test_deserialize
self =
def test_deserialize(self):
c = self.make_commit()
d = Commit()
> d._deserialize(c.as_raw_chunks())
E AttributeError: 'Commit' object has no attribute '_deserialize'
tests/test_objects.py:378: AttributeError
test_objects.py::CommitSerializationTests::test_deserialize_mergetag
test_objects.py::CommitSerializationTests::test_deserialize_mergetag
self =
def test_deserialize_mergetag(self):
tag = make_object(
Tag,
object=(Commit, b"a38d6181ff27824c79fc7df825164a212eff6a3f"),
object_type_name=b"commit",
name=b"v2.6.22-rc7",
tag_time=1183319674,
tag_timezone=0,
tagger=b"Linus Torvalds ",
message=default_message,
)
commit = self.make_commit(mergetag=[tag])
d = Commit()
> d._deserialize(commit.as_raw_chunks())
E AttributeError: 'Commit' object has no attribute '_deserialize'
tests/test_objects.py:535: AttributeError
test_objects.py::CommitSerializationTests::test_deserialize_mergetags
self =
def test_deserialize_mergetags(self):
tag = make_object(
Tag,
object=(Commit, b"a38d6181ff27824c79fc7df825164a212eff6a3f"),
object_type_name=b"commit",
name=b"v2.6.22-rc7",
tag_time=1183319674,
tag_timezone=0,
tagger=b"Linus Torvalds ",
message=default_message,
)
commit = self.make_commit(mergetag=[tag, tag])
d = Commit()
> d._deserialize(commit.as_raw_chunks())
E AttributeError: 'Commit' object has no attribute '_deserialize'
tests/test_objects.py:552: AttributeError
test_objects.py::CommitSerializationTests::test_encoding
test_objects.py::CommitSerializationTests::test_encoding
self =
def test_encoding(self):
c = self.make_commit(encoding=b"iso8859-1")
> self.assertIn(b"encoding iso8859-1\n", c.as_raw_string())
E AttributeError: 'NoneType' object has no attribute 'as_raw_string'
tests/test_objects.py:329: AttributeError
test_objects.py::CommitSerializationTests::test_full_tree
test_objects.py::CommitSerializationTests::test_full_tree
self =
def test_full_tree(self):
c = self.make_commit(commit_time=30)
t = Tree()
t.add(b"data-x", 0o644, Blob().id)
> c.tree = t
E AttributeError: 'NoneType' object has no attribute 'tree'
tests/test_objects.py:341: AttributeError
test_objects.py::CommitSerializationTests::test_neg_timezone
test_objects.py::CommitSerializationTests::test_neg_timezone
self =
def test_neg_timezone(self):
c = self.make_commit(commit_timezone=(-1 * 3600))
> self.assertIn(b" -0100\n", c.as_raw_string())
E AttributeError: 'NoneType' object has no attribute 'as_raw_string'
tests/test_objects.py:373: AttributeError
test_objects.py::CommitSerializationTests::test_raw_length
test_objects.py::CommitSerializationTests::test_raw_length
self =
def test_raw_length(self):
c = self.make_commit()
> self.assertEqual(len(c.as_raw_string()), c.raw_length())
E AttributeError: 'NoneType' object has no attribute 'as_raw_string'
tests/test_objects.py:349: AttributeError
test_objects.py::CommitSerializationTests::test_serialize_gpgsig
test_objects.py::CommitSerializationTests::test_serialize_gpgsig
self =
def test_serialize_gpgsig(self):
commit = self.make_commit(
gpgsig=b"""-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABCgAGBQJULCdfAAoJEACAbyvXKaRXuKwP/RyP9PA49uAvu8tQVCC/uBa8
vi975+xvO14R8Pp8k2nps7lSxCdtCd+xVT1VRHs0wNhOZo2YCVoU1HATkPejqSeV
NScTHcxnk4/+bxyfk14xvJkNp7FlQ3npmBkA+lbV0Ubr33rvtIE5jiJPyz+SgWAg
xdBG2TojV0squj00GoH/euK6aX7GgZtwdtpTv44haCQdSuPGDcI4TORqR6YSqvy3
GPE+3ZqXPFFb+KILtimkxitdwB7CpwmNse2vE3rONSwTvi8nq3ZoQYNY73CQGkUy
qoFU0pDtw87U3niFin1ZccDgH0bB6624sLViqrjcbYJeg815Htsu4rmzVaZADEVC
XhIO4MThebusdk0AcNGjgpf3HRHk0DPMDDlIjm+Oao0cqovvF6VyYmcb0C+RmhJj
dodLXMNmbqErwTk3zEkW0yZvNIYXH7m9SokPCZa4eeIM7be62X6h1mbt0/IU6Th+
v18fS0iTMP/Viug5und+05C/v04kgDo0CPphAbXwWMnkE4B6Tl9sdyUYXtvQsL7x
0+WP1gL27ANqNZiI07Kz/BhbBAQI/+2TFT7oGr0AnFPQ5jHp+3GpUf6OKuT1wT3H
ND189UFuRuubxb42vZhpcXRbqJVWnbECTKVUPsGZqat3enQUB63uM4i6/RdONDZA
fDeF1m4qYs+cUXKNUZ03
=X6RT
-----END PGP SIGNATURE-----"""
)
self.maxDiff = None
self.assertEqual(
b"""\
tree d80c186a03f423a81b39df39dc87fd269736ca86
parent ab64bbdcc51b170d21588e5c5d391ee5c0c96dfd
parent 4cffe90e0a41ad3f5190079d7c8f036bde29cbe6
author James Westby 1174773719 +0000
committer James Westby 1174773719 +0000
gpgsig -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABCgAGBQJULCdfAAoJEACAbyvXKaRXuKwP/RyP9PA49uAvu8tQVCC/uBa8
vi975+xvO14R8Pp8k2nps7lSxCdtCd+xVT1VRHs0wNhOZo2YCVoU1HATkPejqSeV
NScTHcxnk4/+bxyfk14xvJkNp7FlQ3npmBkA+lbV0Ubr33rvtIE5jiJPyz+SgWAg
xdBG2TojV0squj00GoH/euK6aX7GgZtwdtpTv44haCQdSuPGDcI4TORqR6YSqvy3
GPE+3ZqXPFFb+KILtimkxitdwB7CpwmNse2vE3rONSwTvi8nq3ZoQYNY73CQGkUy
qoFU0pDtw87U3niFin1ZccDgH0bB6624sLViqrjcbYJeg815Htsu4rmzVaZADEVC
XhIO4MThebusdk0AcNGjgpf3HRHk0DPMDDlIjm+Oao0cqovvF6VyYmcb0C+RmhJj
dodLXMNmbqErwTk3zEkW0yZvNIYXH7m9SokPCZa4eeIM7be62X6h1mbt0/IU6Th+
v18fS0iTMP/Viug5und+05C/v04kgDo0CPphAbXwWMnkE4B6Tl9sdyUYXtvQsL7x
0+WP1gL27ANqNZiI07Kz/BhbBAQI/+2TFT7oGr0AnFPQ5jHp+3GpUf6OKuT1wT3H
ND189UFuRuubxb42vZhpcXRbqJVWnbECTKVUPsGZqat3enQUB63uM4i6/RdONDZA
fDeF1m4qYs+cUXKNUZ03
=X6RT
-----END PGP SIGNATURE-----
Merge ../b
""",
> commit.as_raw_string(),
)
E AttributeError: 'NoneType' object has no attribute 'as_raw_string'
tests/test_objects.py:429: AttributeError
test_objects.py::CommitSerializationTests::test_serialize_mergetag
test_objects.py::CommitSerializationTests::test_serialize_mergetag
self =
def test_serialize_mergetag(self):
tag = make_object(
Tag,
object=(Commit, b"a38d6181ff27824c79fc7df825164a212eff6a3f"),
object_type_name=b"commit",
name=b"v2.6.22-rc7",
tag_time=1183319674,
tag_timezone=0,
tagger=b"Linus Torvalds ",
message=default_message,
)
commit = self.make_commit(mergetag=[tag])
self.assertEqual(
b"""tree d80c186a03f423a81b39df39dc87fd269736ca86
parent ab64bbdcc51b170d21588e5c5d391ee5c0c96dfd
parent 4cffe90e0a41ad3f5190079d7c8f036bde29cbe6
author James Westby 1174773719 +0000
committer James Westby 1174773719 +0000
mergetag object a38d6181ff27824c79fc7df825164a212eff6a3f
type commit
tag v2.6.22-rc7
tagger Linus Torvalds 1183319674 +0000
Linux 2.6.22-rc7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQBGiAaAF3YsRnbiHLsRAitMAKCiLboJkQECM/jpYsY3WPfvUgLXkACgg3ql
OK2XeQOiEeXtT76rV4t2WR4=
=ivrA
-----END PGP SIGNATURE-----
Merge ../b
""",
> commit.as_raw_string(),
)
E AttributeError: 'NoneType' object has no attribute 'as_raw_string'
tests/test_objects.py:467: AttributeError
test_objects.py::CommitSerializationTests::test_serialize_mergetags
self =
def test_serialize_mergetags(self):
tag = make_object(
Tag,
object=(Commit, b"a38d6181ff27824c79fc7df825164a212eff6a3f"),
object_type_name=b"commit",
name=b"v2.6.22-rc7",
tag_time=1183319674,
tag_timezone=0,
tagger=b"Linus Torvalds ",
message=default_message,
)
commit = self.make_commit(mergetag=[tag, tag])
self.assertEqual(
b"""tree d80c186a03f423a81b39df39dc87fd269736ca86
parent ab64bbdcc51b170d21588e5c5d391ee5c0c96dfd
parent 4cffe90e0a41ad3f5190079d7c8f036bde29cbe6
author James Westby 1174773719 +0000
committer James Westby 1174773719 +0000
mergetag object a38d6181ff27824c79fc7df825164a212eff6a3f
type commit
tag v2.6.22-rc7
tagger Linus Torvalds 1183319674 +0000
Linux 2.6.22-rc7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQBGiAaAF3YsRnbiHLsRAitMAKCiLboJkQECM/jpYsY3WPfvUgLXkACgg3ql
OK2XeQOiEeXtT76rV4t2WR4=
=ivrA
-----END PGP SIGNATURE-----
mergetag object a38d6181ff27824c79fc7df825164a212eff6a3f
type commit
tag v2.6.22-rc7
tagger Linus Torvalds 1183319674 +0000
Linux 2.6.22-rc7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQBGiAaAF3YsRnbiHLsRAitMAKCiLboJkQECM/jpYsY3WPfvUgLXkACgg3ql
OK2XeQOiEeXtT76rV4t2WR4=
=ivrA
-----END PGP SIGNATURE-----
Merge ../b
""",
> commit.as_raw_string(),
)
E AttributeError: 'NoneType' object has no attribute 'as_raw_string'
tests/test_objects.py:518: AttributeError
test_objects.py::CommitSerializationTests::test_short_timestamp
test_objects.py::CommitSerializationTests::test_short_timestamp
self =
def test_short_timestamp(self):
c = self.make_commit(commit_time=30)
c1 = Commit()
> c1.set_raw_string(c.as_raw_string())
E AttributeError: 'NoneType' object has no attribute 'as_raw_string'
tests/test_objects.py:334: AttributeError
test_objects.py::CommitSerializationTests::test_simple
test_objects.py::CommitSerializationTests::test_simple
self =
def test_simple(self):
c = self.make_commit()
> self.assertEqual(c.id, b"5dac377bdded4c9aeb8dff595f0faeebcc8498cc")
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_objects.py:353: AttributeError
test_objects.py::CommitSerializationTests::test_timezone
test_objects.py::CommitSerializationTests::test_timezone
self =
def test_timezone(self):
c = self.make_commit(commit_timezone=(5 * 60))
> self.assertIn(b" +0005\n", c.as_raw_string())
E AttributeError: 'NoneType' object has no attribute 'as_raw_string'
tests/test_objects.py:369: AttributeError
test_objects.py::CommitParseTests::test_check
test_objects.py::CommitParseTests::test_check
self =
def test_check(self):
self.assertCheckSucceeds(Commit, self.make_commit_text())
self.assertCheckSucceeds(Commit, self.make_commit_text(parents=None))
self.assertCheckSucceeds(Commit, self.make_commit_text(encoding=b"UTF-8"))
> self.assertCheckFails(Commit, self.make_commit_text(tree=b"xxx"))
tests/test_objects.py:632:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:276: in assertCheckFails
self.assertRaises(ObjectFormatException, do_check)
E AssertionError: ObjectFormatException not raised by do_check
test_objects.py::CommitParseTests::test_check_commit_with_overflow_date
test_objects.py::CommitParseTests::test_check_commit_with_overflow_date
self =
def test_check_commit_with_overflow_date(self):
"""Date with overflow should raise an ObjectFormatException when checked."""
identity_with_wrong_time = (
b"Igor Sysoev 18446743887488505614 +42707004"
)
commit0 = Commit.from_string(
self.make_commit_text(
author=identity_with_wrong_time, committer=default_committer
)
)
commit1 = Commit.from_string(
self.make_commit_text(
author=default_committer, committer=identity_with_wrong_time
)
)
# Those fails when triggering the check() method
for commit in [commit0, commit1]:
with self.assertRaises(ObjectFormatException):
> commit.check()
E AttributeError: 'NoneType' object has no attribute 'check'
tests/test_objects.py:706: AttributeError
test_objects.py::CommitParseTests::test_check_commit_with_unparseable_time
test_objects.py::CommitParseTests::test_check_commit_with_unparseable_time
self =
def test_check_commit_with_unparseable_time(self):
identity_with_wrong_time = (
b"Igor Sysoev 18446743887488505614+42707004"
)
# Those fail at reading time
> self.assertCheckFails(
Commit,
self.make_commit_text(
author=default_committer, committer=identity_with_wrong_time
),
)
tests/test_objects.py:674:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:276: in assertCheckFails
self.assertRaises(ObjectFormatException, do_check)
E AssertionError: ObjectFormatException not raised by do_check
test_objects.py::CommitParseTests::test_check_duplicates
test_objects.py::CommitParseTests::test_check_duplicates
self =
def test_check_duplicates(self):
# duplicate each of the header fields
for i in range(5):
lines = self.make_commit_lines(parents=[a_sha], encoding=b"UTF-8")
lines.insert(i, lines[i])
text = b"\n".join(lines)
if lines[i].startswith(b"parent"):
# duplicate parents are ok for now
self.assertCheckSucceeds(Commit, text)
else:
> self.assertCheckFails(Commit, text)
tests/test_objects.py:653:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:276: in assertCheckFails
self.assertRaises(ObjectFormatException, do_check)
E AssertionError: ObjectFormatException not raised by do_check
test_objects.py::CommitParseTests::test_check_order
test_objects.py::CommitParseTests::test_check_order
self =
def test_check_order(self):
lines = self.make_commit_lines(parents=[a_sha], encoding=b"UTF-8")
headers = lines[:5]
rest = lines[5:]
# of all possible permutations, ensure only the original succeeds
for perm in permutations(headers):
perm = list(perm)
text = b"\n".join(perm + rest)
if perm == headers:
self.assertCheckSucceeds(Commit, text)
else:
> self.assertCheckFails(Commit, text)
tests/test_objects.py:666:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:276: in assertCheckFails
self.assertRaises(ObjectFormatException, do_check)
E AssertionError: ObjectFormatException not raised by do_check
test_objects.py::CommitParseTests::test_custom
test_objects.py::CommitParseTests::test_custom
self =
def test_custom(self):
c = Commit.from_string(self.make_commit_text(extra={b"extra-field": b"data"}))
> self.assertEqual([(b"extra-field", b"data")], c._extra)
E AttributeError: 'NoneType' object has no attribute '_extra'
tests/test_objects.py:621: AttributeError
test_objects.py::CommitParseTests::test_encoding
test_objects.py::CommitParseTests::test_encoding
self =
def test_encoding(self):
c = Commit.from_string(self.make_commit_text(encoding=b"UTF-8"))
> self.assertEqual(b"UTF-8", c.encoding)
E AttributeError: 'NoneType' object has no attribute 'encoding'
tests/test_objects.py:625: AttributeError
test_objects.py::CommitParseTests::test_mangled_author_line
test_objects.py::CommitParseTests::test_mangled_author_line
self =
def test_mangled_author_line(self):
"""Mangled author line should successfully parse."""
author_line = (
b'Karl MacMillan <"Karl MacMillan '
b'"> 1197475547 -0500'
)
expected_identity = (
b'Karl MacMillan <"Karl MacMillan '
b'">'
)
commit = Commit.from_string(self.make_commit_text(author=author_line))
# The commit parses properly
> self.assertEqual(commit.author, expected_identity)
E AttributeError: 'NoneType' object has no attribute 'author'
tests/test_objects.py:721: AttributeError
test_objects.py::CommitParseTests::test_parse_gpgsig
test_objects.py::CommitParseTests::test_parse_gpgsig
self =
def test_parse_gpgsig(self):
c = Commit.from_string(
b"""tree aaff74984cccd156a469afa7d9ab10e4777beb24
author Jelmer Vernooij 1412179807 +0200
committer Jelmer Vernooij 1412179807 +0200
gpgsig -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABCgAGBQJULCdfAAoJEACAbyvXKaRXuKwP/RyP9PA49uAvu8tQVCC/uBa8
vi975+xvO14R8Pp8k2nps7lSxCdtCd+xVT1VRHs0wNhOZo2YCVoU1HATkPejqSeV
NScTHcxnk4/+bxyfk14xvJkNp7FlQ3npmBkA+lbV0Ubr33rvtIE5jiJPyz+SgWAg
xdBG2TojV0squj00GoH/euK6aX7GgZtwdtpTv44haCQdSuPGDcI4TORqR6YSqvy3
GPE+3ZqXPFFb+KILtimkxitdwB7CpwmNse2vE3rONSwTvi8nq3ZoQYNY73CQGkUy
qoFU0pDtw87U3niFin1ZccDgH0bB6624sLViqrjcbYJeg815Htsu4rmzVaZADEVC
XhIO4MThebusdk0AcNGjgpf3HRHk0DPMDDlIjm+Oao0cqovvF6VyYmcb0C+RmhJj
dodLXMNmbqErwTk3zEkW0yZvNIYXH7m9SokPCZa4eeIM7be62X6h1mbt0/IU6Th+
v18fS0iTMP/Viug5und+05C/v04kgDo0CPphAbXwWMnkE4B6Tl9sdyUYXtvQsL7x
0+WP1gL27ANqNZiI07Kz/BhbBAQI/+2TFT7oGr0AnFPQ5jHp+3GpUf6OKuT1wT3H
ND189UFuRuubxb42vZhpcXRbqJVWnbECTKVUPsGZqat3enQUB63uM4i6/RdONDZA
fDeF1m4qYs+cUXKNUZ03
=X6RT
-----END PGP SIGNATURE-----
foo
"""
)
> self.assertEqual(b"foo\n", c.message)
E AttributeError: 'NoneType' object has no attribute 'message'
tests/test_objects.py:753: AttributeError
test_objects.py::CommitParseTests::test_parse_header_trailing_newline
self =
def test_parse_header_trailing_newline(self):
c = Commit.from_string(
b"""\
tree a7d6277f78d3ecd0230a1a5df6db00b1d9c521ac
parent c09b6dec7a73760fbdb478383a3c926b18db8bbe
author Neil Matatall 1461964057 -1000
committer Neil Matatall 1461964057 -1000
gpgsig -----BEGIN PGP SIGNATURE-----
wsBcBAABCAAQBQJXI80ZCRA6pcNDcVZ70gAAarcIABs72xRX3FWeox349nh6ucJK
CtwmBTusez2Zwmq895fQEbZK7jpaGO5TRO4OvjFxlRo0E08UFx3pxZHSpj6bsFeL
hHsDXnCaotphLkbgKKRdGZo7tDqM84wuEDlh4MwNe7qlFC7bYLDyysc81ZX5lpMm
2MFF1TvjLAzSvkT7H1LPkuR3hSvfCYhikbPOUNnKOo0sYjeJeAJ/JdAVQ4mdJIM0
gl3REp9+A+qBEpNQI7z94Pg5Bc5xenwuDh3SJgHvJV6zBWupWcdB3fAkVd4TPnEZ
nHxksHfeNln9RKseIDcy4b2ATjhDNIJZARHNfr6oy4u3XPW4svRqtBsLoMiIeuI=
=ms6q
-----END PGP SIGNATURE-----
3.3.0 version bump and docs
"""
)
> self.assertEqual([], c._extra)
E AttributeError: 'NoneType' object has no attribute '_extra'
tests/test_objects.py:798: AttributeError
test_objects.py::CommitParseTests::test_simple
test_objects.py::CommitParseTests::test_simple
self =
def test_simple(self):
c = Commit.from_string(self.make_commit_text())
> self.assertEqual(b"Merge ../b\n", c.message)
E AttributeError: 'NoneType' object has no attribute 'message'
tests/test_objects.py:597: AttributeError
test_objects.py::TreeTests::test_add
test_objects.py::TreeTests::test_add
self =
def test_add(self):
myhexsha = b"d80c186a03f423a81b39df39dc87fd269736ca86"
x = Tree()
x.add(b"myname", 0o100755, myhexsha)
> self.assertEqual(x[b"myname"], (0o100755, myhexsha))
tests/test_objects.py:833:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , name = b'myname'
def __getitem__(self, name):
> return self._entries[name]
E KeyError: b'myname'
dulwich/objects.py:571: KeyError
test_objects.py::TreeTests::test_check
test_objects.py::TreeTests::test_check
self =
def test_check(self):
t = Tree
sha = hex_to_sha(a_sha)
# filenames
self.assertCheckSucceeds(t, b"100644 .a\0" + sha)
> self.assertCheckFails(t, b"100644 \0" + sha)
tests/test_objects.py:946:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:276: in assertCheckFails
self.assertRaises(ObjectFormatException, do_check)
E AssertionError: ObjectFormatException not raised by do_check
test_objects.py::TreeTests::test_simple
test_objects.py::TreeTests::test_simple
self =
def test_simple(self):
myhexsha = b"d80c186a03f423a81b39df39dc87fd269736ca86"
x = Tree()
x[b"myname"] = (0o100755, myhexsha)
> self.assertEqual(b"100755 myname\0" + hex_to_sha(myhexsha), x.as_raw_string())
E AssertionError: b'100755 myname\x00\xd8\x0c\x18j\x03\xf4#[36 chars]\x86' != None
tests/test_objects.py:840: AssertionError
test_objects.py::TreeTests::test_tree_items_dir_sort
test_objects.py::TreeTests::test_tree_items_dir_sort
self =
def test_tree_items_dir_sort(self):
x = Tree()
for name, item in _TREE_ITEMS.items():
x[name] = item
> self.assertEqual(_SORTED_TREE_ITEMS, x.items())
E AssertionError: [TreeEntry(path=b'a.c', mode=33261, sha=b[207 chars]86')] != None
tests/test_objects.py:860: AssertionError
test_objects.py::TreeTests::test_tree_iteritems_dir_sort
test_objects.py::TreeTests::test_tree_iteritems_dir_sort
self =
def test_tree_iteritems_dir_sort(self):
x = Tree()
for name, item in _TREE_ITEMS.items():
x[name] = item
> self.assertEqual(_SORTED_TREE_ITEMS, x.items())
E AssertionError: [TreeEntry(path=b'a.c', mode=33261, sha=b[207 chars]86')] != None
tests/test_objects.py:854: AssertionError
test_objects.py::TreeTests::test_tree_update_id
test_objects.py::TreeTests::test_tree_update_id
self =
def test_tree_update_id(self):
x = Tree()
x[b"a.c"] = (0o100755, b"d80c186a03f423a81b39df39dc87fd269736ca86")
> self.assertEqual(b"0c5c6bc2c081accfbc250331b19e43b904ab9cdd", x.id)
E AssertionError: b'0c5c6bc2c081accfbc250331b19e43b904ab9cdd' != None
tests/test_objects.py:846: AssertionError
test_objects.py::TagSerializeTests::test_serialize_none_message
self =
def test_serialize_none_message(self):
x = make_object(
Tag,
tagger=b"Jelmer Vernooij ",
name=b"0.1",
message=None,
object=(Blob, b"d80c186a03f423a81b39df39dc87fd269736ca86"),
tag_time=423423423,
tag_timezone=0,
)
self.assertEqual(
(
b"object d80c186a03f423a81b39df39dc87fd269736ca86\n"
b"type blob\n"
b"tag 0.1\n"
b"tagger Jelmer Vernooij "
b"423423423 +0000\n"
),
> x.as_raw_string(),
)
E AttributeError: 'NoneType' object has no attribute 'as_raw_string'
tests/test_objects.py:1022: AttributeError
test_objects.py::TagSerializeTests::test_serialize_simple
self =
def test_serialize_simple(self):
x = make_object(
Tag,
tagger=b"Jelmer Vernooij ",
name=b"0.1",
message=b"Tag 0.1",
object=(Blob, b"d80c186a03f423a81b39df39dc87fd269736ca86"),
tag_time=423423423,
tag_timezone=0,
)
self.assertEqual(
(
b"object d80c186a03f423a81b39df39dc87fd269736ca86\n"
b"type blob\n"
b"tag 0.1\n"
b"tagger Jelmer Vernooij "
b"423423423 +0000\n"
b"\n"
b"Tag 0.1"
),
> x.as_raw_string(),
)
E AttributeError: 'NoneType' object has no attribute 'as_raw_string'
tests/test_objects.py:1001: AttributeError
test_objects.py::TagParseTests::test_check
test_objects.py::TagParseTests::test_check
self =
def test_check(self):
self.assertCheckSucceeds(Tag, self.make_tag_text())
> self.assertCheckFails(Tag, self.make_tag_text(object_sha=None))
tests/test_objects.py:1105:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:276: in assertCheckFails
self.assertRaises(ObjectFormatException, do_check)
E AssertionError: ObjectFormatException not raised by do_check
test_objects.py::TagParseTests::test_check_duplicates
test_objects.py::TagParseTests::test_check_duplicates
self =
def test_check_duplicates(self):
# duplicate each of the header fields
for i in range(4):
lines = self.make_tag_lines()
lines.insert(i, lines[i])
> self.assertCheckFails(Tag, b"\n".join(lines))
tests/test_objects.py:1150:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:276: in assertCheckFails
self.assertRaises(ObjectFormatException, do_check)
E AssertionError: ObjectFormatException not raised by do_check
test_objects.py::TagParseTests::test_check_order
test_objects.py::TagParseTests::test_check_order
self =
def test_check_order(self):
lines = self.make_tag_lines()
headers = lines[:4]
rest = lines[4:]
# of all possible permutations, ensure only the original succeeds
for perm in permutations(headers):
perm = list(perm)
text = b"\n".join(perm + rest)
if perm == headers:
self.assertCheckSucceeds(Tag, text)
else:
> self.assertCheckFails(Tag, text)
tests/test_objects.py:1163:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:276: in assertCheckFails
self.assertRaises(ObjectFormatException, do_check)
E AssertionError: ObjectFormatException not raised by do_check
test_objects.py::TagParseTests::test_check_tag_with_overflow_time
test_objects.py::TagParseTests::test_check_tag_with_overflow_time
self =
def test_check_tag_with_overflow_time(self):
"""Date with overflow should raise an ObjectFormatException when checked."""
author = f"Some Dude {MAX_TIME + 1} +0000"
tag = Tag.from_string(self.make_tag_text(tagger=(author.encode())))
with self.assertRaises(ObjectFormatException):
> tag.check()
E AttributeError: 'NoneType' object has no attribute 'check'
tests/test_objects.py:1143: AttributeError
test_objects.py::TagParseTests::test_check_tag_with_unparseable_field
test_objects.py::TagParseTests::test_check_tag_with_unparseable_field
self =
def test_check_tag_with_unparseable_field(self):
> self.assertCheckFails(
Tag,
self.make_tag_text(
tagger=(
b"Linus Torvalds "
b"423423+0000"
)
),
)
tests/test_objects.py:1128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_objects.py:276: in assertCheckFails
self.assertRaises(ObjectFormatException, do_check)
E AssertionError: ObjectFormatException not raised by do_check
test_objects.py::TagParseTests::test_parse
test_objects.py::TagParseTests::test_parse
self =
def test_parse(self):
x = Tag()
x.set_raw_string(self.make_tag_text())
> self.assertEqual(
b"Linus Torvalds ", x.tagger
)
E AssertionError: b'Linus Torvalds ' != None
tests/test_objects.py:1069: AssertionError
test_objects.py::TagParseTests::test_parse_no_message
test_objects.py::TagParseTests::test_parse_no_message
self =
def test_parse_no_message(self):
x = Tag()
x.set_raw_string(self.make_tag_text(message=None))
> self.assertEqual(None, x.message)
tests/test_objects.py:1092:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
obj =
def get(obj):
> return getattr(obj, '_' + name)
E AttributeError: 'Tag' object has no attribute '_message'. Did you mean: 'message'?
dulwich/objects.py:77: AttributeError
test_objects.py::TagParseTests::test_parse_no_tagger
test_objects.py::TagParseTests::test_parse_no_tagger
self =
def test_parse_no_tagger(self):
x = Tag()
x.set_raw_string(self.make_tag_text(tagger=None))
self.assertEqual(None, x.tagger)
> self.assertEqual(b"v2.6.22-rc7", x.name)
tests/test_objects.py:1086:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
obj =
def get(obj):
> return getattr(obj, '_' + name)
E AttributeError: 'Tag' object has no attribute '_name'. Did you mean: 'name'?
dulwich/objects.py:77: AttributeError
test_objects.py::TagParseTests::test_tree_copy_after_update
test_objects.py::TagParseTests::test_tree_copy_after_update
self =
def test_tree_copy_after_update(self):
"""Check Tree.id is correctly updated when the tree is copied after updated."""
shas = []
tree = Tree()
shas.append(tree.id)
tree.add(b"data", 0o644, Blob().id)
copied = tree.copy()
shas.append(tree.id)
> shas.append(copied.id)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_objects.py:1173: AttributeError
test_objects.py::CheckTests::test_check_identity
test_objects.py::CheckTests::test_check_identity
self =
def test_check_identity(self):
check_identity(
b"Dave Borowitz ",
"failed to check good identity",
)
check_identity(b" ", "failed to check good identity")
self.assertRaises(
ObjectFormatException,
check_identity,
b"",
"no space before email",
)
self.assertRaises(
ObjectFormatException, check_identity, b"Dave Borowitz", "no email"
)
self.assertRaises(
ObjectFormatException,
check_identity,
b"Dave Borowitz ",
"incomplete email",
)
> self.assertRaises(
ObjectFormatException,
check_identity,
b"Dave Borowitz <",
"typo",
)
E AssertionError: ObjectFormatException not raised by check_identity
tests/test_objects.py:1222: AssertionError
test_objects.py::TimezoneTests::test_format_timezone_cet
self =
def test_format_timezone_cet(self):
> self.assertEqual(b"+0100", format_timezone(60 * 60))
E AssertionError: b'+0100' != None
tests/test_objects.py:1289: AssertionError
test_objects.py::TimezoneTests::test_format_timezone_double_negative
self =
def test_format_timezone_double_negative(self):
> self.assertEqual(b"--700", format_timezone(int((7 * 60) * 60), True))
E AssertionError: b'--700' != None
tests/test_objects.py:1301: AssertionError
test_objects.py::TimezoneTests::test_format_timezone_pdt
self =
def test_format_timezone_pdt(self):
> self.assertEqual(b"-0400", format_timezone(-4 * 60 * 60))
E AssertionError: b'-0400' != None
tests/test_objects.py:1292: AssertionError
test_objects.py::TimezoneTests::test_format_timezone_pdt_half
self =
def test_format_timezone_pdt_half(self):
> self.assertEqual(b"-0440", format_timezone(int(((-4 * 60) - 40) * 60)))
E AssertionError: b'-0440' != None
tests/test_objects.py:1298: AssertionError
test_objects.py::TimezoneTests::test_generate_timezone_utc
test_objects.py::TimezoneTests::test_generate_timezone_utc
self =
def test_generate_timezone_utc(self):
> self.assertEqual(b"+0000", format_timezone(0))
E AssertionError: b'+0000' != None
tests/test_objects.py:1280: AssertionError
test_objects.py::TimezoneTests::test_generate_timezone_utc_negative
test_objects.py::TimezoneTests::test_generate_timezone_utc_negative
self =
def test_generate_timezone_utc_negative(self):
> self.assertEqual(b"-0000", format_timezone(0, True))
E AssertionError: b'-0000' != None
tests/test_objects.py:1283: AssertionError
test_objects.py::TimezoneTests::test_parse_timezone_cet
test_objects.py::TimezoneTests::test_parse_timezone_cet
self =
def test_parse_timezone_cet(self):
> self.assertEqual((60 * 60, False), parse_timezone(b"+0100"))
E AssertionError: (3600, False) != None
tests/test_objects.py:1286: AssertionError
test_objects.py::TimezoneTests::test_parse_timezone_double_negative
test_objects.py::TimezoneTests::test_parse_timezone_double_negative
self =
def test_parse_timezone_double_negative(self):
> self.assertEqual((int((7 * 60) * 60), False), parse_timezone(b"+700"))
E AssertionError: (25200, False) != None
tests/test_objects.py:1307: AssertionError
test_objects.py::TimezoneTests::test_parse_timezone_pdt
test_objects.py::TimezoneTests::test_parse_timezone_pdt
self =
def test_parse_timezone_pdt(self):
> self.assertEqual((-4 * 60 * 60, False), parse_timezone(b"-0400"))
E AssertionError: (-14400, False) != None
tests/test_objects.py:1295: AssertionError
test_objects.py::TimezoneTests::test_parse_timezone_pdt_half
test_objects.py::TimezoneTests::test_parse_timezone_pdt_half
self =
def test_parse_timezone_pdt_half(self):
> self.assertEqual((((-4 * 60) - 40) * 60, False), parse_timezone(b"-0440"))
E AssertionError: (-16800, False) != None
tests/test_objects.py:1304: AssertionError
test_objects.py::TimezoneTests::test_parse_timezone_utc
test_objects.py::TimezoneTests::test_parse_timezone_utc
self =
def test_parse_timezone_utc(self):
> self.assertEqual((0, False), parse_timezone(b"+0000"))
E AssertionError: (0, False) != None
tests/test_objects.py:1274: AssertionError
test_objects.py::TimezoneTests::test_parse_timezone_utc_negative
test_objects.py::TimezoneTests::test_parse_timezone_utc_negative
self =
def test_parse_timezone_utc_negative(self):
> self.assertEqual((0, True), parse_timezone(b"-0000"))
E AssertionError: (0, True) != None
tests/test_objects.py:1277: AssertionError
test_objects.py::ShaFileCopyTests::test_blob_copy
test_objects.py::ShaFileCopyTests::test_blob_copy
self =
def test_blob_copy(self):
blob = make_object(Blob, data=b"i am a blob")
> self.assert_copy(blob)
tests/test_objects.py:1340:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
orig = None
def assert_copy(self, orig):
> oclass = object_class(orig.type_num)
E AttributeError: 'NoneType' object has no attribute 'type_num'
tests/test_objects.py:1313: AttributeError
test_objects.py::ShaFileCopyTests::test_commit_copy
test_objects.py::ShaFileCopyTests::test_commit_copy
self =
def test_commit_copy(self):
attrs = {
"tree": b"d80c186a03f423a81b39df39dc87fd269736ca86",
"parents": [
b"ab64bbdcc51b170d21588e5c5d391ee5c0c96dfd",
b"4cffe90e0a41ad3f5190079d7c8f036bde29cbe6",
],
"author": b"James Westby ",
"committer": b"James Westby ",
"commit_time": 1174773719,
"author_time": 1174773719,
"commit_timezone": 0,
"author_timezone": 0,
"message": b"Merge ../b\n",
}
commit = make_commit(**attrs)
> self.assert_copy(commit)
tests/test_objects.py:1336:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
orig = None
def assert_copy(self, orig):
> oclass = object_class(orig.type_num)
E AttributeError: 'NoneType' object has no attribute 'type_num'
tests/test_objects.py:1313: AttributeError
test_objects.py::ShaFileCopyTests::test_tag_copy
test_objects.py::ShaFileCopyTests::test_tag_copy
self =
def test_tag_copy(self):
tag = make_object(
Tag,
name=b"tag",
message=b"",
tagger=b"Tagger ",
tag_time=12345,
tag_timezone=0,
object=(Commit, b"0" * 40),
)
> self.assert_copy(tag)
tests/test_objects.py:1358:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
orig = None
def assert_copy(self, orig):
> oclass = object_class(orig.type_num)
E AttributeError: 'NoneType' object has no attribute 'type_num'
tests/test_objects.py:1313: AttributeError
test_objects.py::ShaFileCopyTests::test_tree_copy
test_objects.py::ShaFileCopyTests::test_tree_copy
self =
def test_tree_copy(self):
blob = make_object(Blob, data=b"i am a blob")
tree = Tree()
> tree[b"blob"] = (stat.S_IFREG, blob.id)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_objects.py:1345: AttributeError
test_objects.py::ShaFileSerializeTests::test_blob_serialize
test_objects.py::ShaFileSerializeTests::test_blob_serialize
self =
def test_blob_serialize(self):
blob = make_object(Blob, data=b"i am a blob")
> with self.assert_serialization_on_change(
blob, needs_serialization_after_change=False
):
tests/test_objects.py:1404:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.10/contextlib.py:135: in __enter__
return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
obj = None, needs_serialization_after_change = False
@contextmanager
def assert_serialization_on_change(
self, obj, needs_serialization_after_change=True
):
> old_id = obj.id
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_objects.py:1368: AttributeError
test_objects.py::ShaFileSerializeTests::test_commit_serialize
test_objects.py::ShaFileSerializeTests::test_commit_serialize
self =
def test_commit_serialize(self):
attrs = {
"tree": b"d80c186a03f423a81b39df39dc87fd269736ca86",
"parents": [
b"ab64bbdcc51b170d21588e5c5d391ee5c0c96dfd",
b"4cffe90e0a41ad3f5190079d7c8f036bde29cbe6",
],
"author": b"James Westby ",
"committer": b"James Westby ",
"commit_time": 1174773719,
"author_time": 1174773719,
"commit_timezone": 0,
"author_timezone": 0,
"message": b"Merge ../b\n",
}
commit = make_commit(**attrs)
> with self.assert_serialization_on_change(commit):
tests/test_objects.py:1398:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.10/contextlib.py:135: in __enter__
return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
obj = None, needs_serialization_after_change = True
@contextmanager
def assert_serialization_on_change(
self, obj, needs_serialization_after_change=True
):
> old_id = obj.id
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_objects.py:1368: AttributeError
test_objects.py::ShaFileSerializeTests::test_tag_serialize
test_objects.py::ShaFileSerializeTests::test_tag_serialize
self =
def test_tag_serialize(self):
tag = make_object(
Tag,
name=b"tag",
message=b"",
tagger=b"Tagger ",
tag_time=12345,
tag_timezone=0,
object=(Commit, b"0" * 40),
)
> with self.assert_serialization_on_change(tag):
tests/test_objects.py:1428:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.10/contextlib.py:135: in __enter__
return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
obj = None, needs_serialization_after_change = True
@contextmanager
def assert_serialization_on_change(
self, obj, needs_serialization_after_change=True
):
> old_id = obj.id
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_objects.py:1368: AttributeError
test_objects.py::ShaFileSerializeTests::test_tag_serialize_time_error
test_objects.py::ShaFileSerializeTests::test_tag_serialize_time_error
self =
def test_tag_serialize_time_error(self):
with self.assertRaises(ObjectFormatException):
tag = make_object(
Tag,
name=b"tag",
message=b"some message",
tagger=b"Tagger 1174773719+0000",
object=(Commit, b"0" * 40),
)
> tag._deserialize(tag._serialize())
E AttributeError: 'NoneType' object has no attribute '_deserialize'
tests/test_objects.py:1440: AttributeError
test_objects.py::ShaFileSerializeTests::test_tree_serialize
test_objects.py::ShaFileSerializeTests::test_tree_serialize
self =
def test_tree_serialize(self):
blob = make_object(Blob, data=b"i am a blob")
tree = Tree()
> tree[b"blob"] = (stat.S_IFREG, blob.id)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_objects.py:1412: AttributeError
test_objects.py::PrettyFormatTreeEntryTests::test_format
test_objects.py::PrettyFormatTreeEntryTests::test_format
self =
def test_format(self):
> self.assertEqual(
"40000 tree 40820c38cfb182ce6c8b261555410d8382a5918b\tfoo\n",
pretty_format_tree_entry(
b"foo", 0o40000, b"40820c38cfb182ce6c8b261555410d8382a5918b"
),
)
E AssertionError: '40000 tree 40820c38cfb182ce6c8b261555410d8382a5918b\tfoo\n' != None
tests/test_objects.py:1445: AssertionError
test_objectspec.py::ParseObjectTests::test_blob_by_sha
test_objectspec.py::ParseObjectTests::test_blob_by_sha
self =
def test_blob_by_sha(self):
> r = MemoryRepo()
tests/test_objectspec.py:50:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_objectspec.py::ParseObjectTests::test_nonexistent
test_objectspec.py::ParseObjectTests::test_nonexistent
self =
def test_nonexistent(self):
> r = MemoryRepo()
tests/test_objectspec.py:46:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_objectspec.py::ParseCommitRangeTests::test_commit_by_sha
test_objectspec.py::ParseCommitRangeTests::test_commit_by_sha
self =
def test_commit_by_sha(self):
> r = MemoryRepo()
tests/test_objectspec.py:64:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_objectspec.py::ParseCommitRangeTests::test_nonexistent
test_objectspec.py::ParseCommitRangeTests::test_nonexistent
self =
def test_nonexistent(self):
> r = MemoryRepo()
tests/test_objectspec.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_objectspec.py::ParseCommitTests::test_commit_by_sha
test_objectspec.py::ParseCommitTests::test_commit_by_sha
self =
def test_commit_by_sha(self):
> r = MemoryRepo()
tests/test_objectspec.py:77:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_objectspec.py::ParseCommitTests::test_commit_by_short_sha
test_objectspec.py::ParseCommitTests::test_commit_by_short_sha
self =
def test_commit_by_short_sha(self):
> r = MemoryRepo()
tests/test_objectspec.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_objectspec.py::ParseCommitTests::test_nonexistent
test_objectspec.py::ParseCommitTests::test_nonexistent
self =
def test_nonexistent(self):
> r = MemoryRepo()
tests/test_objectspec.py:73:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_objectspec.py::ParseRefTests::test_ambiguous_head
test_objectspec.py::ParseRefTests::test_ambiguous_head
self =
def test_ambiguous_head(self):
r = {
b"refs/heads/ambig4": "bla",
b"refs/remotes/ambig4": "bla",
b"refs/remotes/ambig4/HEAD": "bla",
}
> self.assertEqual(b"refs/heads/ambig4", parse_ref(r, b"ambig4"))
E AssertionError: b'refs/heads/ambig4' != None
tests/test_objectspec.py:128: AssertionError
test_objectspec.py::ParseRefTests::test_ambiguous_ref
test_objectspec.py::ParseRefTests::test_ambiguous_ref
self =
def test_ambiguous_ref(self):
r = {
b"ambig1": "bla",
b"refs/ambig1": "bla",
b"refs/tags/ambig1": "bla",
b"refs/heads/ambig1": "bla",
b"refs/remotes/ambig1": "bla",
b"refs/remotes/ambig1/HEAD": "bla",
}
> self.assertEqual(b"ambig1", parse_ref(r, b"ambig1"))
E AssertionError: b'ambig1' != None
tests/test_objectspec.py:101: AssertionError
test_objectspec.py::ParseRefTests::test_ambiguous_ref2
test_objectspec.py::ParseRefTests::test_ambiguous_ref2
self =
def test_ambiguous_ref2(self):
r = {
b"refs/ambig2": "bla",
b"refs/tags/ambig2": "bla",
b"refs/heads/ambig2": "bla",
b"refs/remotes/ambig2": "bla",
b"refs/remotes/ambig2/HEAD": "bla",
}
> self.assertEqual(b"refs/ambig2", parse_ref(r, b"ambig2"))
E AssertionError: b'refs/ambig2' != None
tests/test_objectspec.py:111: AssertionError
test_objectspec.py::ParseRefTests::test_ambiguous_remote
test_objectspec.py::ParseRefTests::test_ambiguous_remote
self =
def test_ambiguous_remote(self):
r = {b"refs/remotes/ambig5": "bla", b"refs/remotes/ambig5/HEAD": "bla"}
> self.assertEqual(b"refs/remotes/ambig5", parse_ref(r, b"ambig5"))
E AssertionError: b'refs/remotes/ambig5' != None
tests/test_objectspec.py:132: AssertionError
test_objectspec.py::ParseRefTests::test_ambiguous_remote_head
test_objectspec.py::ParseRefTests::test_ambiguous_remote_head
self =
def test_ambiguous_remote_head(self):
r = {b"refs/remotes/ambig6/HEAD": "bla"}
> self.assertEqual(b"refs/remotes/ambig6/HEAD", parse_ref(r, b"ambig6"))
E AssertionError: b'refs/remotes/ambig6/HEAD' != None
tests/test_objectspec.py:136: AssertionError
test_objectspec.py::ParseRefTests::test_ambiguous_tag
test_objectspec.py::ParseRefTests::test_ambiguous_tag
self =
def test_ambiguous_tag(self):
r = {
b"refs/tags/ambig3": "bla",
b"refs/heads/ambig3": "bla",
b"refs/remotes/ambig3": "bla",
b"refs/remotes/ambig3/HEAD": "bla",
}
> self.assertEqual(b"refs/tags/ambig3", parse_ref(r, b"ambig3"))
E AssertionError: b'refs/tags/ambig3' != None
tests/test_objectspec.py:120: AssertionError
test_objectspec.py::ParseRefTests::test_heads_full
test_objectspec.py::ParseRefTests::test_heads_full
self =
def test_heads_full(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual(b"refs/heads/foo", parse_ref(r, b"refs/heads/foo"))
E AssertionError: b'refs/heads/foo' != None
tests/test_objectspec.py:140: AssertionError
test_objectspec.py::ParseRefTests::test_heads_partial
test_objectspec.py::ParseRefTests::test_heads_partial
self =
def test_heads_partial(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual(b"refs/heads/foo", parse_ref(r, b"heads/foo"))
E AssertionError: b'refs/heads/foo' != None
tests/test_objectspec.py:144: AssertionError
test_objectspec.py::ParseRefTests::test_nonexistent
test_objectspec.py::ParseRefTests::test_nonexistent
self =
def test_nonexistent(self):
r = {}
> self.assertRaises(KeyError, parse_ref, r, b"thisdoesnotexist")
E AssertionError: KeyError not raised by parse_ref
tests/test_objectspec.py:90: AssertionError
test_objectspec.py::ParseRefTests::test_tags_partial
self =
def test_tags_partial(self):
r = {b"refs/tags/foo": "bla"}
> self.assertEqual(b"refs/tags/foo", parse_ref(r, b"tags/foo"))
E AssertionError: b'refs/tags/foo' != None
tests/test_objectspec.py:148: AssertionError
test_objectspec.py::ParseRefsTests::test_full
test_objectspec.py::ParseRefsTests::test_full
self =
def test_full(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual([b"refs/heads/foo"], parse_refs(r, b"refs/heads/foo"))
E AssertionError: [b'refs/heads/foo'] != None
tests/test_objectspec.py:162: AssertionError
test_objectspec.py::ParseRefsTests::test_head
test_objectspec.py::ParseRefsTests::test_head
self =
def test_head(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual([b"refs/heads/foo"], parse_refs(r, [b"foo"]))
E AssertionError: [b'refs/heads/foo'] != None
tests/test_objectspec.py:158: AssertionError
test_objectspec.py::ParseRefsTests::test_nonexistent
test_objectspec.py::ParseRefsTests::test_nonexistent
self =
def test_nonexistent(self):
r = {}
> self.assertRaises(KeyError, parse_refs, r, [b"thisdoesnotexist"])
E AssertionError: KeyError not raised by parse_refs
tests/test_objectspec.py:154: AssertionError
test_objectspec.py::ParseReftupleTests::test_default_with_string
test_objectspec.py::ParseReftupleTests::test_default_with_string
self =
def test_default_with_string(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual(
(b"refs/heads/foo", b"refs/heads/foo", False),
parse_reftuple(r, r, "foo"),
)
E AssertionError: (b'refs/heads/foo', b'refs/heads/foo', False) != None
tests/test_objectspec.py:212: AssertionError
test_objectspec.py::ParseReftupleTests::test_full
test_objectspec.py::ParseReftupleTests::test_full
self =
def test_full(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual(
(b"refs/heads/foo", b"refs/heads/foo", False),
parse_reftuple(r, r, b"refs/heads/foo"),
)
E AssertionError: (b'refs/heads/foo', b'refs/heads/foo', False) != None
tests/test_objectspec.py:191: AssertionError
test_objectspec.py::ParseReftupleTests::test_head
test_objectspec.py::ParseReftupleTests::test_head
self =
def test_head(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual(
(b"refs/heads/foo", b"refs/heads/foo", False),
parse_reftuple(r, r, b"foo"),
)
E AssertionError: (b'refs/heads/foo', b'refs/heads/foo', False) != None
tests/test_objectspec.py:172: AssertionError
test_objectspec.py::ParseReftupleTests::test_no_left_ref
test_objectspec.py::ParseReftupleTests::test_no_left_ref
self =
def test_no_left_ref(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual(
(None, b"refs/heads/foo", False),
parse_reftuple(r, r, b":refs/heads/foo"),
)
E AssertionError: (None, b'refs/heads/foo', False) != None
tests/test_objectspec.py:198: AssertionError
test_objectspec.py::ParseReftupleTests::test_no_right_ref
test_objectspec.py::ParseReftupleTests::test_no_right_ref
self =
def test_no_right_ref(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual(
(b"refs/heads/foo", None, False),
parse_reftuple(r, r, b"refs/heads/foo:"),
)
E AssertionError: (b'refs/heads/foo', None, False) != None
tests/test_objectspec.py:205: AssertionError
test_objectspec.py::ParseReftupleTests::test_nonexistent
test_objectspec.py::ParseReftupleTests::test_nonexistent
self =
def test_nonexistent(self):
r = {}
> self.assertRaises(KeyError, parse_reftuple, r, r, b"thisdoesnotexist")
E AssertionError: KeyError not raised by parse_reftuple
tests/test_objectspec.py:168: AssertionError
test_objectspec.py::ParseReftuplesTests::test_full
test_objectspec.py::ParseReftuplesTests::test_full
self =
def test_full(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual(
[(b"refs/heads/foo", b"refs/heads/foo", False)],
parse_reftuples(r, r, b"refs/heads/foo"),
)
E AssertionError: [(b'refs/heads/foo', b'refs/heads/foo', False)] != None
tests/test_objectspec.py:232: AssertionError
test_objectspec.py::ParseReftuplesTests::test_head
test_objectspec.py::ParseReftuplesTests::test_head
self =
def test_head(self):
r = {b"refs/heads/foo": "bla"}
> self.assertEqual(
[(b"refs/heads/foo", b"refs/heads/foo", False)],
parse_reftuples(r, r, [b"foo"]),
)
E AssertionError: [(b'refs/heads/foo', b'refs/heads/foo', False)] != None
tests/test_objectspec.py:225: AssertionError
test_objectspec.py::ParseReftuplesTests::test_nonexistent
test_objectspec.py::ParseReftuplesTests::test_nonexistent
self =
def test_nonexistent(self):
r = {}
> self.assertRaises(KeyError, parse_reftuples, r, r, [b"thisdoesnotexist"])
E AssertionError: KeyError not raised by parse_reftuples
tests/test_objectspec.py:221: AssertionError
test_objectspec.py::ParseTreeTests::test_from_commit
test_objectspec.py::ParseTreeTests::test_from_commit
self =
def test_from_commit(self):
> r = MemoryRepo()
tests/test_objectspec.py:251:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_objectspec.py::ParseTreeTests::test_from_ref
test_objectspec.py::ParseTreeTests::test_from_ref
self =
def test_from_ref(self):
> r = MemoryRepo()
tests/test_objectspec.py:257:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_objectspec.py::ParseTreeTests::test_nonexistent
test_objectspec.py::ParseTreeTests::test_nonexistent
self =
def test_nonexistent(self):
> r = MemoryRepo()
tests/test_objectspec.py:247:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_pack.py::PackIndexTests::test_get_stored_checksum
test_pack.py::PackIndexTests::test_get_stored_checksum
self =
def test_get_stored_checksum(self):
p = self.get_pack_index(pack1_sha)
self.assertEqual(
b"f2848e2ad16f329ae1c92e3b95e91888daa5bd01",
> sha_to_hex(p.get_stored_checksum()),
)
E AttributeError: 'NoneType' object has no attribute 'get_stored_checksum'
tests/test_pack.py:135: AttributeError
test_pack.py::PackIndexTests::test_index_check
test_pack.py::PackIndexTests::test_index_check
self =
def test_index_check(self):
p = self.get_pack_index(pack1_sha)
> self.assertSucceeds(p.check)
E AttributeError: 'NoneType' object has no attribute 'check'
tests/test_pack.py:144: AttributeError
test_pack.py::PackIndexTests::test_index_len
test_pack.py::PackIndexTests::test_index_len
self =
def test_index_len(self):
p = self.get_pack_index(pack1_sha)
> self.assertEqual(3, len(p))
E TypeError: object of type 'NoneType' has no len()
tests/test_pack.py:129: TypeError
test_pack.py::PackIndexTests::test_iter
test_pack.py::PackIndexTests::test_iter
self =
def test_iter(self):
p = self.get_pack_index(pack1_sha)
> self.assertEqual({tree_sha, commit_sha, a_sha}, set(p))
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:160: TypeError
test_pack.py::PackIndexTests::test_iterentries
test_pack.py::PackIndexTests::test_iterentries
self =
def test_iterentries(self):
p = self.get_pack_index(pack1_sha)
> entries = [(sha_to_hex(s), o, c) for s, o, c in p.iterentries()]
E AttributeError: 'NoneType' object has no attribute 'iterentries'
tests/test_pack.py:148: AttributeError
test_pack.py::PackIndexTests::test_object_offset
test_pack.py::PackIndexTests::test_object_offset
self =
def test_object_offset(self):
"""Tests that the correct object offset is returned from the index."""
p = self.get_pack_index(pack1_sha)
> self.assertRaises(KeyError, p.object_offset, pack1_sha)
E AttributeError: 'NoneType' object has no attribute 'object_offset'
tests/test_pack.py:114: AttributeError
test_pack.py::PackIndexTests::test_object_sha1
test_pack.py::PackIndexTests::test_object_sha1
self =
def test_object_sha1(self):
"""Tests that the correct object offset is returned from the index."""
p = self.get_pack_index(pack1_sha)
> self.assertRaises(KeyError, p.object_sha1, 876)
E AttributeError: 'NoneType' object has no attribute 'object_sha1'
tests/test_pack.py:122: AttributeError
test_pack.py::TestPackDeltas::test_change
test_pack.py::TestPackDeltas::test_change
self =
def test_change(self):
> self._test_roundtrip(self.test_string1, self.test_string2)
tests/test_pack.py:184:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
base = b'The answer was flailing in the wind'
target = b'The answer was falling down the pipe'
def _test_roundtrip(self, base, target):
self.assertEqual(
> target, b"".join(apply_delta(base, list(create_delta(base, target))))
)
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:174: TypeError
test_pack.py::TestPackDeltas::test_dest_overflow
test_pack.py::TestPackDeltas::test_dest_overflow
self =
def test_dest_overflow(self):
> self.assertRaises(
ApplyDeltaError,
apply_delta,
b"a" * 0x10000,
b"\x80\x80\x04\x80\x80\x04\x80" + b"a" * 0x10000,
)
E AssertionError: ApplyDeltaError not raised by apply_delta
tests/test_pack.py:202: AssertionError
test_pack.py::TestPackDeltas::test_empty_to_big
test_pack.py::TestPackDeltas::test_empty_to_big
self =
def test_empty_to_big(self):
> self._test_roundtrip(self.test_string_empty, self.test_string_big)
tests/test_pack.py:190:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , base = b''
target = b'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'
def _test_roundtrip(self, base, target):
self.assertEqual(
> target, b"".join(apply_delta(base, list(create_delta(base, target))))
)
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:174: TypeError
test_pack.py::TestPackDeltas::test_empty_to_huge
test_pack.py::TestPackDeltas::test_empty_to_huge
self =
def test_empty_to_huge(self):
> self._test_roundtrip(self.test_string_empty, self.test_string_huge)
tests/test_pack.py:193:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
base = b''
target = b'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'
def _test_roundtrip(self, base, target):
self.assertEqual(
> target, b"".join(apply_delta(base, list(create_delta(base, target))))
)
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:174: TypeError
test_pack.py::TestPackDeltas::test_huge_copy
test_pack.py::TestPackDeltas::test_huge_copy
self =
def test_huge_copy(self):
> self._test_roundtrip(
self.test_string_huge + self.test_string1,
self.test_string_huge + self.test_string2,
)
tests/test_pack.py:196:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
base = b'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZThe answer was flailing in the wind'
target = b'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZThe answer was falling down the pipe'
def _test_roundtrip(self, base, target):
self.assertEqual(
> target, b"".join(apply_delta(base, list(create_delta(base, target))))
)
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:174: TypeError
test_pack.py::TestPackDeltas::test_nochange
test_pack.py::TestPackDeltas::test_nochange
self =
def test_nochange(self):
> self._test_roundtrip(self.test_string1, self.test_string1)
tests/test_pack.py:178:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
base = b'The answer was flailing in the wind'
target = b'The answer was flailing in the wind'
def _test_roundtrip(self, base, target):
self.assertEqual(
> target, b"".join(apply_delta(base, list(create_delta(base, target))))
)
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:174: TypeError
test_pack.py::TestPackDeltas::test_nochange_huge
test_pack.py::TestPackDeltas::test_nochange_huge
self =
def test_nochange_huge(self):
> self._test_roundtrip(self.test_string_huge, self.test_string_huge)
tests/test_pack.py:181:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
base = b'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'
target = b'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'
def _test_roundtrip(self, base, target):
self.assertEqual(
> target, b"".join(apply_delta(base, list(create_delta(base, target))))
)
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:174: TypeError
test_pack.py::TestPackDeltas::test_pypy_issue
test_pack.py::TestPackDeltas::test_pypy_issue
self =
def test_pypy_issue(self):
# Test for https://github.com/jelmer/dulwich/issues/509 /
# https://bitbucket.org/pypy/pypy/issues/2499/cpyext-pystring_asstring-doesnt-work
chunks = [
b"tree 03207ccf58880a748188836155ceed72f03d65d6\n"
b"parent 408fbab530fd4abe49249a636a10f10f44d07a21\n"
b"author Victor Stinner "
b"1421355207 +0100\n"
b"committer Victor Stinner "
b"1421355207 +0100\n"
b"\n"
b"Backout changeset 3a06020af8cf\n"
b"\nStreamWriter: close() now clears the reference to the "
b"transport\n"
b"\nStreamWriter now raises an exception if it is closed: "
b"write(), writelines(),\n"
b"write_eof(), can_write_eof(), get_extra_info(), drain().\n"
]
delta = [
b"\xcd\x03\xad\x03]tree ff3c181a393d5a7270cddc01ea863818a8621ca8\n"
b"parent 20a103cc90135494162e819f98d0edfc1f1fba6b\x91]7\x0510738"
b"\x91\x99@\x0b10738 +0100\x93\x04\x01\xc9"
]
res = apply_delta(chunks, delta)
expected = [
b"tree ff3c181a393d5a7270cddc01ea863818a8621ca8\n"
b"parent 20a103cc90135494162e819f98d0edfc1f1fba6b",
b"\nauthor Victor Stinner 14213",
b"10738",
b" +0100\ncommitter Victor Stinner " b"14213",
b"10738 +0100",
b"\n\nStreamWriter: close() now clears the reference to the "
b"transport\n\n"
b"StreamWriter now raises an exception if it is closed: "
b"write(), writelines(),\n"
b"write_eof(), can_write_eof(), get_extra_info(), drain().\n",
]
> self.assertEqual(b"".join(expected), b"".join(res))
E TypeError: can only join an iterable
tests/test_pack.py:249: TypeError
test_pack.py::TestPackDeltas::test_rewrite
test_pack.py::TestPackDeltas::test_rewrite
self =
def test_rewrite(self):
> self._test_roundtrip(self.test_string1, self.test_string3)
tests/test_pack.py:187:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
base = b'The answer was flailing in the wind', target = b'zzzzz'
def _test_roundtrip(self, base, target):
self.assertEqual(
> target, b"".join(apply_delta(base, list(create_delta(base, target))))
)
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:174: TypeError
test_pack.py::TestPackData::test_compute_file_sha
test_pack.py::TestPackData::test_compute_file_sha
self =
def test_compute_file_sha(self):
f = BytesIO(b"abcd1234wxyz")
self.assertEqual(
> sha1(b"abcd1234wxyz").hexdigest(), compute_file_sha(f).hexdigest()
)
E AttributeError: 'NoneType' object has no attribute 'hexdigest'
tests/test_pack.py:356: AttributeError
test_pack.py::TestPackData::test_compute_file_sha_short_file
test_pack.py::TestPackData::test_compute_file_sha_short_file
self =
def test_compute_file_sha_short_file(self):
f = BytesIO(b"abcd1234wxyz")
> self.assertRaises(AssertionError, compute_file_sha, f, end_ofs=-20)
E AssertionError: AssertionError not raised by compute_file_sha
tests/test_pack.py:377: AssertionError
test_pack.py::TestPackData::test_create_index_v1
test_pack.py::TestPackData::test_create_index_v1
self =
def test_create_index_v1(self):
> with self.get_pack_data(pack1_sha) as p:
tests/test_pack.py:336:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:94: in get_pack_data
return PackData(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481.pack'
file = None, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E AttributeError: 'NoneType' object has no attribute 'read'
dulwich/pack.py:751: AttributeError
test_pack.py::TestPackData::test_create_index_v2
test_pack.py::TestPackData::test_create_index_v2
self =
def test_create_index_v2(self):
> with self.get_pack_data(pack1_sha) as p:
tests/test_pack.py:345:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:94: in get_pack_data
return PackData(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481.pack'
file = None, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E AttributeError: 'NoneType' object has no attribute 'read'
dulwich/pack.py:751: AttributeError
test_pack.py::TestPackData::test_create_pack
test_pack.py::TestPackData::test_create_pack
self =
def test_create_pack(self):
> self.get_pack_data(pack1_sha).close()
tests/test_pack.py:256:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:94: in get_pack_data
return PackData(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481.pack'
file = None, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E AttributeError: 'NoneType' object has no attribute 'read'
dulwich/pack.py:751: AttributeError
test_pack.py::TestPackData::test_from_file
test_pack.py::TestPackData::test_from_file
self =
def test_from_file(self):
path = os.path.join(
self.datadir, "pack-{}.pack".format(pack1_sha.decode("ascii"))
)
with open(path, "rb") as f:
> PackData.from_file(f, os.path.getsize(path))
E AttributeError: type object 'PackData' has no attribute 'from_file'
tests/test_pack.py:263: AttributeError
test_pack.py::TestPackData::test_index_check
test_pack.py::TestPackData::test_index_check
self =
def test_index_check(self):
> with self.get_pack_data(pack1_sha) as p:
tests/test_pack.py:270:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:94: in get_pack_data
return PackData(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481.pack'
file = None, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E AttributeError: 'NoneType' object has no attribute 'read'
dulwich/pack.py:751: AttributeError
test_pack.py::TestPackData::test_iter_unpacked
test_pack.py::TestPackData::test_iter_unpacked
self =
def test_iter_unpacked(self):
> with self.get_pack_data(pack1_sha) as p:
tests/test_pack.py:274:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:94: in get_pack_data
return PackData(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481.pack'
file = None, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E AttributeError: 'NoneType' object has no attribute 'read'
dulwich/pack.py:751: AttributeError
test_pack.py::TestPackData::test_iterentries
test_pack.py::TestPackData::test_iterentries
self =
def test_iterentries(self):
> with self.get_pack_data(pack1_sha) as p:
tests/test_pack.py:312:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:94: in get_pack_data
return PackData(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481.pack'
file = None, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E AttributeError: 'NoneType' object has no attribute 'read'
dulwich/pack.py:751: AttributeError
test_pack.py::TestPackData::test_pack_len
test_pack.py::TestPackData::test_pack_len
self =
def test_pack_len(self):
> with self.get_pack_data(pack1_sha) as p:
tests/test_pack.py:266:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:94: in get_pack_data
return PackData(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481.pack'
file = None, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E AttributeError: 'NoneType' object has no attribute 'read'
dulwich/pack.py:751: AttributeError
test_pack.py::TestPack::test_checksum_mismatch
test_pack.py::TestPack::test_checksum_mismatch
self =
def test_checksum_mismatch(self):
> with self.get_pack_data(pack1_sha) as data:
tests/test_pack.py:508:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:94: in get_pack_data
return PackData(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481.pack'
file = None, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E AttributeError: 'NoneType' object has no attribute 'read'
dulwich/pack.py:751: AttributeError
test_pack.py::TestPack::test_commit_obj
test_pack.py::TestPack::test_commit_obj
self =
def test_commit_obj(self):
with self.get_pack(pack1_sha) as p:
> commit = p[commit_sha]
tests/test_pack.py:449:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
sha1 = b'f18faa16531ac570a3fdc8c7ca16682548dafd12'
def __getitem__(self, sha1: bytes) -> ShaFile:
"""Retrieve the specified SHA1."""
> type, uncomp = self.get_raw(sha1)
E AttributeError: 'Pack' object has no attribute 'get_raw'. Did you mean: 'get_ref'?
dulwich/pack.py:1188: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_commit_obj(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:448:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'Pack' object has no attribute 'get_raw'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_contains
test_pack.py::TestPack::test_contains
self =
def test_contains(self):
with self.get_pack(pack1_sha) as p:
> self.assertIn(tree_sha, p)
tests/test_pack.py:391:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
sha1 = b'b2a2766a2879c209ab1176e7e778b81ae422eeaa'
def __contains__(self, sha1: bytes) -> bool:
"""Check whether this pack contains a particular SHA1."""
try:
> self.index.object_offset(sha1)
E AttributeError: 'NoneType' object has no attribute 'object_offset'
dulwich/pack.py:1181: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_contains(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:390:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'NoneType' object has no attribute 'object_offset'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_copy
test_pack.py::TestPack::test_copy
self =
def test_copy(self):
with self.get_pack(pack1_sha) as origpack:
> self.assertSucceeds(origpack.index.check)
E AttributeError: 'NoneType' object has no attribute 'check'
tests/test_pack.py:429: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_copy(self):
> with self.get_pack(pack1_sha) as origpack:
tests/test_pack.py:428:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'NoneType' object has no attribute 'check'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_get
test_pack.py::TestPack::test_get
self =
def test_get(self):
with self.get_pack(pack1_sha) as p:
> self.assertEqual(type(p[tree_sha]), Tree)
tests/test_pack.py:395:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
sha1 = b'b2a2766a2879c209ab1176e7e778b81ae422eeaa'
def __getitem__(self, sha1: bytes) -> ShaFile:
"""Retrieve the specified SHA1."""
> type, uncomp = self.get_raw(sha1)
E AttributeError: 'Pack' object has no attribute 'get_raw'. Did you mean: 'get_ref'?
dulwich/pack.py:1188: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_get(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:394:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'Pack' object has no attribute 'get_raw'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_get_object_at
test_pack.py::TestPack::test_get_object_at
self =
def test_get_object_at(self):
"""Tests random access for non-delta objects."""
with self.get_pack(pack1_sha) as p:
> obj = p[a_sha]
tests/test_pack.py:417:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
sha1 = b'6f670c0fb53f9463760b7295fbb814e965fb20c8'
def __getitem__(self, sha1: bytes) -> ShaFile:
"""Retrieve the specified SHA1."""
> type, uncomp = self.get_raw(sha1)
E AttributeError: 'Pack' object has no attribute 'get_raw'. Did you mean: 'get_ref'?
dulwich/pack.py:1188: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_get_object_at(self):
"""Tests random access for non-delta objects."""
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:416:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'Pack' object has no attribute 'get_raw'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_iter
test_pack.py::TestPack::test_iter
self =
def test_iter(self):
with self.get_pack(pack1_sha) as p:
> self.assertEqual({tree_sha, commit_sha, a_sha}, set(p))
tests/test_pack.py:399:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
def __iter__(self):
"""Iterate over all the sha1s of the objects in this pack."""
> return iter(self.index)
E TypeError: 'NoneType' object is not iterable
dulwich/pack.py:1164: TypeError
During handling of the above exception, another exception occurred:
self =
def test_iter(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:398:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = TypeError("'NoneType' object is not iterable")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_iterobjects
test_pack.py::TestPack::test_iterobjects
self =
def test_iterobjects(self):
with self.get_pack(pack1_sha) as p:
> expected = {p[s] for s in [commit_sha, tree_sha, a_sha]}
tests/test_pack.py:403:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:403: in
expected = {p[s] for s in [commit_sha, tree_sha, a_sha]}
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
sha1 = b'f18faa16531ac570a3fdc8c7ca16682548dafd12'
def __getitem__(self, sha1: bytes) -> ShaFile:
"""Retrieve the specified SHA1."""
> type, uncomp = self.get_raw(sha1)
E AttributeError: 'Pack' object has no attribute 'get_raw'. Did you mean: 'get_ref'?
dulwich/pack.py:1188: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_iterobjects(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:402:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'Pack' object has no attribute 'get_raw'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_iterobjects_2
test_pack.py::TestPack::test_iterobjects_2
self =
def test_iterobjects_2(self):
with self.get_pack(pack1_sha) as p:
> objs = {o.id: o for o in p.iterobjects()}
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:521: TypeError
During handling of the above exception, another exception occurred:
self =
def test_iterobjects_2(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:520:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = TypeError("'NoneType' object is not iterable")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_iterobjects_subset
test_pack.py::TestPack::test_iterobjects_subset
self =
def test_iterobjects_subset(self):
with self.get_pack(pack1_sha) as p:
> objs = {o.id: o for o in p.iterobjects_subset([commit_sha])}
E AttributeError: 'Pack' object has no attribute 'iterobjects_subset'
tests/test_pack.py:530: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_iterobjects_subset(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:529:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'Pack' object has no attribute 'iterobjects_subset'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_keep_message
test_pack.py::TestPack::test_keep_message
self =
def test_keep_message(self):
with self.get_pack(pack1_sha) as p:
> p = self._copy_pack(p)
tests/test_pack.py:474:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
origpack = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
def _copy_pack(self, origpack):
basename = os.path.join(self.tempdir, "somepack")
> write_pack(basename, origpack.pack_tuples())
E AttributeError: 'Pack' object has no attribute 'pack_tuples'
tests/test_pack.py:455: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_keep_message(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:473:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'Pack' object has no attribute 'pack_tuples'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_keep_no_message
test_pack.py::TestPack::test_keep_no_message
self =
def test_keep_no_message(self):
with self.get_pack(pack1_sha) as p:
> p = self._copy_pack(p)
tests/test_pack.py:460:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
origpack = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
def _copy_pack(self, origpack):
basename = os.path.join(self.tempdir, "somepack")
> write_pack(basename, origpack.pack_tuples())
E AttributeError: 'Pack' object has no attribute 'pack_tuples'
tests/test_pack.py:455: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_keep_no_message(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:459:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'Pack' object has no attribute 'pack_tuples'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_len
test_pack.py::TestPack::test_len
self =
def test_len(self):
with self.get_pack(pack1_sha) as p:
> self.assertEqual(3, len(p))
tests/test_pack.py:387:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
def __len__(self) -> int:
"""Number of entries in this pack."""
> return len(self.index)
E TypeError: object of type 'NoneType' has no len()
dulwich/pack.py:1157: TypeError
During handling of the above exception, another exception occurred:
self =
def test_len(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:386:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = TypeError("object of type 'NoneType' has no len()")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_length_mismatch
test_pack.py::TestPack::test_length_mismatch
self =
def test_length_mismatch(self):
> with self.get_pack_data(pack1_sha) as data:
tests/test_pack.py:493:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:94: in get_pack_data
return PackData(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481.pack'
file = None, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E AttributeError: 'NoneType' object has no attribute 'read'
dulwich/pack.py:751: AttributeError
test_pack.py::TestPack::test_name
test_pack.py::TestPack::test_name
self =
def test_name(self):
with self.get_pack(pack1_sha) as p:
> self.assertEqual(pack1_sha, p.name())
E AssertionError: b'bc63ddad95e7321ee734ea11a7a62d314e0d7481' != None
tests/test_pack.py:490: AssertionError
During handling of the above exception, another exception occurred:
self =
def test_name(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AssertionError("b'bc63ddad95e7321ee734ea11a7a62d314e0d7481' != None")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestPack::test_pack_tuples
test_pack.py::TestPack::test_pack_tuples
self =
def test_pack_tuples(self):
with self.get_pack(pack1_sha) as p:
> tuples = p.pack_tuples()
E AttributeError: 'Pack' object has no attribute 'pack_tuples'
tests/test_pack.py:408: AttributeError
During handling of the above exception, another exception occurred:
self =
def test_pack_tuples(self):
> with self.get_pack(pack1_sha) as p:
tests/test_pack.py:407:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Pack('/testbed/testdata/packs/pack-bc63ddad95e7321ee734ea11a7a62d314e0d7481')
exc_type =
exc_val = AttributeError("'Pack' object has no attribute 'pack_tuples'")
exc_tb =
def __exit__(self, exc_type, exc_val, exc_tb):
> self.close()
E AttributeError: 'Pack' object has no attribute 'close'
dulwich/pack.py:1150: AttributeError
test_pack.py::TestThinPack::test_get_raw
test_pack.py::TestThinPack::test_get_raw
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
self.blobs = {}
for blob in (b"foo", b"bar", b"foo1234", b"bar2468"):
self.blobs[blob] = make_object(Blob, data=blob)
self.store.add_object(self.blobs[b"foo"])
self.store.add_object(self.blobs[b"bar"])
# Build a thin pack. 'foo' is as an external reference, 'bar' an
# internal reference.
self.pack_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.pack_dir)
self.pack_prefix = os.path.join(self.pack_dir, "pack")
with open(self.pack_prefix + ".pack", "wb") as f:
build_pack(
f,
[
> (REF_DELTA, (self.blobs[b"foo"].id, b"foo1234")),
(Blob.type_num, b"bar"),
(REF_DELTA, (self.blobs[b"bar"].id, b"bar2468")),
],
store=self.store,
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:555: AttributeError
test_pack.py::TestThinPack::test_get_unpacked_object
test_pack.py::TestThinPack::test_get_unpacked_object
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
self.blobs = {}
for blob in (b"foo", b"bar", b"foo1234", b"bar2468"):
self.blobs[blob] = make_object(Blob, data=blob)
self.store.add_object(self.blobs[b"foo"])
self.store.add_object(self.blobs[b"bar"])
# Build a thin pack. 'foo' is as an external reference, 'bar' an
# internal reference.
self.pack_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.pack_dir)
self.pack_prefix = os.path.join(self.pack_dir, "pack")
with open(self.pack_prefix + ".pack", "wb") as f:
build_pack(
f,
[
> (REF_DELTA, (self.blobs[b"foo"].id, b"foo1234")),
(Blob.type_num, b"bar"),
(REF_DELTA, (self.blobs[b"bar"].id, b"bar2468")),
],
store=self.store,
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:555: AttributeError
test_pack.py::TestThinPack::test_iterobjects
test_pack.py::TestThinPack::test_iterobjects
self =
def setUp(self):
super().setUp()
self.store = MemoryObjectStore()
self.blobs = {}
for blob in (b"foo", b"bar", b"foo1234", b"bar2468"):
self.blobs[blob] = make_object(Blob, data=blob)
self.store.add_object(self.blobs[b"foo"])
self.store.add_object(self.blobs[b"bar"])
# Build a thin pack. 'foo' is as an external reference, 'bar' an
# internal reference.
self.pack_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.pack_dir)
self.pack_prefix = os.path.join(self.pack_dir, "pack")
with open(self.pack_prefix + ".pack", "wb") as f:
build_pack(
f,
[
> (REF_DELTA, (self.blobs[b"foo"].id, b"foo1234")),
(Blob.type_num, b"bar"),
(REF_DELTA, (self.blobs[b"bar"].id, b"bar2468")),
],
store=self.store,
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:555: AttributeError
test_pack.py::WritePackTests::test_write_pack_header
self =
def test_write_pack_header(self):
f = BytesIO()
write_pack_header(f.write, 42)
> self.assertEqual(b"PACK\x00\x00\x00\x02\x00\x00\x00*", f.getvalue())
E AssertionError: b'PACK\x00\x00\x00\x02\x00\x00\x00*' != b''
tests/test_pack.py:627: AssertionError
test_pack.py::WritePackTests::test_write_pack_object
test_pack.py::WritePackTests::test_write_pack_object
self =
def test_write_pack_object(self):
f = BytesIO()
f.write(b"header")
offset = f.tell()
crc32 = write_pack_object(f.write, Blob.type_num, b"blob")
> self.assertEqual(crc32, zlib.crc32(f.getvalue()[6:]) & 0xFFFFFFFF)
E AssertionError: None != 0
tests/test_pack.py:634: AssertionError
test_pack.py::WritePackTests::test_write_pack_object_compression_level
test_pack.py::WritePackTests::test_write_pack_object_compression_level
self =
def test_write_pack_object_compression_level(self):
f = BytesIO()
f.write(b"header")
offset = f.tell()
sha_a = sha1(b"foo")
sha_b = sha_a.copy()
write_pack_object(
f.write, Blob.type_num, b"blob", sha=sha_a, compression_level=6
)
> self.assertNotEqual(sha_a.digest(), sha_b.digest())
E AssertionError: b'\x0b\xee\xc7\xb5\xea?\x0f\xdb\xc9]\r\xd4\x7f<[\xc2u\xda\x8a3' == b'\x0b\xee\xc7\xb5\xea?\x0f\xdb\xc9]\r\xd4\x7f<[\xc2u\xda\x8a3'
tests/test_pack.py:665: AssertionError
test_pack.py::WritePackTests::test_write_pack_object_sha
test_pack.py::WritePackTests::test_write_pack_object_sha
self =
def test_write_pack_object_sha(self):
f = BytesIO()
f.write(b"header")
offset = f.tell()
sha_a = sha1(b"foo")
sha_b = sha_a.copy()
write_pack_object(f.write, Blob.type_num, b"blob", sha=sha_a)
> self.assertNotEqual(sha_a.digest(), sha_b.digest())
E AssertionError: b'\x0b\xee\xc7\xb5\xea?\x0f\xdb\xc9]\r\xd4\x7f<[\xc2u\xda\x8a3' == b'\x0b\xee\xc7\xb5\xea?\x0f\xdb\xc9]\r\xd4\x7f<[\xc2u\xda\x8a3'
tests/test_pack.py:652: AssertionError
test_pack.py::TestMemoryIndexWriting::test_empty
test_pack.py::TestMemoryIndexWriting::test_empty
self =
def test_empty(self):
idx = self.index("empty.idx", [], pack_checksum)
> self.assertEqual(idx.get_pack_checksum(), pack_checksum)
E AssertionError: None != b'r\x19\x80\xe8f\xaf\x9a_\x93\xadgAD\xe1E\x9b\x8b\xa3\xe7\xb7'
tests/test_pack.py:685: AssertionError
test_pack.py::TestMemoryIndexWriting::test_large
test_pack.py::TestMemoryIndexWriting::test_large
self =
def test_large(self):
entry1_sha = hex_to_sha("4e6388232ec39792661e2e75db8fb117fc869ce6")
entry2_sha = hex_to_sha("e98f071751bd77f59967bfa671cd2caebdccc9a2")
entries = [
(entry1_sha, 0xF2972D0830529B87, 24),
(entry2_sha, (~0xF2972D0830529B87) & (2**64 - 1), 92),
]
if not self._supports_large:
self.assertRaises(
TypeError, self.index, "single.idx", entries, pack_checksum
)
return
idx = self.index("single.idx", entries, pack_checksum)
> self.assertEqual(idx.get_pack_checksum(), pack_checksum)
E AssertionError: None != b'r\x19\x80\xe8f\xaf\x9a_\x93\xadgAD\xe1E\x9b\x8b\xa3\xe7\xb7'
tests/test_pack.py:701: AssertionError
test_pack.py::TestMemoryIndexWriting::test_single
test_pack.py::TestMemoryIndexWriting::test_single
self =
def test_single(self):
entry_sha = hex_to_sha("6f670c0fb53f9463760b7295fbb814e965fb20c8")
my_entries = [(entry_sha, 178, 42)]
idx = self.index("single.idx", my_entries, pack_checksum)
> self.assertEqual(idx.get_pack_checksum(), pack_checksum)
E AssertionError: None != b'r\x19\x80\xe8f\xaf\x9a_\x93\xadgAD\xe1E\x9b\x8b\xa3\xe7\xb7'
tests/test_pack.py:719: AssertionError
test_pack.py::TestPackIndexWritingv1::test_empty
test_pack.py::TestPackIndexWritingv1::test_empty
self =
def test_empty(self):
> idx = self.index("empty.idx", [], pack_checksum)
tests/test_pack.py:684:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:743: in index
self.writeIndex(path, entries, pack_checksum)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/tmp/tmpcif8veg5/empty.idx', entries = []
pack_checksum = b'r\x19\x80\xe8f\xaf\x9a_\x93\xadgAD\xe1E\x9b\x8b\xa3\xe7\xb7'
def writeIndex(self, filename, entries, pack_checksum):
# FIXME: Write to BytesIO instead rather than hitting disk ?
> with GitFile(filename, "wb") as f:
E AttributeError: __enter__
tests/test_pack.py:751: AttributeError
test_pack.py::TestPackIndexWritingv1::test_large
test_pack.py::TestPackIndexWritingv1::test_large
self =
def test_large(self):
entry1_sha = hex_to_sha("4e6388232ec39792661e2e75db8fb117fc869ce6")
entry2_sha = hex_to_sha("e98f071751bd77f59967bfa671cd2caebdccc9a2")
entries = [
(entry1_sha, 0xF2972D0830529B87, 24),
(entry2_sha, (~0xF2972D0830529B87) & (2**64 - 1), 92),
]
if not self._supports_large:
> self.assertRaises(
TypeError, self.index, "single.idx", entries, pack_checksum
)
tests/test_pack.py:696:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:743: in index
self.writeIndex(path, entries, pack_checksum)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def writeIndex(self, filename, entries, pack_checksum):
# FIXME: Write to BytesIO instead rather than hitting disk ?
> with GitFile(filename, "wb") as f:
E AttributeError: __enter__
tests/test_pack.py:751: AttributeError
test_pack.py::TestPackIndexWritingv1::test_single
test_pack.py::TestPackIndexWritingv1::test_single
self =
def test_single(self):
entry_sha = hex_to_sha("6f670c0fb53f9463760b7295fbb814e965fb20c8")
my_entries = [(entry_sha, 178, 42)]
> idx = self.index("single.idx", my_entries, pack_checksum)
tests/test_pack.py:718:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:743: in index
self.writeIndex(path, entries, pack_checksum)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/tmp/tmpyni9s21q/single.idx'
entries = [(b'og\x0c\x0f\xb5?\x94cv\x0br\x95\xfb\xb8\x14\xe9e\xfb \xc8', 178, 42)]
pack_checksum = b'r\x19\x80\xe8f\xaf\x9a_\x93\xadgAD\xe1E\x9b\x8b\xa3\xe7\xb7'
def writeIndex(self, filename, entries, pack_checksum):
# FIXME: Write to BytesIO instead rather than hitting disk ?
> with GitFile(filename, "wb") as f:
E AttributeError: __enter__
tests/test_pack.py:751: AttributeError
test_pack.py::TestPackIndexWritingv2::test_empty
test_pack.py::TestPackIndexWritingv2::test_empty
self =
def test_empty(self):
> idx = self.index("empty.idx", [], pack_checksum)
tests/test_pack.py:684:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:743: in index
self.writeIndex(path, entries, pack_checksum)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/tmp/tmpotdabuwy/empty.idx', entries = []
pack_checksum = b'r\x19\x80\xe8f\xaf\x9a_\x93\xadgAD\xe1E\x9b\x8b\xa3\xe7\xb7'
def writeIndex(self, filename, entries, pack_checksum):
# FIXME: Write to BytesIO instead rather than hitting disk ?
> with GitFile(filename, "wb") as f:
E AttributeError: __enter__
tests/test_pack.py:751: AttributeError
test_pack.py::TestPackIndexWritingv2::test_large
test_pack.py::TestPackIndexWritingv2::test_large
self =
def test_large(self):
entry1_sha = hex_to_sha("4e6388232ec39792661e2e75db8fb117fc869ce6")
entry2_sha = hex_to_sha("e98f071751bd77f59967bfa671cd2caebdccc9a2")
entries = [
(entry1_sha, 0xF2972D0830529B87, 24),
(entry2_sha, (~0xF2972D0830529B87) & (2**64 - 1), 92),
]
if not self._supports_large:
self.assertRaises(
TypeError, self.index, "single.idx", entries, pack_checksum
)
return
> idx = self.index("single.idx", entries, pack_checksum)
tests/test_pack.py:700:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:743: in index
self.writeIndex(path, entries, pack_checksum)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/tmp/tmpknxyyt3q/single.idx'
entries = [(b'Nc\x88#.\xc3\x97\x92f\x1e.u\xdb\x8f\xb1\x17\xfc\x86\x9c\xe6', 17480489991855577991, 24), (b'\xe9\x8f\x07\x17Q\xbdw\xf5\x99g\xbf\xa6q\xcd,\xae\xbd\xcc\xc9\xa2', 966254081853973624, 92)]
pack_checksum = b'r\x19\x80\xe8f\xaf\x9a_\x93\xadgAD\xe1E\x9b\x8b\xa3\xe7\xb7'
def writeIndex(self, filename, entries, pack_checksum):
# FIXME: Write to BytesIO instead rather than hitting disk ?
> with GitFile(filename, "wb") as f:
E AttributeError: __enter__
tests/test_pack.py:751: AttributeError
test_pack.py::TestPackIndexWritingv2::test_single
test_pack.py::TestPackIndexWritingv2::test_single
self =
def test_single(self):
entry_sha = hex_to_sha("6f670c0fb53f9463760b7295fbb814e965fb20c8")
my_entries = [(entry_sha, 178, 42)]
> idx = self.index("single.idx", my_entries, pack_checksum)
tests/test_pack.py:718:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:743: in index
self.writeIndex(path, entries, pack_checksum)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
filename = '/tmp/tmps8952rdl/single.idx'
entries = [(b'og\x0c\x0f\xb5?\x94cv\x0br\x95\xfb\xb8\x14\xe9e\xfb \xc8', 178, 42)]
pack_checksum = b'r\x19\x80\xe8f\xaf\x9a_\x93\xadgAD\xe1E\x9b\x8b\xa3\xe7\xb7'
def writeIndex(self, filename, entries, pack_checksum):
# FIXME: Write to BytesIO instead rather than hitting disk ?
> with GitFile(filename, "wb") as f:
E AttributeError: __enter__
tests/test_pack.py:751: AttributeError
test_pack.py::ReadZlibTests::test_decompress_buffer_size_1
test_pack.py::ReadZlibTests::test_decompress_buffer_size_1
self =
def test_decompress_buffer_size_1(self):
> self._do_decompress_test(1)
tests/test_pack.py:861:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:850: in _do_decompress_test
self.assertEqual(zlib.crc32(self.comp), self.unpacked.crc32)
E AssertionError: 583396265 != 3609230709
test_pack.py::ReadZlibTests::test_decompress_buffer_size_2
test_pack.py::ReadZlibTests::test_decompress_buffer_size_2
self =
def test_decompress_buffer_size_2(self):
> self._do_decompress_test(2)
tests/test_pack.py:864:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:850: in _do_decompress_test
self.assertEqual(zlib.crc32(self.comp), self.unpacked.crc32)
E AssertionError: 583396265 != 3479363476
test_pack.py::ReadZlibTests::test_decompress_buffer_size_3
test_pack.py::ReadZlibTests::test_decompress_buffer_size_3
self =
def test_decompress_buffer_size_3(self):
> self._do_decompress_test(3)
tests/test_pack.py:867:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:850: in _do_decompress_test
self.assertEqual(zlib.crc32(self.comp), self.unpacked.crc32)
E AssertionError: 583396265 != 3204038867
test_pack.py::ReadZlibTests::test_decompress_buffer_size_4
test_pack.py::ReadZlibTests::test_decompress_buffer_size_4
self =
def test_decompress_buffer_size_4(self):
> self._do_decompress_test(4)
tests/test_pack.py:870:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:850: in _do_decompress_test
self.assertEqual(zlib.crc32(self.comp), self.unpacked.crc32)
E AssertionError: 583396265 != 3242514680
test_pack.py::ReadZlibTests::test_decompress_include_comp
test_pack.py::ReadZlibTests::test_decompress_include_comp
self =
def test_decompress_include_comp(self):
> self._do_decompress_test(4096, include_comp=True)
tests/test_pack.py:873:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:850: in _do_decompress_test
self.assertEqual(zlib.crc32(self.comp), self.unpacked.crc32)
E AssertionError: 583396265 != 1633924910
test_pack.py::ReadZlibTests::test_decompress_size
test_pack.py::ReadZlibTests::test_decompress_size
self =
def test_decompress_size(self):
good_decomp_len = len(self.decomp)
self.unpacked.decomp_len = -1
> self.assertRaises(ValueError, read_zlib_chunks, self.read, self.unpacked)
E AssertionError: ValueError not raised by read_zlib_chunks
tests/test_pack.py:818: AssertionError
test_pack.py::ReadZlibTests::test_decompress_truncated
test_pack.py::ReadZlibTests::test_decompress_truncated
self =
def test_decompress_truncated(self):
read = BytesIO(self.comp[:10]).read
> self.assertRaises(zlib.error, read_zlib_chunks, read, self.unpacked)
tests/test_pack.py:826:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def read_zlib_chunks(read_some: Callable[[int], bytes], unpacked: UnpackedObject, include_comp: bool=False, buffer_size: int=_ZLIB_BUFSIZE) -> bytes:
"""Read zlib data from a buffer.
This function requires that the buffer have additional data following the
compressed data, which is guaranteed to be the case for git pack files.
Args:
read_some: Read function that returns at least one byte, but may
return less than the requested size.
unpacked: An UnpackedObject to write result data to. If its crc32
attr is not None, the CRC32 of the compressed bytes will be computed
using this starting CRC32.
After this function, will have the following attrs set:
* comp_chunks (if include_comp is True)
* decomp_chunks
* decomp_len
* crc32
include_comp: If True, include compressed data in the result.
buffer_size: Size of the read buffer.
Returns: Leftover unused data from the decompression.
Raises:
zlib.error: if a decompression error occurred.
"""
if include_comp:
comp_chunks = []
unpacked.comp_chunks = comp_chunks
else:
comp_chunks = None
decomp_chunks = unpacked.decomp_chunks
decomp_len = 0
crc32 = unpacked.crc32
# Start streaming the data to zlib
d = zlib.decompressobj()
while True:
add_data = read_some(buffer_size)
if not add_data:
break
if comp_chunks is not None:
comp_chunks.append(add_data)
if crc32 is not None:
crc32 = zlib.crc32(add_data, crc32)
decomp = d.decompress(add_data)
decomp_len += len(decomp)
decomp_chunks.append(decomp)
if d.unused_data:
leftover = d.unused_data
if comp_chunks is not None:
comp_chunks[-1] = add_data[:-len(leftover)]
if crc32 is not None:
crc32 = zlib.crc32(add_data[:-len(leftover)], crc32)
break
else:
leftover = b''
unpacked.decomp_len = decomp_len
unpacked.crc32 = crc32
> return leftover
E UnboundLocalError: local variable 'leftover' referenced before assignment
dulwich/pack.py:281: UnboundLocalError
test_pack.py::ReadZlibTests::test_simple_decompress
test_pack.py::ReadZlibTests::test_simple_decompress
self =
def test_simple_decompress(self):
> self._do_decompress_test(4096)
tests/test_pack.py:855:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:850: in _do_decompress_test
self.assertEqual(zlib.crc32(self.comp), self.unpacked.crc32)
E AssertionError: 583396265 != 1633924910
test_pack.py::DeltifyTests::test_empty
test_pack.py::DeltifyTests::test_empty
self =
def test_empty(self):
> self.assertEqual([], list(deltify_pack_objects([])))
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:879: TypeError
test_pack.py::DeltifyTests::test_simple_delta
test_pack.py::DeltifyTests::test_simple_delta
self =
def test_simple_delta(self):
b1 = Blob.from_string(b"a" * 101)
b2 = Blob.from_string(b"a" * 100)
> delta = list(create_delta(b1.as_raw_chunks(), b2.as_raw_chunks()))
E AttributeError: 'NoneType' object has no attribute 'as_raw_chunks'
tests/test_pack.py:898: AttributeError
test_pack.py::DeltifyTests::test_single
test_pack.py::DeltifyTests::test_single
self =
def test_single(self):
b = Blob.from_string(b"foo")
self.assertEqual(
[
UnpackedObject(
> b.type_num,
sha=b.sha().digest(),
delta_base=None,
decomp_chunks=b.as_raw_chunks(),
)
],
list(deltify_pack_objects([(b, b"")])),
)
E AttributeError: 'NoneType' object has no attribute 'type_num'
tests/test_pack.py:886: AttributeError
test_pack.py::TestPackStreamReader::test_read_objects
test_pack.py::TestPackStreamReader::test_read_objects
self =
def test_read_objects(self):
f = BytesIO()
entries = build_pack(
f,
[
(Blob.type_num, b"blob"),
(OFS_DELTA, (0, b"blob1")),
],
)
reader = PackStreamReader(f.read)
> objects = list(reader.read_objects(compute_crc32=True))
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:935: TypeError
test_pack.py::TestPackStreamReader::test_read_objects_buffered
test_pack.py::TestPackStreamReader::test_read_objects_buffered
self =
def test_read_objects_buffered(self):
f = BytesIO()
build_pack(
f,
[
(Blob.type_num, b"blob"),
(OFS_DELTA, (0, b"blob1")),
],
)
reader = PackStreamReader(f.read, zlib_bufsize=4)
> self.assertEqual(2, len(list(reader.read_objects())))
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:968: TypeError
test_pack.py::TestPackStreamReader::test_read_objects_empty
test_pack.py::TestPackStreamReader::test_read_objects_empty
self =
def test_read_objects_empty(self):
reader = PackStreamReader(BytesIO().read)
> self.assertRaises(AssertionError, list, reader.read_objects())
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:972: TypeError
test_pack.py::TestPackStreamReader::test_read_objects_emtpy
test_pack.py::TestPackStreamReader::test_read_objects_emtpy
self =
def test_read_objects_emtpy(self):
f = BytesIO()
build_pack(f, [])
reader = PackStreamReader(f.read)
> self.assertEqual(0, len(list(reader.read_objects())))
E TypeError: 'NoneType' object is not iterable
tests/test_pack.py:923: TypeError
test_pack.py::DeltaChainIteratorTests::test_bad_ext_ref_non_thin_pack
test_pack.py::DeltaChainIteratorTests::test_bad_ext_ref_non_thin_pack
self =
def test_bad_ext_ref_non_thin_pack(self):
(blob,) = self.store_blobs([b"blob"])
f = BytesIO()
> build_pack(f, [(REF_DELTA, (blob.id, b"blob1"))], store=self.store)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:1257: AttributeError
test_pack.py::DeltaChainIteratorTests::test_bad_ext_ref_thin_pack
test_pack.py::DeltaChainIteratorTests::test_bad_ext_ref_thin_pack
self =
def test_bad_ext_ref_thin_pack(self):
b1, b2, b3 = self.store_blobs([b"foo", b"bar", b"baz"])
f = BytesIO()
build_pack(
f,
[
(REF_DELTA, (1, b"foo99")),
> (REF_DELTA, (b1.id, b"foo1")),
(REF_DELTA, (b2.id, b"bar2")),
(REF_DELTA, (b3.id, b"baz3")),
],
store=self.store,
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:1272: AttributeError
test_pack.py::DeltaChainIteratorTests::test_branchy_chain
test_pack.py::DeltaChainIteratorTests::test_branchy_chain
self =
def test_branchy_chain(self):
n = 100
objects_spec = [(Blob.type_num, b"blob")]
for i in range(n):
objects_spec.append((OFS_DELTA, (0, b"blob" + str(i).encode("ascii"))))
f = BytesIO()
entries = build_pack(f, objects_spec)
# Delta resolution changed to DFS
indices = [0, *list(range(100, 0, -1))]
> self.assertEntriesMatch(indices, entries, self.make_pack_iter(f))
tests/test_pack.py:1179:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:1027: in make_pack_iter
data = PackData("test.pack", file=f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , filename = 'test.pack'
file = <_io.BytesIO object at 0x7eec1eb877e0>, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/pack.py:751: TypeError
test_pack.py::DeltaChainIteratorTests::test_ext_ref
test_pack.py::DeltaChainIteratorTests::test_ext_ref
self =
def test_ext_ref(self):
(blob,) = self.store_blobs([b"blob"])
f = BytesIO()
> entries = build_pack(f, [(REF_DELTA, (blob.id, b"blob1"))], store=self.store)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:1184: AttributeError
test_pack.py::DeltaChainIteratorTests::test_ext_ref_chain
test_pack.py::DeltaChainIteratorTests::test_ext_ref_chain
self =
def test_ext_ref_chain(self):
(blob,) = self.store_blobs([b"blob"])
f = BytesIO()
entries = build_pack(
f,
[
(REF_DELTA, (1, b"blob2")),
> (REF_DELTA, (blob.id, b"blob1")),
],
store=self.store,
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:1196: AttributeError
test_pack.py::DeltaChainIteratorTests::test_ext_ref_chain_degenerate
test_pack.py::DeltaChainIteratorTests::test_ext_ref_chain_degenerate
self =
def test_ext_ref_chain_degenerate(self):
# Test a degenerate case where the sender is sending a REF_DELTA
# object that expands to an object already in the repository.
(blob,) = self.store_blobs([b"blob"])
(blob2,) = self.store_blobs([b"blob2"])
> assert blob.id < blob2.id
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:1209: AttributeError
test_pack.py::DeltaChainIteratorTests::test_ext_ref_deltified_object_based_on_itself
test_pack.py::DeltaChainIteratorTests::test_ext_ref_deltified_object_based_on_itself
self =
def test_ext_ref_deltified_object_based_on_itself(self):
b1_content = b"foo"
(b1,) = self.store_blobs([b1_content])
f = BytesIO()
build_pack(
f,
[
# b1's content refers to bl1's object ID as delta base
> (REF_DELTA, (b1.id, b1_content)),
],
store=self.store,
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:1295: AttributeError
test_pack.py::DeltaChainIteratorTests::test_ext_ref_multiple_times
test_pack.py::DeltaChainIteratorTests::test_ext_ref_multiple_times
self =
def test_ext_ref_multiple_times(self):
(blob,) = self.store_blobs([b"blob"])
f = BytesIO()
entries = build_pack(
f,
[
> (REF_DELTA, (blob.id, b"blob1")),
(REF_DELTA, (blob.id, b"blob2")),
],
store=self.store,
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:1230: AttributeError
test_pack.py::DeltaChainIteratorTests::test_long_chain
test_pack.py::DeltaChainIteratorTests::test_long_chain
self =
def test_long_chain(self):
n = 100
objects_spec = [(Blob.type_num, b"blob")]
for i in range(n):
objects_spec.append((OFS_DELTA, (i, b"blob" + str(i).encode("ascii"))))
f = BytesIO()
entries = build_pack(f, objects_spec)
> self.assertEntriesMatch(range(n + 1), entries, self.make_pack_iter(f))
tests/test_pack.py:1168:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:1027: in make_pack_iter
data = PackData("test.pack", file=f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , filename = 'test.pack'
file = <_io.BytesIO object at 0x7eec1ec27650>, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/pack.py:751: TypeError
test_pack.py::DeltaChainIteratorTests::test_mixed_chain
test_pack.py::DeltaChainIteratorTests::test_mixed_chain
self =
def test_mixed_chain(self):
f = BytesIO()
entries = build_pack(
f,
[
(Blob.type_num, b"blob"),
(REF_DELTA, (2, b"blob2")),
(OFS_DELTA, (0, b"blob1")),
(OFS_DELTA, (1, b"blob3")),
(OFS_DELTA, (0, b"bob")),
],
)
# Delta resolution changed to DFS
> self.assertEntriesMatch([0, 4, 2, 1, 3], entries, self.make_pack_iter(f))
tests/test_pack.py:1159:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:1027: in make_pack_iter
data = PackData("test.pack", file=f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , filename = 'test.pack'
file = <_io.BytesIO object at 0x7eec20221cb0>, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/pack.py:751: TypeError
test_pack.py::DeltaChainIteratorTests::test_multiple_ext_refs
test_pack.py::DeltaChainIteratorTests::test_multiple_ext_refs
self =
def test_multiple_ext_refs(self):
b1, b2 = self.store_blobs([b"foo", b"bar"])
f = BytesIO()
entries = build_pack(
f,
[
> (REF_DELTA, (b1.id, b"foo1")),
(REF_DELTA, (b2.id, b"bar2")),
],
store=self.store,
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_pack.py:1245: AttributeError
test_pack.py::DeltaChainIteratorTests::test_no_deltas
test_pack.py::DeltaChainIteratorTests::test_no_deltas
self =
def test_no_deltas(self):
f = BytesIO()
entries = build_pack(
f,
[
(Commit.type_num, b"commit"),
(Blob.type_num, b"blob"),
(Tree.type_num, b"tree"),
],
)
> self.assertEntriesMatch([0, 1, 2], entries, self.make_pack_iter(f))
tests/test_pack.py:1056:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:1027: in make_pack_iter
data = PackData("test.pack", file=f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , filename = 'test.pack'
file = <_io.BytesIO object at 0x7eec1fdcbd80>, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/pack.py:751: TypeError
test_pack.py::DeltaChainIteratorTests::test_ofs_and_ref_deltas
test_pack.py::DeltaChainIteratorTests::test_ofs_and_ref_deltas
self =
def test_ofs_and_ref_deltas(self):
# Deltas pending on this offset are popped before deltas depending on
# this ref.
f = BytesIO()
entries = build_pack(
f,
[
(REF_DELTA, (1, b"blob1")),
(Blob.type_num, (b"blob")),
(OFS_DELTA, (1, b"blob2")),
],
)
# Delta resolution changed to DFS
> self.assertEntriesMatch([1, 0, 2], entries, self.make_pack_iter(f))
tests/test_pack.py:1144:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:1027: in make_pack_iter
data = PackData("test.pack", file=f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , filename = 'test.pack'
file = <_io.BytesIO object at 0x7eec1ec24d60>, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/pack.py:751: TypeError
test_pack.py::DeltaChainIteratorTests::test_ofs_deltas
test_pack.py::DeltaChainIteratorTests::test_ofs_deltas
self =
def test_ofs_deltas(self):
f = BytesIO()
entries = build_pack(
f,
[
(Blob.type_num, b"blob"),
(OFS_DELTA, (0, b"blob1")),
(OFS_DELTA, (0, b"blob2")),
],
)
# Delta resolution changed to DFS
> self.assertEntriesMatch([0, 2, 1], entries, self.make_pack_iter(f))
tests/test_pack.py:1085:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:1027: in make_pack_iter
data = PackData("test.pack", file=f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , filename = 'test.pack'
file = <_io.BytesIO object at 0x7eec1fb28810>, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/pack.py:751: TypeError
test_pack.py::DeltaChainIteratorTests::test_ofs_deltas_chain
test_pack.py::DeltaChainIteratorTests::test_ofs_deltas_chain
self =
def test_ofs_deltas_chain(self):
f = BytesIO()
entries = build_pack(
f,
[
(Blob.type_num, b"blob"),
(OFS_DELTA, (0, b"blob1")),
(OFS_DELTA, (1, b"blob2")),
],
)
> self.assertEntriesMatch([0, 1, 2], entries, self.make_pack_iter(f))
tests/test_pack.py:1103:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:1027: in make_pack_iter
data = PackData("test.pack", file=f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , filename = 'test.pack'
file = <_io.BytesIO object at 0x7eec1ec80f40>, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/pack.py:751: TypeError
test_pack.py::DeltaChainIteratorTests::test_ref_deltas
test_pack.py::DeltaChainIteratorTests::test_ref_deltas
self =
def test_ref_deltas(self):
f = BytesIO()
entries = build_pack(
f,
[
(REF_DELTA, (1, b"blob1")),
(Blob.type_num, (b"blob")),
(REF_DELTA, (1, b"blob2")),
],
)
# Delta resolution changed to DFS
> self.assertEntriesMatch([1, 2, 0], entries, self.make_pack_iter(f))
tests/test_pack.py:1116:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:1027: in make_pack_iter
data = PackData("test.pack", file=f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , filename = 'test.pack'
file = <_io.BytesIO object at 0x7eec20915710>, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/pack.py:751: TypeError
test_pack.py::DeltaChainIteratorTests::test_ref_deltas_chain
test_pack.py::DeltaChainIteratorTests::test_ref_deltas_chain
self =
def test_ref_deltas_chain(self):
f = BytesIO()
entries = build_pack(
f,
[
(REF_DELTA, (2, b"blob1")),
(Blob.type_num, (b"blob")),
(REF_DELTA, (1, b"blob2")),
],
)
> self.assertEntriesMatch([1, 2, 0], entries, self.make_pack_iter(f))
tests/test_pack.py:1128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_pack.py:1027: in make_pack_iter
data = PackData("test.pack", file=f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , filename = 'test.pack'
file = <_io.BytesIO object at 0x7eec1fb280e0>, size = None
def __init__(self, filename, file=None, size=None) -> None:
"""Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of.
It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python
mmap implementation is flawed.
"""
self._filename = filename
self._size = size
self._header_size = 12
if file is None:
self._file = GitFile(self._filename, 'rb')
else:
self._file = file
> version, self._num_objects = read_pack_header(self._file.read)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/pack.py:751: TypeError
test_pack.py::EncodeCopyOperationTests::test_basic
test_pack.py::EncodeCopyOperationTests::test_basic
self =
def test_basic(self):
self.assertEqual(b"\x80", _encode_copy_operation(0, 0))
> self.assertEqual(b"\x91\x01\x0a", _encode_copy_operation(1, 10))
E AssertionError: b'\x91\x01\n' != b'\xa1'
tests/test_pack.py:1328: AssertionError
test_patch.py::WriteCommitPatchTests::test_simple_bytesio
test_patch.py::WriteCommitPatchTests::test_simple_bytesio
self =
def test_simple_bytesio(self):
f = BytesIO()
c = Commit()
c.committer = c.author = b"Jelmer "
c.commit_time = c.author_time = 1271350201
c.commit_timezone = c.author_timezone = 0
c.message = b"This is the first line\nAnd this is the second line.\n"
c.tree = Tree().id
write_commit_patch(f, c, b"CONTENTS", (1, 1), version="custom")
f.seek(0)
lines = f.readlines()
self.assertTrue(
> lines[0].startswith(b"From 0b0d34d1b5b596c928adc9a727a4b9e03d025298")
)
E IndexError: list index out of range
tests/test_patch.py:52: IndexError
test_patch.py::ReadGitAmPatch::test_extract_bytes
self =
def test_extract_bytes(self):
text = b"""\
From ff643aae102d8870cac88e8f007e70f58f3a7363 Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij
Date: Thu, 15 Apr 2010 15:40:28 +0200
Subject: [PATCH 1/2] Remove executable bit from prey.ico (triggers a warning).
---
pixmaps/prey.ico | Bin 9662 -> 9662 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 pixmaps/prey.ico
--
1.7.0.4
"""
> c, diff, version = git_am_patch_split(BytesIO(text))
E TypeError: cannot unpack non-iterable NoneType object
tests/test_patch.py:120: TypeError
test_patch.py::ReadGitAmPatch::test_extract_no_version_tail
self =
def test_extract_no_version_tail(self):
text = b"""\
From ff643aae102d8870cac88e8f007e70f58f3a7363 Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij
Date: Thu, 15 Apr 2010 15:40:28 +0200
Subject: [Dulwich-users] [PATCH] Added unit tests for
dulwich.object_store.tree_lookup_path.
From: Jelmer Vernooij
---
pixmaps/prey.ico | Bin 9662 -> 9662 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 pixmaps/prey.ico
"""
> c, diff, version = git_am_patch_split(BytesIO(text), "utf-8")
E TypeError: cannot unpack non-iterable NoneType object
tests/test_patch.py:216: TypeError
test_patch.py::ReadGitAmPatch::test_extract_pseudo_from_header
self =
def test_extract_pseudo_from_header(self):
text = b"""From ff643aae102d8870cac88e8f007e70f58f3a7363 Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij
Date: Thu, 15 Apr 2010 15:40:28 +0200
Subject: [Dulwich-users] [PATCH] Added unit tests for
dulwich.object_store.tree_lookup_path.
From: Jelmer Vernooij
* dulwich/tests/test_object_store.py
(TreeLookupPathTests): This test case contains a few tests that ensure the
tree_lookup_path function works as expected.
---
pixmaps/prey.ico | Bin 9662 -> 9662 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 pixmaps/prey.ico
--
1.7.0.4
"""
> c, diff, version = git_am_patch_split(BytesIO(text), "utf-8")
E TypeError: cannot unpack non-iterable NoneType object
tests/test_patch.py:187: TypeError
test_patch.py::ReadGitAmPatch::test_extract_spaces
self =
def test_extract_spaces(self):
text = b"""From ff643aae102d8870cac88e8f007e70f58f3a7363 Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij
Date: Thu, 15 Apr 2010 15:40:28 +0200
Subject: [Dulwich-users] [PATCH] Added unit tests for
dulwich.object_store.tree_lookup_path.
* dulwich/tests/test_object_store.py
(TreeLookupPathTests): This test case contains a few tests that ensure the
tree_lookup_path function works as expected.
---
pixmaps/prey.ico | Bin 9662 -> 9662 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 pixmaps/prey.ico
--
1.7.0.4
"""
> c, diff, version = git_am_patch_split(BytesIO(text), "utf-8")
E TypeError: cannot unpack non-iterable NoneType object
tests/test_patch.py:155: TypeError
test_patch.py::ReadGitAmPatch::test_extract_string
self =
def test_extract_string(self):
text = b"""\
From ff643aae102d8870cac88e8f007e70f58f3a7363 Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij
Date: Thu, 15 Apr 2010 15:40:28 +0200
Subject: [PATCH 1/2] Remove executable bit from prey.ico (triggers a warning).
---
pixmaps/prey.ico | Bin 9662 -> 9662 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 pixmaps/prey.ico
--
1.7.0.4
"""
> c, diff, version = git_am_patch_split(StringIO(text.decode("utf-8")), "utf-8")
E TypeError: cannot unpack non-iterable NoneType object
tests/test_patch.py:88: TypeError
test_patch.py::DiffTests::test_blob_add
test_patch.py::DiffTests::test_blob_add
self =
def test_blob_add(self):
f = BytesIO()
write_blob_diff(
f,
(None, None, None),
(b"bar.txt", 0o644, Blob.from_string(b"new\nsame\n")),
)
> self.assertEqual(
[
b"diff --git a/bar.txt b/bar.txt",
b"new file mode 644",
b"index 0000000..a116b51",
b"--- /dev/null",
b"+++ b/bar.txt",
b"@@ -0,0 +1,2 @@",
b"+new",
b"+same",
],
f.getvalue().splitlines(),
)
E AssertionError: Lists differ: [b'diff --git a/bar.txt b/bar.txt', b'new [112 chars]ame'] != []
E
E First list contains 8 additional elements.
E First extra element 0:
E b'diff --git a/bar.txt b/bar.txt'
E
E + []
E - [b'diff --git a/bar.txt b/bar.txt',
E - b'new file mode 644',
E - b'index 0000000..a116b51',
E - b'--- /dev/null',
E - b'+++ b/bar.txt',
E - b'@@ -0,0 +1,2 @@',
E - b'+new',
E - b'+same']
tests/test_patch.py:293: AssertionError
test_patch.py::DiffTests::test_blob_diff
test_patch.py::DiffTests::test_blob_diff
self =
def test_blob_diff(self):
f = BytesIO()
write_blob_diff(
f,
(b"foo.txt", 0o644, Blob.from_string(b"old\nsame\n")),
(b"bar.txt", 0o644, Blob.from_string(b"new\nsame\n")),
)
> self.assertEqual(
[
b"diff --git a/foo.txt b/bar.txt",
b"index 3b0f961..a116b51 644",
b"--- a/foo.txt",
b"+++ b/bar.txt",
b"@@ -1,2 +1,2 @@",
b"-old",
b"+new",
b" same",
],
f.getvalue().splitlines(),
)
E AssertionError: Lists differ: [b'diff --git a/foo.txt b/bar.txt', b'inde[103 chars]ame'] != []
E
E First list contains 8 additional elements.
E First extra element 0:
E b'diff --git a/foo.txt b/bar.txt'
E
E + []
E - [b'diff --git a/foo.txt b/bar.txt',
E - b'index 3b0f961..a116b51 644',
E - b'--- a/foo.txt',
E - b'+++ b/bar.txt',
E - b'@@ -1,2 +1,2 @@',
E - b'-old',
E - b'+new',
E - b' same']
tests/test_patch.py:272: AssertionError
test_patch.py::DiffTests::test_blob_remove
test_patch.py::DiffTests::test_blob_remove
self =
def test_blob_remove(self):
f = BytesIO()
write_blob_diff(
f,
(b"bar.txt", 0o644, Blob.from_string(b"new\nsame\n")),
(None, None, None),
)
> self.assertEqual(
[
b"diff --git a/bar.txt b/bar.txt",
b"deleted file mode 644",
b"index a116b51..0000000",
b"--- a/bar.txt",
b"+++ /dev/null",
b"@@ -1,2 +0,0 @@",
b"-new",
b"-same",
],
f.getvalue().splitlines(),
)
E AssertionError: Lists differ: [b'diff --git a/bar.txt b/bar.txt', b'dele[116 chars]ame'] != []
E
E First list contains 8 additional elements.
E First extra element 0:
E b'diff --git a/bar.txt b/bar.txt'
E
E + []
E - [b'diff --git a/bar.txt b/bar.txt',
E - b'deleted file mode 644',
E - b'index a116b51..0000000',
E - b'--- a/bar.txt',
E - b'+++ /dev/null',
E - b'@@ -1,2 +0,0 @@',
E - b'-new',
E - b'-same']
tests/test_patch.py:314: AssertionError
test_patch.py::DiffTests::test_object_diff_add_bin_blob
test_patch.py::DiffTests::test_object_diff_add_bin_blob
self =
def test_object_diff_add_bin_blob(self):
f = BytesIO()
b2 = Blob.from_string(
b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"
b"\x00\x00\x00\x0d\x49\x48\x44\x52"
b"\x00\x00\x01\xd5\x00\x00\x00\x9f"
b"\x08\x03\x00\x00\x00\x98\xd3\xb3"
)
store = MemoryObjectStore()
store.add_object(b2)
> write_object_diff(f, store, (None, None, None), (b"bar.png", 0o644, b2.id))
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_patch.py:563: AttributeError
test_patch.py::DiffTests::test_object_diff_add_blob
test_patch.py::DiffTests::test_object_diff_add_blob
self =
def test_object_diff_add_blob(self):
f = BytesIO()
store = MemoryObjectStore()
b2 = Blob.from_string(b"new\nsame\n")
store.add_object(b2)
> write_object_diff(f, store, (None, None, None), (b"bar.txt", 0o644, b2.id))
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_patch.py:445: AttributeError
test_patch.py::DiffTests::test_object_diff_bin_blob
test_patch.py::DiffTests::test_object_diff_bin_blob
self =
def test_object_diff_bin_blob(self):
f = BytesIO()
# Prepare two slightly different PNG headers
b1 = Blob.from_string(
b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"
b"\x00\x00\x00\x0d\x49\x48\x44\x52"
b"\x00\x00\x01\xd5\x00\x00\x00\x9f"
b"\x08\x04\x00\x00\x00\x05\x04\x8b"
)
b2 = Blob.from_string(
b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"
b"\x00\x00\x00\x0d\x49\x48\x44\x52"
b"\x00\x00\x01\xd5\x00\x00\x00\x9f"
b"\x08\x03\x00\x00\x00\x98\xd3\xb3"
)
store = MemoryObjectStore()
store.add_objects([(b1, None), (b2, None)])
write_object_diff(
> f, store, (b"foo.png", 0o644, b1.id), (b"bar.png", 0o644, b2.id)
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_patch.py:542: AttributeError
test_patch.py::DiffTests::test_object_diff_bin_blob_force
test_patch.py::DiffTests::test_object_diff_bin_blob_force
self =
def test_object_diff_bin_blob_force(self):
f = BytesIO()
# Prepare two slightly different PNG headers
b1 = Blob.from_string(
b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"
b"\x00\x00\x00\x0d\x49\x48\x44\x52"
b"\x00\x00\x01\xd5\x00\x00\x00\x9f"
b"\x08\x04\x00\x00\x00\x05\x04\x8b"
)
b2 = Blob.from_string(
b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"
b"\x00\x00\x00\x0d\x49\x48\x44\x52"
b"\x00\x00\x01\xd5\x00\x00\x00\x9f"
b"\x08\x03\x00\x00\x00\x98\xd3\xb3"
)
store = MemoryObjectStore()
store.add_objects([(b1, None), (b2, None)])
write_object_diff(
f,
store,
> (b"foo.png", 0o644, b1.id),
(b"bar.png", 0o644, b2.id),
diff_binary=True,
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_patch.py:500: AttributeError
test_patch.py::DiffTests::test_object_diff_blob
test_patch.py::DiffTests::test_object_diff_blob
self =
def test_object_diff_blob(self):
f = BytesIO()
b1 = Blob.from_string(b"old\nsame\n")
b2 = Blob.from_string(b"new\nsame\n")
store = MemoryObjectStore()
store.add_objects([(b1, None), (b2, None)])
write_object_diff(
> f, store, (b"foo.txt", 0o644, b1.id), (b"bar.txt", 0o644, b2.id)
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_patch.py:424: AttributeError
test_patch.py::DiffTests::test_object_diff_kind_change
test_patch.py::DiffTests::test_object_diff_kind_change
self =
def test_object_diff_kind_change(self):
f = BytesIO()
b1 = Blob.from_string(b"new\nsame\n")
store = MemoryObjectStore()
store.add_object(b1)
write_object_diff(
f,
store,
> (b"bar.txt", 0o644, b1.id),
(
b"bar.txt",
0o160000,
b"06d0bdd9e2e20377b3180e4986b14c8549b393e4",
),
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_patch.py:603: AttributeError
test_patch.py::DiffTests::test_object_diff_remove_bin_blob
test_patch.py::DiffTests::test_object_diff_remove_bin_blob
self =
def test_object_diff_remove_bin_blob(self):
f = BytesIO()
b1 = Blob.from_string(
b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"
b"\x00\x00\x00\x0d\x49\x48\x44\x52"
b"\x00\x00\x01\xd5\x00\x00\x00\x9f"
b"\x08\x04\x00\x00\x00\x05\x04\x8b"
)
store = MemoryObjectStore()
store.add_object(b1)
> write_object_diff(f, store, (b"foo.png", 0o644, b1.id), (None, None, None))
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_patch.py:584: AttributeError
test_patch.py::DiffTests::test_object_diff_remove_blob
test_patch.py::DiffTests::test_object_diff_remove_blob
self =
def test_object_diff_remove_blob(self):
f = BytesIO()
b1 = Blob.from_string(b"new\nsame\n")
store = MemoryObjectStore()
store.add_object(b1)
> write_object_diff(f, store, (b"bar.txt", 0o644, b1.id), (None, None, None))
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_patch.py:465: AttributeError
test_patch.py::DiffTests::test_tree_diff
test_patch.py::DiffTests::test_tree_diff
self =
def test_tree_diff(self):
f = BytesIO()
store = MemoryObjectStore()
added = Blob.from_string(b"add\n")
removed = Blob.from_string(b"removed\n")
changed1 = Blob.from_string(b"unchanged\nremoved\n")
changed2 = Blob.from_string(b"unchanged\nadded\n")
unchanged = Blob.from_string(b"unchanged\n")
tree1 = Tree()
> tree1.add(b"removed.txt", 0o644, removed.id)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_patch.py:337: AttributeError
test_patch.py::DiffTests::test_tree_diff_submodule
test_patch.py::DiffTests::test_tree_diff_submodule
self =
def test_tree_diff_submodule(self):
f = BytesIO()
store = MemoryObjectStore()
tree1 = Tree()
tree1.add(
b"asubmodule",
S_IFGITLINK,
b"06d0bdd9e2e20377b3180e4986b14c8549b393e4",
)
tree2 = Tree()
tree2.add(
b"asubmodule",
S_IFGITLINK,
b"cc975646af69f279396d4d5e1379ac6af80ee637",
)
store.add_objects([(o, None) for o in [tree1, tree2]])
write_tree_diff(f, store, tree1.id, tree2.id)
> self.assertEqual(
[
b"diff --git a/asubmodule b/asubmodule",
b"index 06d0bdd..cc97564 160000",
b"--- a/asubmodule",
b"+++ b/asubmodule",
b"@@ -1 +1 @@",
b"-Subproject commit 06d0bdd9e2e20377b3180e4986b14c8549b393e4",
b"+Subproject commit cc975646af69f279396d4d5e1379ac6af80ee637",
],
f.getvalue().splitlines(),
)
E AssertionError: Lists differ: [b'diff --git a/asubmodule b/asubmodule', [214 chars]637'] != []
E
E First list contains 7 additional elements.
E First extra element 0:
E b'diff --git a/asubmodule b/asubmodule'
E
E + []
E - [b'diff --git a/asubmodule b/asubmodule',
E - b'index 06d0bdd..cc97564 160000',
E - b'--- a/asubmodule',
E - b'+++ b/asubmodule',
E - b'@@ -1 +1 @@',
E - b'-Subproject commit 06d0bdd9e2e20377b3180e4986b14c8549b393e4',
E - b'+Subproject commit cc975646af69f279396d4d5e1379ac6af80ee637']
tests/test_patch.py:404: AssertionError
test_patch.py::GetSummaryTests::test_simple
test_patch.py::GetSummaryTests::test_simple
self =
def test_simple(self):
c = Commit()
c.committer = c.author = b"Jelmer "
c.commit_time = c.author_time = 1271350201
c.commit_timezone = c.author_timezone = 0
c.message = b"This is the first line\nAnd this is the second line.\n"
c.tree = Tree().id
> self.assertEqual("This-is-the-first-line", get_summary(c))
E AssertionError: 'This-is-the-first-line' != None
tests/test_patch.py:635: AssertionError
test_protocol.py::ProtocolTests::test_eof
test_protocol.py::ProtocolTests::test_eof
self =
def test_eof(self):
self.rin.write(b"0000")
self.rin.seek(0)
self.assertFalse(self.proto.eof())
self.assertEqual(None, self.proto.read_pkt_line())
> self.assertTrue(self.proto.eof())
E AssertionError: None is not true
tests/test_protocol.py:62: AssertionError
test_protocol.py::ProtocolTests::test_read_cmd
test_protocol.py::ProtocolTests::test_read_cmd
self =
def test_read_cmd(self):
self.rin.write(b"0012cmd arg1\x00arg2\x00")
self.rin.seek(0)
> self.assertEqual((b"cmd", [b"arg1", b"arg2"]), self.proto.read_cmd())
E AssertionError: (b'cmd', [b'arg1', b'arg2']) != None
tests/test_protocol.py:101: AssertionError
test_protocol.py::ProtocolTests::test_read_cmd_noend0
test_protocol.py::ProtocolTests::test_read_cmd_noend0
self =
def test_read_cmd_noend0(self):
self.rin.write(b"0011cmd arg1\x00arg2")
self.rin.seek(0)
> self.assertRaises(AssertionError, self.proto.read_cmd)
E AssertionError: AssertionError not raised by read_cmd
tests/test_protocol.py:106: AssertionError
test_protocol.py::ProtocolTests::test_read_pkt_line
test_protocol.py::ProtocolTests::test_read_pkt_line
self =
def test_read_pkt_line(self):
self.rin.write(b"0008cmd ")
self.rin.seek(0)
> self.assertEqual(b"cmd ", self.proto.read_pkt_line())
E AssertionError: b'cmd ' != None
tests/test_protocol.py:55: AssertionError
test_protocol.py::ProtocolTests::test_read_pkt_line_wrong_size
test_protocol.py::ProtocolTests::test_read_pkt_line_wrong_size
self =
def test_read_pkt_line_wrong_size(self):
self.rin.write(b"0100too short")
self.rin.seek(0)
> self.assertRaises(GitProtocolError, self.proto.read_pkt_line)
E AssertionError: GitProtocolError not raised by read_pkt_line
tests/test_protocol.py:88: AssertionError
test_protocol.py::ProtocolTests::test_read_pkt_seq
test_protocol.py::ProtocolTests::test_read_pkt_seq
self =
def test_read_pkt_seq(self):
self.rin.write(b"0008cmd 0005l0000")
self.rin.seek(0)
> self.assertEqual([b"cmd ", b"l"], list(self.proto.read_pkt_seq()))
E TypeError: 'NoneType' object is not iterable
tests/test_protocol.py:78: TypeError
test_protocol.py::ProtocolTests::test_send_cmd
test_protocol.py::ProtocolTests::test_send_cmd
self =
def test_send_cmd(self):
self.proto.send_cmd(b"fetch", b"a", b"b")
> self.assertEqual(self.rout.getvalue(), b"000efetch a\x00b\x00")
E AssertionError: b'' != b'000efetch a\x00b\x00'
tests/test_protocol.py:96: AssertionError
test_protocol.py::ProtocolTests::test_unread_pkt_line
test_protocol.py::ProtocolTests::test_unread_pkt_line
self =
def test_unread_pkt_line(self):
self.rin.write(b"0007foo0000")
self.rin.seek(0)
> self.assertEqual(b"foo", self.proto.read_pkt_line())
E AssertionError: b'foo' != None
tests/test_protocol.py:68: AssertionError
test_protocol.py::ProtocolTests::test_write_pkt_line
test_protocol.py::ProtocolTests::test_write_pkt_line
self =
def test_write_pkt_line(self):
self.proto.write_pkt_line(b"bla")
> self.assertEqual(self.rout.getvalue(), b"0007bla")
E AssertionError: b'' != b'0007bla'
tests/test_protocol.py:50: AssertionError
test_protocol.py::ProtocolTests::test_write_pkt_line_none
test_protocol.py::ProtocolTests::test_write_pkt_line_none
self =
def test_write_pkt_line_none(self):
self.proto.write_pkt_line(None)
> self.assertEqual(self.rout.getvalue(), b"0000")
E AssertionError: b'' != b'0000'
tests/test_protocol.py:46: AssertionError
test_protocol.py::ProtocolTests::test_write_sideband
test_protocol.py::ProtocolTests::test_write_sideband
self =
def test_write_sideband(self):
self.proto.write_sideband(3, b"bloe")
> self.assertEqual(self.rout.getvalue(), b"0009\x03bloe")
E AssertionError: b'' != b'0009\x03bloe'
tests/test_protocol.py:92: AssertionError
test_protocol.py::ReceivableProtocolTests::test_eof
test_protocol.py::ReceivableProtocolTests::test_eof
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_mixed
test_protocol.py::ReceivableProtocolTests::test_mixed
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_read_cmd
test_protocol.py::ReceivableProtocolTests::test_read_cmd
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_read_cmd_noend0
test_protocol.py::ReceivableProtocolTests::test_read_cmd_noend0
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_read_pkt_line
test_protocol.py::ReceivableProtocolTests::test_read_pkt_line
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_read_pkt_line_none
test_protocol.py::ReceivableProtocolTests::test_read_pkt_line_none
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_read_pkt_line_wrong_size
test_protocol.py::ReceivableProtocolTests::test_read_pkt_line_wrong_size
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_read_pkt_seq
test_protocol.py::ReceivableProtocolTests::test_read_pkt_seq
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_read_recv
test_protocol.py::ReceivableProtocolTests::test_read_recv
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_recv
test_protocol.py::ReceivableProtocolTests::test_recv
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_recv_read
test_protocol.py::ReceivableProtocolTests::test_recv_read
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_send_cmd
test_protocol.py::ReceivableProtocolTests::test_send_cmd
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_unread_pkt_line
test_protocol.py::ReceivableProtocolTests::test_unread_pkt_line
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_write_pkt_line
test_protocol.py::ReceivableProtocolTests::test_write_pkt_line
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_write_pkt_line_none
test_protocol.py::ReceivableProtocolTests::test_write_pkt_line_none
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::ReceivableProtocolTests::test_write_sideband
test_protocol.py::ReceivableProtocolTests::test_write_sideband
self =
def setUp(self):
TestCase.setUp(self)
self.rout = BytesIO()
self.rin = ReceivableBytesIO()
> self.proto = ReceivableProtocol(self.rin.recv, self.rout.write)
tests/test_protocol.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
recv = >
write =
close = None, report_activity = None, rbufsize = 8192
def __init__(self, recv, write, close=None, report_activity=None, rbufsize=_RBUFSIZE) -> None:
> super().__init__(self.read, write, close=close, report_activity=report_activity)
E AttributeError: 'ReceivableProtocol' object has no attribute 'read'
dulwich/protocol.py:199: AttributeError
test_protocol.py::CapabilitiesTestCase::test_ack_type
test_protocol.py::CapabilitiesTestCase::test_ack_type
self =
def test_ack_type(self):
> self.assertEqual(SINGLE_ACK, ack_type([b"foo", b"bar"]))
E AssertionError: 0 != None
tests/test_protocol.py:232: AssertionError
test_protocol.py::CapabilitiesTestCase::test_caps
test_protocol.py::CapabilitiesTestCase::test_caps
self =
def test_caps(self):
> self.assertEqual((b"bla", [b"la"]), extract_capabilities(b"bla\0la"))
E AssertionError: Tuples differ: (b'bla', [b'la']) != (b'bla\x00la', [])
E
E First differing element 0:
E b'bla'
E b'bla\x00la'
E
E - (b'bla', [b'la'])
E + (b'bla\x00la', [])
tests/test_protocol.py:210: AssertionError
test_protocol.py::CapabilitiesTestCase::test_caps_want_line
test_protocol.py::CapabilitiesTestCase::test_caps_want_line
self =
def test_caps_want_line(self):
> self.assertEqual(
(b"want bla", [b"la"]),
extract_want_line_capabilities(b"want bla la"),
)
E AssertionError: (b'want bla', [b'la']) != None
tests/test_protocol.py:218: AssertionError
test_protocol.py::CapabilitiesTestCase::test_plain_want_line
test_protocol.py::CapabilitiesTestCase::test_plain_want_line
self =
def test_plain_want_line(self):
> self.assertEqual((b"want bla", []), extract_want_line_capabilities(b"want bla"))
E AssertionError: (b'want bla', []) != None
tests/test_protocol.py:215: AssertionError
test_protocol.py::BufferedPktLineWriterTests::test_write
test_protocol.py::BufferedPktLineWriterTests::test_write
self =
def test_write(self):
self._writer.write(b"foo")
self.assertOutputEquals(b"")
self._writer.flush()
> self.assertOutputEquals(b"0007foo")
tests/test_protocol.py:262:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_protocol.py:252: in assertOutputEquals
self.assertEqual(expected, self._output.getvalue())
E AssertionError: b'0007foo' != b''
test_protocol.py::BufferedPktLineWriterTests::test_write_across_boundary
test_protocol.py::BufferedPktLineWriterTests::test_write_across_boundary
self =
def test_write_across_boundary(self):
self._writer.write(b"foo")
self._writer.write(b"barbaz")
> self.assertOutputEquals(b"0007foo000abarba")
tests/test_protocol.py:284:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_protocol.py:252: in assertOutputEquals
self.assertEqual(expected, self._output.getvalue())
E AssertionError: b'0007foo000abarba' != b''
test_protocol.py::BufferedPktLineWriterTests::test_write_multiple
test_protocol.py::BufferedPktLineWriterTests::test_write_multiple
self =
def test_write_multiple(self):
self._writer.write(b"foo")
self._writer.write(b"bar")
self.assertOutputEquals(b"")
self._writer.flush()
> self.assertOutputEquals(b"0007foo0007bar")
tests/test_protocol.py:279:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_protocol.py:252: in assertOutputEquals
self.assertEqual(expected, self._output.getvalue())
E AssertionError: b'0007foo0007bar' != b''
test_protocol.py::BufferedPktLineWriterTests::test_write_none
test_protocol.py::BufferedPktLineWriterTests::test_write_none
self =
def test_write_none(self):
self._writer.write(None)
self.assertOutputEquals(b"")
self._writer.flush()
> self.assertOutputEquals(b"0000")
tests/test_protocol.py:268:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_protocol.py:252: in assertOutputEquals
self.assertEqual(expected, self._output.getvalue())
E AssertionError: b'0000' != b''
test_protocol.py::BufferedPktLineWriterTests::test_write_to_boundary
test_protocol.py::BufferedPktLineWriterTests::test_write_to_boundary
self =
def test_write_to_boundary(self):
self._writer.write(b"foo")
self._writer.write(b"barba")
> self.assertOutputEquals(b"0007foo0009barba")
tests/test_protocol.py:292:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_protocol.py:252: in assertOutputEquals
self.assertEqual(expected, self._output.getvalue())
E AssertionError: b'0007foo0009barba' != b''
test_protocol.py::PktLineParserTests::test_multiple_packets
test_protocol.py::PktLineParserTests::test_multiple_packets
self =
def test_multiple_packets(self):
pktlines = []
parser = PktLineParser(pktlines.append)
parser.parse(b"0005z0006aba")
> self.assertEqual(pktlines, [b"z", b"ab"])
E AssertionError: Lists differ: [] != [b'z', b'ab']
E
E Second list contains 2 additional elements.
E First extra element 0:
E b'z'
E
E - []
E + [b'z', b'ab']
tests/test_protocol.py:320: AssertionError
test_protocol.py::PktLineParserTests::test_none
test_protocol.py::PktLineParserTests::test_none
self =
def test_none(self):
pktlines = []
parser = PktLineParser(pktlines.append)
parser.parse(b"0000")
> self.assertEqual(pktlines, [None])
E AssertionError: Lists differ: [] != [None]
E
E Second list contains 1 additional elements.
E First extra element 0:
E None
E
E - []
E + [None]
tests/test_protocol.py:304: AssertionError
test_protocol.py::PktLineParserTests::test_small_fragments
test_protocol.py::PktLineParserTests::test_small_fragments
self =
def test_small_fragments(self):
pktlines = []
parser = PktLineParser(pktlines.append)
parser.parse(b"00")
parser.parse(b"05")
parser.parse(b"z0000")
> self.assertEqual(pktlines, [b"z", None])
E AssertionError: Lists differ: [] != [b'z', None]
E
E Second list contains 2 additional elements.
E First extra element 0:
E b'z'
E
E - []
E + [b'z', None]
tests/test_protocol.py:313: AssertionError
test_reflog.py::ReflogLineTests::test_format
self =
def test_format(self):
> self.assertEqual(
b"0000000000000000000000000000000000000000 "
b"49030649db3dfec5a9bc03e5dde4255a14499f16 Jelmer Vernooij "
b" 1446552482 +0000 "
b"clone: from git://jelmer.uk/samba",
format_reflog_line(
b"0000000000000000000000000000000000000000",
b"49030649db3dfec5a9bc03e5dde4255a14499f16",
b"Jelmer Vernooij ",
1446552482,
0,
b"clone: from git://jelmer.uk/samba",
),
)
E AssertionError: b'000000000000000000000000000000000000000[125 chars]amba' != None
tests/test_reflog.py:38: AssertionError
test_reflog.py::ReflogLineTests::test_parse
test_reflog.py::ReflogLineTests::test_parse
self =
def test_parse(self):
reflog_line = (
b"0000000000000000000000000000000000000000 "
b"49030649db3dfec5a9bc03e5dde4255a14499f16 Jelmer Vernooij "
b" 1446552482 +0000 "
b"clone: from git://jelmer.uk/samba"
)
> self.assertEqual(
(
b"0000000000000000000000000000000000000000",
b"49030649db3dfec5a9bc03e5dde4255a14499f16",
b"Jelmer Vernooij ",
1446552482,
0,
b"clone: from git://jelmer.uk/samba",
),
parse_reflog_line(reflog_line),
)
E AssertionError: (b'00000000000000000000000000000000000000[136 chars]mba') != None
tests/test_reflog.py:75: AssertionError
test_reflog.py::ReflogDropTests::test_drop_entry
test_reflog.py::ReflogDropTests::test_drop_entry
self =
def setUp(self):
TestCase.setUp(self)
self.f = BytesIO(_TEST_REFLOG)
> self.original_log = list(read_reflog(self.f))
E TypeError: 'NoneType' object is not iterable
tests/test_reflog.py:108: TypeError
test_reflog.py::ReflogDropTests::test_drop_entry_with_rewrite
test_reflog.py::ReflogDropTests::test_drop_entry_with_rewrite
self =
def setUp(self):
TestCase.setUp(self)
self.f = BytesIO(_TEST_REFLOG)
> self.original_log = list(read_reflog(self.f))
E TypeError: 'NoneType' object is not iterable
tests/test_reflog.py:108: TypeError
test_reflog.py::ReflogDropTests::test_invalid
test_reflog.py::ReflogDropTests::test_invalid
self =
def setUp(self):
TestCase.setUp(self)
self.f = BytesIO(_TEST_REFLOG)
> self.original_log = list(read_reflog(self.f))
E TypeError: 'NoneType' object is not iterable
tests/test_reflog.py:108: TypeError
test_refs.py::CheckRefFormatTests::test_valid
self =
def test_valid(self):
> self.assertTrue(check_ref_format(b"heads/foo"))
E AssertionError: None is not true
tests/test_refs.py:57: AssertionError
test_refs.py::PackedRefsFileTests::test_read_with_peeled
test_refs.py::PackedRefsFileTests::test_read_with_peeled
self =
def test_read_with_peeled(self):
f = BytesIO(
b"\n".join(
[
ONES + b" ref/1",
TWOS + b" ref/2",
b"^" + THREES,
FOURS + b" ref/4",
]
)
)
self.assertEqual(
[
(ONES, b"ref/1", None),
(TWOS, b"ref/2", THREES),
(FOURS, b"ref/4", None),
],
> list(read_packed_refs_with_peeled(f)),
)
E TypeError: 'NoneType' object is not iterable
tests/test_refs.py:119: TypeError
test_refs.py::PackedRefsFileTests::test_read_with_peeled_errors
test_refs.py::PackedRefsFileTests::test_read_with_peeled_errors
self =
def test_read_with_peeled_errors(self):
f = BytesIO(b"\n".join([b"^" + TWOS, ONES + b" ref/1"]))
> self.assertRaises(errors.PackedRefsException, list, read_packed_refs(f))
E TypeError: 'NoneType' object is not iterable
tests/test_refs.py:124: TypeError
test_refs.py::PackedRefsFileTests::test_read_without_peeled
test_refs.py::PackedRefsFileTests::test_read_without_peeled
self =
def test_read_without_peeled(self):
f = BytesIO(b"\n".join([b"# comment", ONES + b" ref/1", TWOS + b" ref/2"]))
self.assertEqual(
> [(ONES, b"ref/1"), (TWOS, b"ref/2")], list(read_packed_refs(f))
)
E TypeError: 'NoneType' object is not iterable
tests/test_refs.py:95: TypeError
test_refs.py::PackedRefsFileTests::test_read_without_peeled_errors
test_refs.py::PackedRefsFileTests::test_read_without_peeled_errors
self =
def test_read_without_peeled_errors(self):
f = BytesIO(b"\n".join([ONES + b" ref/1", b"^" + TWOS]))
> self.assertRaises(errors.PackedRefsException, list, read_packed_refs(f))
E TypeError: 'NoneType' object is not iterable
tests/test_refs.py:100: TypeError
test_refs.py::PackedRefsFileTests::test_split_ref_line_errors
test_refs.py::PackedRefsFileTests::test_split_ref_line_errors
self =
def test_split_ref_line_errors(self):
> self.assertRaises(errors.PackedRefsException, _split_ref_line, b"singlefield")
E AssertionError: PackedRefsException not raised by _split_ref_line
tests/test_refs.py:84: AssertionError
test_refs.py::PackedRefsFileTests::test_write_with_peeled
test_refs.py::PackedRefsFileTests::test_write_with_peeled
self =
def test_write_with_peeled(self):
f = BytesIO()
write_packed_refs(f, {b"ref/1": ONES, b"ref/2": TWOS}, {b"ref/1": THREES})
> self.assertEqual(
b"\n".join(
[
b"# pack-refs with: peeled",
ONES + b" ref/1",
b"^" + THREES,
TWOS + b" ref/2",
]
)
+ b"\n",
f.getvalue(),
)
E AssertionError: b'# pack-refs with: peeled\n111111111111111[120 chars]/2\n' != b''
tests/test_refs.py:132: AssertionError
test_refs.py::PackedRefsFileTests::test_write_without_peeled
test_refs.py::PackedRefsFileTests::test_write_without_peeled
self =
def test_write_without_peeled(self):
f = BytesIO()
write_packed_refs(f, {b"ref/1": ONES, b"ref/2": TWOS})
> self.assertEqual(
b"\n".join([ONES + b" ref/1", TWOS + b" ref/2"]) + b"\n",
f.getvalue(),
)
E AssertionError: b'1111111111111111111111111111111111111111 [51 chars]/2\n' != b''
tests/test_refs.py:148: AssertionError
test_refs.py::DictRefsContainerTests::test_add_if_new
test_refs.py::DictRefsContainerTests::test_add_if_new
self =
def test_add_if_new(self):
nines = b"9" * 40
self.assertFalse(self._refs.add_if_new(b"refs/heads/master", nines))
self.assertEqual(
b"42d06bd4b77fed026b154d16493e5deab78f02ec",
> self._refs[b"refs/heads/master"],
)
tests/test_refs.py:250:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = b'refs/heads/master'
def __getitem__(self, name):
"""Get the SHA1 for a reference name.
This method follows all symbolic references.
"""
> _, sha = self.follow(name)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/refs.py:181: TypeError
test_refs.py::DictRefsContainerTests::test_as_dict
test_refs.py::DictRefsContainerTests::test_as_dict
self =
def test_as_dict(self):
# refs/heads/loop does not show up even if it exists
expected_refs = dict(_TEST_REFS)
del expected_refs[b"refs/heads/loop"]
> self.assertEqual(expected_refs, self._refs.as_dict())
E AssertionError: {b'HEAD': b'42d06bd4b77fed026b154d16493e5[369 chars]6a8'} != None
tests/test_refs.py:191: AssertionError
test_refs.py::DictRefsContainerTests::test_check_refname
test_refs.py::DictRefsContainerTests::test_check_refname
self =
def test_check_refname(self):
self._refs._check_refname(b"HEAD")
self._refs._check_refname(b"refs/stash")
self._refs._check_refname(b"refs/heads/foo")
> self.assertRaises(errors.RefFormatError, self._refs._check_refname, b"refs")
E AssertionError: RefFormatError not raised by _check_refname
tests/test_refs.py:287: AssertionError
test_refs.py::DictRefsContainerTests::test_contains
test_refs.py::DictRefsContainerTests::test_contains
self =
def test_contains(self):
> self.assertIn(b"refs/heads/master", self._refs)
E AssertionError: b'refs/heads/master' not found in
tests/test_refs.py:293: AssertionError
test_refs.py::DictRefsContainerTests::test_delitem
test_refs.py::DictRefsContainerTests::test_delitem
self =
def test_delitem(self):
self.assertEqual(
b"42d06bd4b77fed026b154d16493e5deab78f02ec",
> self._refs[b"refs/heads/master"],
)
tests/test_refs.py:299:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = b'refs/heads/master'
def __getitem__(self, name):
"""Get the SHA1 for a reference name.
This method follows all symbolic references.
"""
> _, sha = self.follow(name)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/refs.py:181: TypeError
test_refs.py::DictRefsContainerTests::test_get_symrefs
test_refs.py::DictRefsContainerTests::test_get_symrefs
self =
def test_get_symrefs(self):
self._refs.set_symbolic_ref(b"refs/heads/src", b"refs/heads/dst")
symrefs = self._refs.get_symrefs()
> if b"HEAD" in symrefs:
E TypeError: argument of type 'NoneType' is not iterable
tests/test_refs.py:196: TypeError
test_refs.py::DictRefsContainerTests::test_import_refs_name
test_refs.py::DictRefsContainerTests::test_import_refs_name
self =
def test_import_refs_name(self):
self._refs[b"refs/remotes/origin/other"] = (
b"48d01bd4b77fed026b154d16493e5deab78f02ec"
)
> self._refs.import_refs(
b"refs/remotes/origin",
{b"master": b"42d06bd4b77fed026b154d16493e5deab78f02ec"},
)
E AttributeError: 'DictRefsContainer' object has no attribute 'import_refs'
tests/test_refs.py:322: AttributeError
test_refs.py::DictRefsContainerTests::test_import_refs_name_prune
test_refs.py::DictRefsContainerTests::test_import_refs_name_prune
self =
def test_import_refs_name_prune(self):
self._refs[b"refs/remotes/origin/other"] = (
b"48d01bd4b77fed026b154d16493e5deab78f02ec"
)
> self._refs.import_refs(
b"refs/remotes/origin",
{b"master": b"42d06bd4b77fed026b154d16493e5deab78f02ec"},
prune=True,
)
E AttributeError: 'DictRefsContainer' object has no attribute 'import_refs'
tests/test_refs.py:339: AttributeError
test_refs.py::DictRefsContainerTests::test_invalid_refname
test_refs.py::DictRefsContainerTests::test_invalid_refname
self =
def test_invalid_refname(self):
# FIXME: Move this test into RefsContainerTests, but requires
# some way of injecting invalid refs.
self._refs._refs[b"refs/stash"] = b"00" * 20
expected_refs = dict(_TEST_REFS)
del expected_refs[b"refs/heads/loop"]
expected_refs[b"refs/stash"] = b"00" * 20
> self.assertEqual(expected_refs, self._refs.as_dict())
E AssertionError: {b'HEAD': b'42d06bd4b77fed026b154d16493e5[429 chars]000'} != None
tests/test_refs.py:363: AssertionError
test_refs.py::DictRefsContainerTests::test_iter
test_refs.py::DictRefsContainerTests::test_iter
self =
def test_iter(self):
> actual_keys = set(self._refs.keys())
E TypeError: 'NoneType' object is not iterable
tests/test_refs.py:183: TypeError
test_refs.py::DictRefsContainerTests::test_keys
test_refs.py::DictRefsContainerTests::test_keys
self =
def test_keys(self):
> actual_keys = set(self._refs.keys())
E TypeError: 'NoneType' object is not iterable
tests/test_refs.py:168: TypeError
test_refs.py::DictRefsContainerTests::test_remove_if_equals
test_refs.py::DictRefsContainerTests::test_remove_if_equals
self =
def test_remove_if_equals(self):
self.assertFalse(self._refs.remove_if_equals(b"HEAD", b"c0ffee"))
self.assertEqual(
> b"42d06bd4b77fed026b154d16493e5deab78f02ec", self._refs[b"HEAD"]
)
tests/test_refs.py:307:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , name = b'HEAD'
def __getitem__(self, name):
"""Get the SHA1 for a reference name.
This method follows all symbolic references.
"""
> _, sha = self.follow(name)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/refs.py:181: TypeError
test_refs.py::DictRefsContainerTests::test_set_if_equals
test_refs.py::DictRefsContainerTests::test_set_if_equals
self =
def test_set_if_equals(self):
nines = b"9" * 40
self.assertFalse(self._refs.set_if_equals(b"HEAD", b"c0ffee", nines))
self.assertEqual(
> b"42d06bd4b77fed026b154d16493e5deab78f02ec", self._refs[b"HEAD"]
)
tests/test_refs.py:223:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , name = b'HEAD'
def __getitem__(self, name):
"""Get the SHA1 for a reference name.
This method follows all symbolic references.
"""
> _, sha = self.follow(name)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/refs.py:181: TypeError
test_refs.py::DictRefsContainerTests::test_set_symbolic_ref
test_refs.py::DictRefsContainerTests::test_set_symbolic_ref
self =
def test_set_symbolic_ref(self):
self._refs.set_symbolic_ref(b"refs/heads/symbolic", b"refs/heads/master")
> self.assertEqual(
b"ref: refs/heads/master",
self._refs.read_loose_ref(b"refs/heads/symbolic"),
)
E AssertionError: b'ref: refs/heads/master' != None
tests/test_refs.py:258: AssertionError
test_refs.py::DictRefsContainerTests::test_set_symbolic_ref_overwrite
test_refs.py::DictRefsContainerTests::test_set_symbolic_ref_overwrite
self =
def test_set_symbolic_ref_overwrite(self):
nines = b"9" * 40
self.assertNotIn(b"refs/heads/symbolic", self._refs)
self._refs[b"refs/heads/symbolic"] = nines
> self.assertEqual(nines, self._refs.read_loose_ref(b"refs/heads/symbolic"))
E AssertionError: b'9999999999999999999999999999999999999999' != None
tests/test_refs.py:271: AssertionError
test_refs.py::DictRefsContainerTests::test_setitem
test_refs.py::DictRefsContainerTests::test_setitem
self =
def test_setitem(self):
self._refs[b"refs/some/ref"] = b"42d06bd4b77fed026b154d16493e5deab78f02ec"
self.assertEqual(
b"42d06bd4b77fed026b154d16493e5deab78f02ec",
> self._refs[b"refs/some/ref"],
)
tests/test_refs.py:210:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
name = b'refs/some/ref'
def __getitem__(self, name):
"""Get the SHA1 for a reference name.
This method follows all symbolic references.
"""
> _, sha = self.follow(name)
E TypeError: cannot unpack non-iterable NoneType object
dulwich/refs.py:181: TypeError
test_refs.py::DiskRefsContainerTests::test_add_if_new
test_refs.py::DiskRefsContainerTests::test_add_if_new
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_add_if_new_packed
test_refs.py::DiskRefsContainerTests::test_add_if_new_packed
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_add_if_new_symbolic
test_refs.py::DiskRefsContainerTests::test_add_if_new_symbolic
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_add_packed_refs
test_refs.py::DiskRefsContainerTests::test_add_packed_refs
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_as_dict
test_refs.py::DiskRefsContainerTests::test_as_dict
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_check_refname
test_refs.py::DiskRefsContainerTests::test_check_refname
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_contains
test_refs.py::DiskRefsContainerTests::test_contains
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_cyrillic
test_refs.py::DiskRefsContainerTests::test_cyrillic
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_delete_refs_container
test_refs.py::DiskRefsContainerTests::test_delete_refs_container
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_delitem
test_refs.py::DiskRefsContainerTests::test_delitem
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_delitem_symbolic
test_refs.py::DiskRefsContainerTests::test_delitem_symbolic
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_follow
test_refs.py::DiskRefsContainerTests::test_follow
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_get_packed_refs
test_refs.py::DiskRefsContainerTests::test_get_packed_refs
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_get_peeled_not_packed
test_refs.py::DiskRefsContainerTests::test_get_peeled_not_packed
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_get_symrefs
test_refs.py::DiskRefsContainerTests::test_get_symrefs
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_import_refs_name
test_refs.py::DiskRefsContainerTests::test_import_refs_name
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_import_refs_name_prune
test_refs.py::DiskRefsContainerTests::test_import_refs_name_prune
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_iter
test_refs.py::DiskRefsContainerTests::test_iter
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_keys
test_refs.py::DiskRefsContainerTests::test_keys
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_non_ascii
test_refs.py::DiskRefsContainerTests::test_non_ascii
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_read_loose_ref
test_refs.py::DiskRefsContainerTests::test_read_loose_ref
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_read_ref
test_refs.py::DiskRefsContainerTests::test_read_ref
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_remove_if_equals
test_refs.py::DiskRefsContainerTests::test_remove_if_equals
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_remove_if_equals_packed
test_refs.py::DiskRefsContainerTests::test_remove_if_equals_packed
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_remove_if_equals_symref
test_refs.py::DiskRefsContainerTests::test_remove_if_equals_symref
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_remove_packed_without_peeled
test_refs.py::DiskRefsContainerTests::test_remove_packed_without_peeled
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_remove_parent
test_refs.py::DiskRefsContainerTests::test_remove_parent
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_set_if_equals
test_refs.py::DiskRefsContainerTests::test_set_if_equals
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_set_overwrite_loop
test_refs.py::DiskRefsContainerTests::test_set_overwrite_loop
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_set_symbolic_ref
test_refs.py::DiskRefsContainerTests::test_set_symbolic_ref
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_set_symbolic_ref_overwrite
test_refs.py::DiskRefsContainerTests::test_set_symbolic_ref_overwrite
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_setitem
test_refs.py::DiskRefsContainerTests::test_setitem
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_setitem_packed
test_refs.py::DiskRefsContainerTests::test_setitem_packed
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::DiskRefsContainerTests::test_setitem_symbolic
test_refs.py::DiskRefsContainerTests::test_setitem_symbolic
self =
def setUp(self):
TestCase.setUp(self)
self._repo = open_repo("refs.git")
self.addCleanup(tear_down_repo, self._repo)
> self._refs = self._repo.refs
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_refs.py:371: AttributeError
test_refs.py::InfoRefsContainerTests::test_as_dict
test_refs.py::InfoRefsContainerTests::test_as_dict
self =
def test_as_dict(self):
> refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
tests/test_refs.py:769:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
f = <_io.BytesIO object at 0x7eec1f828130>
def __init__(self, f) -> None:
self._refs = {}
self._peeled = {}
for line in f.readlines():
sha, name = line.rstrip(b'\n').split(b'\t')
if name.endswith(PEELED_TAG_SUFFIX):
name = name[:-3]
if not check_ref_format(name):
raise ValueError(f'invalid ref name {name!r}')
self._peeled[name] = sha
else:
if not check_ref_format(name):
> raise ValueError(f'invalid ref name {name!r}')
E ValueError: invalid ref name b'refs/heads/40-char-ref-aaaaaaaaaaaaaaaaaa'
dulwich/refs.py:302: ValueError
test_refs.py::InfoRefsContainerTests::test_contains
test_refs.py::InfoRefsContainerTests::test_contains
self =
def test_contains(self):
> refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
tests/test_refs.py:777:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
f = <_io.BytesIO object at 0x7eec1e9efba0>
def __init__(self, f) -> None:
self._refs = {}
self._peeled = {}
for line in f.readlines():
sha, name = line.rstrip(b'\n').split(b'\t')
if name.endswith(PEELED_TAG_SUFFIX):
name = name[:-3]
if not check_ref_format(name):
raise ValueError(f'invalid ref name {name!r}')
self._peeled[name] = sha
else:
if not check_ref_format(name):
> raise ValueError(f'invalid ref name {name!r}')
E ValueError: invalid ref name b'refs/heads/40-char-ref-aaaaaaaaaaaaaaaaaa'
dulwich/refs.py:302: ValueError
test_refs.py::InfoRefsContainerTests::test_get_peeled
test_refs.py::InfoRefsContainerTests::test_get_peeled
self =
def test_get_peeled(self):
> refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
tests/test_refs.py:782:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
f = <_io.BytesIO object at 0x7eec1eae30b0>
def __init__(self, f) -> None:
self._refs = {}
self._peeled = {}
for line in f.readlines():
sha, name = line.rstrip(b'\n').split(b'\t')
if name.endswith(PEELED_TAG_SUFFIX):
name = name[:-3]
if not check_ref_format(name):
raise ValueError(f'invalid ref name {name!r}')
self._peeled[name] = sha
else:
if not check_ref_format(name):
> raise ValueError(f'invalid ref name {name!r}')
E ValueError: invalid ref name b'refs/heads/40-char-ref-aaaaaaaaaaaaaaaaaa'
dulwich/refs.py:302: ValueError
test_refs.py::InfoRefsContainerTests::test_invalid_refname
test_refs.py::InfoRefsContainerTests::test_invalid_refname
self =
def test_invalid_refname(self):
text = _TEST_REFS_SERIALIZED + b"00" * 20 + b"\trefs/stash\n"
> refs = InfoRefsContainer(BytesIO(text))
tests/test_refs.py:744:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
f = <_io.BytesIO object at 0x7eec1e9ec8b0>
def __init__(self, f) -> None:
self._refs = {}
self._peeled = {}
for line in f.readlines():
sha, name = line.rstrip(b'\n').split(b'\t')
if name.endswith(PEELED_TAG_SUFFIX):
name = name[:-3]
if not check_ref_format(name):
raise ValueError(f'invalid ref name {name!r}')
self._peeled[name] = sha
else:
if not check_ref_format(name):
> raise ValueError(f'invalid ref name {name!r}')
E ValueError: invalid ref name b'refs/heads/40-char-ref-aaaaaaaaaaaaaaaaaa'
dulwich/refs.py:302: ValueError
test_refs.py::InfoRefsContainerTests::test_keys
test_refs.py::InfoRefsContainerTests::test_keys
self =
def test_keys(self):
> refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
tests/test_refs.py:752:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
f = <_io.BytesIO object at 0x7eec1eae3f10>
def __init__(self, f) -> None:
self._refs = {}
self._peeled = {}
for line in f.readlines():
sha, name = line.rstrip(b'\n').split(b'\t')
if name.endswith(PEELED_TAG_SUFFIX):
name = name[:-3]
if not check_ref_format(name):
raise ValueError(f'invalid ref name {name!r}')
self._peeled[name] = sha
else:
if not check_ref_format(name):
> raise ValueError(f'invalid ref name {name!r}')
E ValueError: invalid ref name b'refs/heads/40-char-ref-aaaaaaaaaaaaaaaaaa'
dulwich/refs.py:302: ValueError
test_refs.py::ParseSymrefValueTests::test_invalid
test_refs.py::ParseSymrefValueTests::test_invalid
self =
def test_invalid(self):
> self.assertRaises(ValueError, parse_symref_value, b"foobar")
E AssertionError: ValueError not raised by parse_symref_value
tests/test_refs.py:795: AssertionError
test_refs.py::ParseSymrefValueTests::test_valid
test_refs.py::ParseSymrefValueTests::test_valid
self =
def test_valid(self):
> self.assertEqual(b"refs/heads/foo", parse_symref_value(b"ref: refs/heads/foo"))
E AssertionError: b'refs/heads/foo' != None
tests/test_refs.py:792: AssertionError
test_server.py::HandlerTestCase::test_capability_line
test_server.py::HandlerTestCase::test_capability_line
self =
def test_capability_line(self):
> self.assertEqual(
b" cap1 cap2 cap3",
format_capability_line([b"cap1", b"cap2", b"cap3"]),
)
E AssertionError: b' cap1 cap2 cap3' != [b'cap1', b'cap2', b'cap3']
tests/test_server.py:123: AssertionError
test_server.py::HandlerTestCase::test_has_capability
test_server.py::HandlerTestCase::test_has_capability
self =
def test_has_capability(self):
> self.assertRaises(GitProtocolError, self._handler.has_capability, b"cap")
E AttributeError: 'TestGenericPackHandler' object has no attribute 'has_capability'
tests/test_server.py:147: AttributeError
test_server.py::HandlerTestCase::test_set_client_capabilities
test_server.py::HandlerTestCase::test_set_client_capabilities
self =
def test_set_client_capabilities(self):
> set_caps = self._handler.set_client_capabilities
E AttributeError: 'TestGenericPackHandler' object has no attribute 'set_client_capabilities'. Did you mean: '_client_capabilities'?
tests/test_server.py:129: AttributeError
test_server.py::UploadPackHandlerTestCase::test_get_tagged
test_server.py::UploadPackHandlerTestCase::test_get_tagged
self =
def test_get_tagged(self):
refs = {
b"refs/tags/tag1": ONE,
b"refs/tags/tag2": TWO,
b"refs/heads/master": FOUR, # not a tag, no peeled value
}
# repo needs to peel this object
> self._repo.object_store.add_object(make_commit(id=FOUR))
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:191: AttributeError
test_server.py::UploadPackHandlerTestCase::test_no_progress
test_server.py::UploadPackHandlerTestCase::test_no_progress
self =
def test_no_progress(self):
> caps = [*list(self._handler.required_capabilities()), b"no-progress"]
E TypeError: 'NoneType' object is not iterable
tests/test_server.py:178: TypeError
test_server.py::UploadPackHandlerTestCase::test_nothing_to_do_but_wants
test_server.py::UploadPackHandlerTestCase::test_nothing_to_do_but_wants
self =
def test_nothing_to_do_but_wants(self):
# Just the fact that the client claims to want an object is enough
# for sending a pack. Even if there turns out to be nothing.
refs = {b"refs/tags/tag1": ONE}
tree = Tree()
> self._repo.object_store.add_object(tree)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:218: AttributeError
test_server.py::UploadPackHandlerTestCase::test_nothing_to_do_no_wants
test_server.py::UploadPackHandlerTestCase::test_nothing_to_do_no_wants
self =
def test_nothing_to_do_no_wants(self):
# Don't send a pack if the client didn't ask for anything.
refs = {b"refs/tags/tag1": ONE}
tree = Tree()
> self._repo.object_store.add_object(tree)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:239: AttributeError
test_server.py::UploadPackHandlerTestCase::test_progress
test_server.py::UploadPackHandlerTestCase::test_progress
self =
def test_progress(self):
caps = self._handler.required_capabilities()
> self._handler.set_client_capabilities(caps)
E AttributeError: 'UploadPackHandler' object has no attribute 'set_client_capabilities'. Did you mean: '_client_capabilities'?
tests/test_server.py:169: AttributeError
test_server.py::FindShallowTests::test_linear
test_server.py::FindShallowTests::test_linear
self =
def test_linear(self):
> c1, c2, c3 = self.make_linear_commits(3)
tests/test_server.py:272:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , n = 3
message = b''
def make_linear_commits(self, n, message=b""):
commits = []
parents = []
for _ in range(n):
commits.append(self.make_commit(parents=parents, message=message))
> parents = [commits[-1].id]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_server.py:265: AttributeError
test_server.py::FindShallowTests::test_merge
test_server.py::FindShallowTests::test_merge
self =
def test_merge(self):
c1 = self.make_commit()
c2 = self.make_commit()
> c3 = self.make_commit(parents=[c1.id, c2.id])
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_server.py:317: AttributeError
test_server.py::FindShallowTests::test_multiple_independent
test_server.py::FindShallowTests::test_multiple_independent
self =
def test_multiple_independent(self):
> a = self.make_linear_commits(2, message=b"a")
tests/test_server.py:289:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 2, message = b'a'
def make_linear_commits(self, n, message=b""):
commits = []
parents = []
for _ in range(n):
commits.append(self.make_commit(parents=parents, message=message))
> parents = [commits[-1].id]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_server.py:265: AttributeError
test_server.py::FindShallowTests::test_multiple_overlapping
test_server.py::FindShallowTests::test_multiple_overlapping
self =
def test_multiple_overlapping(self):
# Create the following commit tree:
# 1--2
# \
# 3--4
> c1, c2 = self.make_linear_commits(2)
tests/test_server.py:304:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
n = 2, message = b''
def make_linear_commits(self, n, message=b""):
commits = []
parents = []
for _ in range(n):
commits.append(self.make_commit(parents=parents, message=message))
> parents = [commits[-1].id]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_server.py:265: AttributeError
test_server.py::FindShallowTests::test_tag
test_server.py::FindShallowTests::test_tag
self =
def test_tag(self):
> c1, c2 = self.make_linear_commits(2)
tests/test_server.py:325:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , n = 2
message = b''
def make_linear_commits(self, n, message=b""):
commits = []
parents = []
for _ in range(n):
commits.append(self.make_commit(parents=parents, message=message))
> parents = [commits[-1].id]
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_server.py:265: AttributeError
test_server.py::ReceivePackHandlerTestCase::test_apply_pack_del_ref
test_server.py::ReceivePackHandlerTestCase::test_apply_pack_del_ref
self =
def test_apply_pack_del_ref(self):
refs = {b"refs/heads/master": TWO, b"refs/heads/fake-branch": ONE}
> self._repo.refs._update(refs)
E AttributeError: 'NoneType' object has no attribute 'refs'
tests/test_server.py:352: AttributeError
test_server.py::ProtocolGraphWalkerEmptyTestCase::test_empty_repository
test_server.py::ProtocolGraphWalkerEmptyTestCase::test_empty_repository
self =
def setUp(self):
super().setUp()
self._repo = MemoryRepo.init_bare([], {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:371: AttributeError
test_server.py::ProtocolGraphWalkerTestCase::test_all_wants_satisfied
test_server.py::ProtocolGraphWalkerTestCase::test_all_wants_satisfied
self =
def setUp(self):
super().setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:405: AttributeError
test_server.py::ProtocolGraphWalkerTestCase::test_all_wants_satisfied_have_branch
test_server.py::ProtocolGraphWalkerTestCase::test_all_wants_satisfied_have_branch
self =
def setUp(self):
super().setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:405: AttributeError
test_server.py::ProtocolGraphWalkerTestCase::test_all_wants_satisfied_have_root
test_server.py::ProtocolGraphWalkerTestCase::test_all_wants_satisfied_have_root
self =
def setUp(self):
super().setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:405: AttributeError
test_server.py::ProtocolGraphWalkerTestCase::test_all_wants_satisfied_no_haves
test_server.py::ProtocolGraphWalkerTestCase::test_all_wants_satisfied_no_haves
self =
def setUp(self):
super().setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:405: AttributeError
test_server.py::ProtocolGraphWalkerTestCase::test_determine_wants
test_server.py::ProtocolGraphWalkerTestCase::test_determine_wants
self =
def setUp(self):
super().setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:405: AttributeError
test_server.py::ProtocolGraphWalkerTestCase::test_determine_wants_advertisement
test_server.py::ProtocolGraphWalkerTestCase::test_determine_wants_advertisement
self =
def setUp(self):
super().setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:405: AttributeError
test_server.py::ProtocolGraphWalkerTestCase::test_handle_shallow_request_no_client_shallows
test_server.py::ProtocolGraphWalkerTestCase::test_handle_shallow_request_no_client_shallows
self =
def setUp(self):
super().setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:405: AttributeError
test_server.py::ProtocolGraphWalkerTestCase::test_handle_shallow_request_no_new_shallows
test_server.py::ProtocolGraphWalkerTestCase::test_handle_shallow_request_no_new_shallows
self =
def setUp(self):
super().setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:405: AttributeError
test_server.py::ProtocolGraphWalkerTestCase::test_handle_shallow_request_unshallows
test_server.py::ProtocolGraphWalkerTestCase::test_handle_shallow_request_unshallows
self =
def setUp(self):
super().setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:405: AttributeError
test_server.py::ProtocolGraphWalkerTestCase::test_split_proto_line
test_server.py::ProtocolGraphWalkerTestCase::test_split_proto_line
self =
def setUp(self):
super().setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({b"/": self._repo})
self._walker = _ProtocolGraphWalker(
TestUploadPackHandler(backend, [b"/", b"host=lolcats"], TestProto()),
> self._repo.object_store,
self._repo.get_peeled,
self._repo.refs.get_symrefs,
)
E AttributeError: 'NoneType' object has no attribute 'object_store'
tests/test_server.py:405: AttributeError
test_server.py::SingleAckGraphWalkerImplTestCase::test_single_ack
test_server.py::SingleAckGraphWalkerImplTestCase::test_single_ack
self =
def test_single_ack(self):
> self.assertNextEquals(TWO)
tests/test_server.py:680:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::SingleAckGraphWalkerImplTestCase::test_single_ack_flush
test_server.py::SingleAckGraphWalkerImplTestCase::test_single_ack_flush
self =
def test_single_ack_flush(self):
# same as ack test but ends with a flush-pkt instead of done
self._walker.lines[-1] = (None, None)
> self.assertNextEquals(TWO)
tests/test_server.py:698:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::SingleAckGraphWalkerImplTestCase::test_single_ack_nak
test_server.py::SingleAckGraphWalkerImplTestCase::test_single_ack_nak
self =
def test_single_ack_nak(self):
> self.assertNextEquals(TWO)
tests/test_server.py:712:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::SingleAckGraphWalkerImplTestCase::test_single_ack_nak_flush
test_server.py::SingleAckGraphWalkerImplTestCase::test_single_ack_nak_flush
self =
def test_single_ack_nak_flush(self):
# same as nak test but ends with a flush-pkt instead of done
self._walker.lines[-1] = (None, None)
> self.assertNextEquals(TWO)
tests/test_server.py:729:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckGraphWalkerImplTestCase::test_multi_ack
test_server.py::MultiAckGraphWalkerImplTestCase::test_multi_ack
self =
def test_multi_ack(self):
> self.assertNextEquals(TWO)
tests/test_server.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckGraphWalkerImplTestCase::test_multi_ack_flush
test_server.py::MultiAckGraphWalkerImplTestCase::test_multi_ack_flush
self =
def test_multi_ack_flush(self):
self._walker.lines = [
(b"have", TWO),
(None, None),
(b"have", ONE),
(b"have", THREE),
(b"done", None),
]
> self.assertNextEquals(TWO)
tests/test_server.py:785:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckGraphWalkerImplTestCase::test_multi_ack_nak
test_server.py::MultiAckGraphWalkerImplTestCase::test_multi_ack_nak
self =
def test_multi_ack_nak(self):
> self.assertNextEquals(TWO)
tests/test_server.py:803:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckGraphWalkerImplTestCase::test_multi_ack_partial
test_server.py::MultiAckGraphWalkerImplTestCase::test_multi_ack_partial
self =
def test_multi_ack_partial(self):
> self.assertNextEquals(TWO)
tests/test_server.py:763:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack
self =
def test_multi_ack(self):
> self.assertNextEquals(TWO)
tests/test_server.py:821:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_flush
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_flush
self =
def test_multi_ack_flush(self):
# same as ack test but contains a flush-pkt in the middle
self._walker.lines = [
(b"have", TWO),
(None, None),
(b"have", ONE),
(b"have", THREE),
(b"done", None),
(None, None),
]
> self.assertNextEquals(TWO)
tests/test_server.py:933:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_flush_end
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_flush_end
self =
def test_multi_ack_flush_end(self):
# transmission ends with a flush-pkt without a done but no-done is
# assumed.
self._walker.lines[-1] = (None, None)
> self.assertNextEquals(TWO)
tests/test_server.py:867:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_flush_end_nodone
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_flush_end_nodone
self =
def test_multi_ack_flush_end_nodone(self):
# transmission ends with a flush-pkt without a done but no-done is
# assumed.
self._walker.lines[-1] = (None, None)
self._walker.done_required = False
> self.assertNextEquals(TWO)
tests/test_server.py:890:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_nak
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_nak
self =
def test_multi_ack_nak(self):
> self.assertNextEquals(TWO)
tests/test_server.py:952:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_nak_flush
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_nak_flush
self =
def test_multi_ack_nak_flush(self):
# same as nak test but contains a flush-pkt in the middle
self._walker.lines = [
(b"have", TWO),
(None, None),
(b"have", ONE),
(b"have", THREE),
(b"done", None),
]
> self.assertNextEquals(TWO)
tests/test_server.py:996:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_nak_nodone
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_nak_nodone
self =
def test_multi_ack_nak_nodone(self):
self._walker.done_required = False
> self.assertNextEquals(TWO)
tests/test_server.py:970:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_nodone
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_nodone
self =
def test_multi_ack_nodone(self):
self._walker.done_required = False
> self.assertNextEquals(TWO)
tests/test_server.py:843:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_partial
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_partial
self =
def test_multi_ack_partial(self):
> self.assertNextEquals(TWO)
tests/test_server.py:909:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_stateless
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_stateless
self =
def test_multi_ack_stateless(self):
# transmission ends with a flush-pkt
self._walker.lines[-1] = (None, None)
self._walker.stateless_rpc = True
> self.assertNextEquals(TWO)
tests/test_server.py:1014:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_stateless_nodone
test_server.py::MultiAckDetailedGraphWalkerImplTestCase::test_multi_ack_stateless_nodone
self =
def test_multi_ack_stateless_nodone(self):
self._walker.done_required = False
# transmission ends with a flush-pkt
self._walker.lines[-1] = (None, None)
self._walker.stateless_rpc = True
> self.assertNextEquals(TWO)
tests/test_server.py:1037:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
sha = b'2222222222222222222222222222222222222222'
def assertNextEquals(self, sha):
> self.assertEqual(sha, next(self._impl))
E TypeError: next expected at least 1 argument, got 0
tests/test_server.py:664: TypeError
test_server.py::FileSystemBackendTests::test_absolute
test_server.py::FileSystemBackendTests::test_absolute
self =
def test_absolute(self):
repo = self.backend.open_repository(self.path)
self.assertTrue(
os.path.samefile(
> os.path.abspath(repo.path), os.path.abspath(self.repo.path)
)
)
E AttributeError: 'NoneType' object has no attribute 'path'
tests/test_server.py:1080: AttributeError
test_server.py::FileSystemBackendTests::test_bad_repo_path
test_server.py::FileSystemBackendTests::test_bad_repo_path
self =
def test_bad_repo_path(self):
backend = FileSystemBackend()
> self.assertRaises(NotGitRepository, lambda: backend.open_repository("/ups"))
E AssertionError: NotGitRepository not raised by
tests/test_server.py:1094: AssertionError
test_server.py::FileSystemBackendTests::test_child
test_server.py::FileSystemBackendTests::test_child
self =
def test_child(self):
> self.assertRaises(
NotGitRepository,
self.backend.open_repository,
os.path.join(self.path, "foo"),
)
E AssertionError: NotGitRepository not raised by open_repository
tests/test_server.py:1085: AssertionError
test_server.py::FileSystemBackendTests::test_nonexistant
test_server.py::FileSystemBackendTests::test_nonexistant
self =
def test_nonexistant(self):
> self.assertRaises(
NotGitRepository,
self.backend.open_repository,
"/does/not/exist/unless/foo",
)
E AssertionError: NotGitRepository not raised by open_repository
tests/test_server.py:1070: AssertionError
test_server.py::DictBackendTests::test_bad_repo_path
test_server.py::DictBackendTests::test_bad_repo_path
self =
def test_bad_repo_path(self):
repo = MemoryRepo.init_bare([], {})
backend = DictBackend({b"/": repo})
> self.assertRaises(NotGitRepository, lambda: backend.open_repository("/ups"))
E AssertionError: NotGitRepository not raised by
tests/test_server.py:1113: AssertionError
test_server.py::DictBackendTests::test_nonexistant
test_server.py::DictBackendTests::test_nonexistant
self =
def test_nonexistant(self):
repo = MemoryRepo.init_bare([], {})
backend = DictBackend({b"/": repo})
> self.assertRaises(
NotGitRepository,
backend.open_repository,
"/does/not/exist/unless/foo",
)
E AssertionError: NotGitRepository not raised by open_repository
tests/test_server.py:1103: AssertionError
test_server.py::ServeCommandTests::test_receive_pack
test_server.py::ServeCommandTests::test_receive_pack
self =
def test_receive_pack(self):
commit = make_commit(id=ONE, parents=[], commit_time=111)
self.backend.repos[b"/"] = MemoryRepo.init_bare(
> [commit], {b"refs/heads/master": commit.id}
)
E AttributeError: 'NoneType' object has no attribute 'id'
tests/test_server.py:1135: AttributeError
test_server.py::UpdateServerInfoTests::test_empty
test_server.py::UpdateServerInfoTests::test_empty
self =
def test_empty(self):
update_server_info(self.repo)
> with open(os.path.join(self.path, ".git", "info", "refs"), "rb") as f:
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpbx1hjo5n/.git/info/refs'
tests/test_server.py:1162: FileNotFoundError
test_server.py::UpdateServerInfoTests::test_simple
test_server.py::UpdateServerInfoTests::test_simple
self =
def test_simple(self):
> commit_id = self.repo.do_commit(
message=b"foo",
committer=b"Joe Example ",
ref=b"refs/heads/foo",
)
E AttributeError: 'NoneType' object has no attribute 'do_commit'
tests/test_server.py:1169: AttributeError
test_stash.py::StashTests::test_obtain
test_stash.py::StashTests::test_obtain
self =
def test_obtain(self):
> repo = MemoryRepo()
tests/test_stash.py:33:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
def __init__(self) -> None:
from .config import ConfigFile
self._reflog: List[Any] = []
> refs_container = DictRefsContainer({}, logger=self._append_reflog)
E AttributeError: 'MemoryRepo' object has no attribute '_append_reflog'
dulwich/repo.py:826: AttributeError
test_utils.py::BuildCommitGraphTest::test_attrs
test_utils.py::BuildCommitGraphTest::test_attrs
self =
def test_attrs(self):
> c1, c2 = build_commit_graph(
self.store, [[1], [2, 1]], attrs={1: {"message": b"Hooray!"}}
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_utils.py:70: TypeError
test_utils.py::BuildCommitGraphTest::test_commit_time
test_utils.py::BuildCommitGraphTest::test_commit_time
self =
def test_commit_time(self):
> c1, c2, c3 = build_commit_graph(
self.store,
[[1], [2, 1], [3, 2]],
attrs={1: {"commit_time": 124}, 2: {"commit_time": 123}},
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_utils.py:77: TypeError
test_utils.py::BuildCommitGraphTest::test_linear
test_utils.py::BuildCommitGraphTest::test_linear
self =
def test_linear(self):
> c1, c2 = build_commit_graph(self.store, [[1], [2, 1]])
E TypeError: cannot unpack non-iterable NoneType object
tests/test_utils.py:36: TypeError
test_utils.py::BuildCommitGraphTest::test_merge
test_utils.py::BuildCommitGraphTest::test_merge
self =
def test_merge(self):
> c1, c2, c3, c4 = build_commit_graph(
self.store, [[1], [2, 1], [3, 1], [4, 2, 3]]
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_utils.py:46: TypeError
test_utils.py::BuildCommitGraphTest::test_missing_parent
test_utils.py::BuildCommitGraphTest::test_missing_parent
self =
def test_missing_parent(self):
> self.assertRaises(
ValueError, build_commit_graph, self.store, [[1], [3, 2], [2, 1]]
)
E AssertionError: ValueError not raised by build_commit_graph
tests/test_utils.py:54: AssertionError
test_utils.py::BuildCommitGraphTest::test_trees
test_utils.py::BuildCommitGraphTest::test_trees
self =
def test_trees(self):
a1 = make_object(Blob, data=b"aaa1")
a2 = make_object(Blob, data=b"aaa2")
> c1, c2 = build_commit_graph(
self.store,
[[1], [2, 1]],
trees={1: [(b"a", a1)], 2: [(b"a", a2, 0o100644)]},
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_utils.py:61: TypeError
test_walk.py::WalkerTest::test_branch
test_walk.py::WalkerTest::test_branch
self =
def test_branch(self):
> c1, x2, x3, y4 = self.make_commits([[1], [2, 1], [3, 2], [4, 1]])
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:111: TypeError
test_walk.py::WalkerTest::test_changes_multiple_parents
test_walk.py::WalkerTest::test_changes_multiple_parents
self =
def test_changes_multiple_parents(self):
blob_a1 = make_object(Blob, data=b"a1")
blob_b2 = make_object(Blob, data=b"b2")
blob_a3 = make_object(Blob, data=b"a3")
> c1, c2, c3 = self.make_commits(
[[1], [2], [3, 1, 2]],
trees={
1: [(b"a", blob_a1)],
2: [(b"b", blob_b2)],
3: [(b"a", blob_a3), (b"b", blob_b2)],
},
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:197: TypeError
test_walk.py::WalkerTest::test_changes_one_parent
test_walk.py::WalkerTest::test_changes_one_parent
self =
def test_changes_one_parent(self):
blob_a1 = make_object(Blob, data=b"a1")
blob_a2 = make_object(Blob, data=b"a2")
blob_b2 = make_object(Blob, data=b"b2")
> c1, c2 = self.make_linear_commits(
2,
trees={
1: [(b"a", blob_a1)],
2: [(b"a", blob_a2), (b"b", blob_b2)],
},
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:176: TypeError
test_walk.py::WalkerTest::test_changes_with_renames
test_walk.py::WalkerTest::test_changes_with_renames
self =
def test_changes_with_renames(self):
blob = make_object(Blob, data=b"blob")
> c1, c2 = self.make_linear_commits(
2, trees={1: [(b"a", blob)], 2: [(b"b", blob)]}
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:299: TypeError
test_walk.py::WalkerTest::test_empty_walk
test_walk.py::WalkerTest::test_empty_walk
self =
def test_empty_walk(self):
> c1, c2, c3 = self.make_linear_commits(3)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:476: TypeError
test_walk.py::WalkerTest::test_follow_rename
test_walk.py::WalkerTest::test_follow_rename
self =
def test_follow_rename(self):
blob = make_object(Blob, data=b"blob")
names = [b"a", b"a", b"b", b"b", b"c", b"c"]
trees = {i + 1: [(n, blob, F)] for i, n in enumerate(names)}
> c1, c2, c3, c4, c5, c6 = self.make_linear_commits(6, trees=trees)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:327: TypeError
test_walk.py::WalkerTest::test_follow_rename_remove_path
test_walk.py::WalkerTest::test_follow_rename_remove_path
self =
def test_follow_rename_remove_path(self):
blob = make_object(Blob, data=b"blob")
> _, _, _, c4, c5, c6 = self.make_linear_commits(
6,
trees={
1: [(b"a", blob), (b"c", blob)],
2: [],
3: [],
4: [(b"b", blob)],
5: [(b"a", blob)],
6: [(b"c", blob)],
},
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:346: TypeError
test_walk.py::WalkerTest::test_linear
test_walk.py::WalkerTest::test_linear
self =
def test_linear(self):
> c1, c2, c3 = self.make_linear_commits(3)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:89: TypeError
test_walk.py::WalkerTest::test_max_entries
test_walk.py::WalkerTest::test_max_entries
self =
def test_max_entries(self):
> c1, c2, c3 = self.make_linear_commits(3)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:161: TypeError
test_walk.py::WalkerTest::test_merge
test_walk.py::WalkerTest::test_merge
self =
def test_merge(self):
> c1, c2, c3, c4 = self.make_commits([[1], [2, 1], [3, 1], [4, 2, 3]])
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:121: TypeError
test_walk.py::WalkerTest::test_merge_of_new_branch_from_old_base
test_walk.py::WalkerTest::test_merge_of_new_branch_from_old_base
self =
def test_merge_of_new_branch_from_old_base(self):
# The commit on the branch was made at a time after any of the
# commits on master, but the branch was from an older commit.
# See also test_merge_of_old_branch
self.maxDiff = None
> c1, c2, c3, c4, c5 = self.make_commits(
[[1], [2, 1], [3, 2], [4, 1], [5, 3, 4]],
times=[1, 2, 3, 4, 5],
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:133: TypeError
test_walk.py::WalkerTest::test_merge_of_old_branch
test_walk.py::WalkerTest::test_merge_of_old_branch
self =
testcase =
rawexcinfo = (, TypeError('cannot unpack non-iterable NoneType object'), )
reason = ''
def addExpectedFailure(
self,
testcase: unittest.TestCase,
rawexcinfo: _SysExcInfoType,
reason: str = "",
) -> None:
try:
> xfail(str(reason))
E _pytest.outcomes.XFailed
.venv/lib/python3.10/site-packages/_pytest/unittest.py:295: XFailed
test_walk.py::WalkerTest::test_missing
test_walk.py::WalkerTest::test_missing
self =
def test_missing(self):
> cs = list(reversed(self.make_linear_commits(20)))
E TypeError: 'NoneType' object is not reversible
tests/test_walk.py:99: TypeError
test_walk.py::WalkerTest::test_out_of_order_children
test_walk.py::WalkerTest::test_out_of_order_children
self =
def test_out_of_order_children(self):
> c1, c2, c3, c4, c5 = self.make_commits(
[[1], [2, 1], [3, 2], [4, 1], [5, 3, 4]], times=[2, 1, 3, 4, 5]
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:454: TypeError
test_walk.py::WalkerTest::test_out_of_order_with_exclude
test_walk.py::WalkerTest::test_out_of_order_with_exclude
self =
def test_out_of_order_with_exclude(self):
# Create the following graph:
# c1-------x2---m6
# \ /
# \-y3--y4-/--y5
# Due to skew, y5 is the oldest commit.
> c1, x2, y3, y4, y5, m6 = self.make_commits(
[[1], [2, 1], [3, 1], [4, 3], [5, 4], [6, 2, 4]],
times=[2, 3, 4, 5, 1, 6],
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:466: TypeError
test_walk.py::WalkerTest::test_path_matches
test_walk.py::WalkerTest::test_path_matches
self =
def test_path_matches(self):
walker = Walker(None, [], paths=[b"foo", b"bar", b"baz/quux"])
> self.assertTrue(walker._path_matches(b"foo"))
E AttributeError: 'Walker' object has no attribute '_path_matches'
tests/test_walk.py:218: AttributeError
test_walk.py::WalkerTest::test_paths
test_walk.py::WalkerTest::test_paths
self =
def test_paths(self):
blob_a1 = make_object(Blob, data=b"a1")
blob_b2 = make_object(Blob, data=b"b2")
blob_a3 = make_object(Blob, data=b"a3")
blob_b3 = make_object(Blob, data=b"b3")
> c1, c2, c3 = self.make_linear_commits(
3,
trees={
1: [(b"a", blob_a1)],
2: [(b"a", blob_a1), (b"x/b", blob_b2)],
3: [(b"a", blob_a3), (b"x/b", blob_b3)],
},
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:236: TypeError
test_walk.py::WalkerTest::test_paths_max_entries
test_walk.py::WalkerTest::test_paths_max_entries
self =
def test_paths_max_entries(self):
blob_a = make_object(Blob, data=b"a")
blob_b = make_object(Blob, data=b"b")
> c1, c2 = self.make_linear_commits(
2, trees={1: [(b"a", blob_a)], 2: [(b"a", blob_a), (b"b", blob_b)]}
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:275: TypeError
test_walk.py::WalkerTest::test_paths_merge
test_walk.py::WalkerTest::test_paths_merge
self =
def test_paths_merge(self):
blob_a1 = make_object(Blob, data=b"a1")
blob_a2 = make_object(Blob, data=b"a2")
blob_a3 = make_object(Blob, data=b"a3")
> x1, y2, m3, m4 = self.make_commits(
[[1], [2], [3, 1, 2], [4, 1, 2]],
trees={
1: [(b"a", blob_a1)],
2: [(b"a", blob_a2)],
3: [(b"a", blob_a3)],
4: [(b"a", blob_a1)],
},
) # Non-conflicting
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:285: TypeError
test_walk.py::WalkerTest::test_paths_subtree
test_walk.py::WalkerTest::test_paths_subtree
self =
def test_paths_subtree(self):
blob_a = make_object(Blob, data=b"a")
blob_b = make_object(Blob, data=b"b")
> c1, c2, c3 = self.make_linear_commits(
3,
trees={
1: [(b"x/a", blob_a)],
2: [(b"b", blob_b), (b"x/a", blob_a)],
3: [(b"b", blob_b), (b"x/a", blob_a), (b"x/b", blob_b)],
},
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:261: TypeError
test_walk.py::WalkerTest::test_reverse
test_walk.py::WalkerTest::test_reverse
self =
def test_reverse(self):
> c1, c2, c3 = self.make_linear_commits(3)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:157: TypeError
test_walk.py::WalkerTest::test_reverse_after_max_entries
test_walk.py::WalkerTest::test_reverse_after_max_entries
self =
def test_reverse_after_max_entries(self):
> c1, c2, c3 = self.make_linear_commits(3)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:167: TypeError
test_walk.py::WalkerTest::test_since
test_walk.py::WalkerTest::test_since
self =
def test_since(self):
> c1, c2, c3 = self.make_linear_commits(3)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:374: TypeError
test_walk.py::WalkerTest::test_since_over_scan
test_walk.py::WalkerTest::test_since_over_scan
self =
def test_since_over_scan(self):
commits = self.make_linear_commits(11, times=[9, 0, 1, 2, 3, 4, 5, 8, 6, 7, 9])
> c8, _, c10, c11 = commits[-4:]
E TypeError: 'NoneType' object is not subscriptable
tests/test_walk.py:408: TypeError
test_walk.py::WalkerTest::test_since_until
test_walk.py::WalkerTest::test_since_until
self =
def test_since_until(self):
> c1, c2, c3 = self.make_linear_commits(3)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:400: TypeError
test_walk.py::WalkerTest::test_tag
test_walk.py::WalkerTest::test_tag
self =
def test_tag(self):
> c1, c2, c3 = self.make_linear_commits(3)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:83: TypeError
test_walk.py::WalkerTest::test_topo_reorder_linear
test_walk.py::WalkerTest::test_topo_reorder_linear
self =
def test_topo_reorder_linear(self):
commits = self.make_linear_commits(5)
> commits.reverse()
E AttributeError: 'NoneType' object has no attribute 'reverse'
tests/test_walk.py:423: AttributeError
test_walk.py::WalkerTest::test_topo_reorder_multiple_children
test_walk.py::WalkerTest::test_topo_reorder_multiple_children
self =
def test_topo_reorder_multiple_children(self):
> c1, c2, c3 = self.make_commits([[1], [2, 1], [3, 1]])
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:442: TypeError
test_walk.py::WalkerTest::test_topo_reorder_multiple_parents
test_walk.py::WalkerTest::test_topo_reorder_multiple_parents
self =
def test_topo_reorder_multiple_parents(self):
> c1, c2, c3 = self.make_commits([[1], [2], [3, 1, 2]])
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:428: TypeError
test_walk.py::WalkerTest::test_until
test_walk.py::WalkerTest::test_until
self =
def test_until(self):
> c1, c2, c3 = self.make_linear_commits(3)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:387: TypeError
test_walk.py::WalkEntryTest::test_all_changes
test_walk.py::WalkEntryTest::test_all_changes
self =
def test_all_changes(self):
# Construct a commit with 2 files in different subdirectories.
blob_a = make_object(Blob, data=b"a")
blob_b = make_object(Blob, data=b"b")
> c1 = self.make_linear_commits(
1,
trees={1: [(b"x/a", blob_a), (b"y/b", blob_b)]},
)[0]
E TypeError: 'NoneType' object is not subscriptable
tests/test_walk.py:505: TypeError
test_walk.py::WalkEntryTest::test_all_with_merge
test_walk.py::WalkEntryTest::test_all_with_merge
self =
def test_all_with_merge(self):
blob_a = make_object(Blob, data=b"a")
blob_a2 = make_object(Blob, data=b"a2")
blob_b = make_object(Blob, data=b"b")
blob_b2 = make_object(Blob, data=b"b2")
> x1, y2, m3 = self.make_commits(
[[1], [2], [3, 1, 2]],
trees={
1: [(b"x/a", blob_a)],
2: [(b"y/b", blob_b)],
3: [(b"x/a", blob_a2), (b"y/b", blob_b2)],
},
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:528: TypeError
test_walk.py::WalkEntryTest::test_filter_changes
test_walk.py::WalkEntryTest::test_filter_changes
self =
def test_filter_changes(self):
# Construct a commit with 2 files in different subdirectories.
blob_a = make_object(Blob, data=b"a")
blob_b = make_object(Blob, data=b"b")
> c1 = self.make_linear_commits(
1,
trees={1: [(b"x/a", blob_a), (b"y/b", blob_b)]},
)[0]
E TypeError: 'NoneType' object is not subscriptable
tests/test_walk.py:567: TypeError
test_walk.py::WalkEntryTest::test_filter_with_merge
test_walk.py::WalkEntryTest::test_filter_with_merge
self =
def test_filter_with_merge(self):
blob_a = make_object(Blob, data=b"a")
blob_a2 = make_object(Blob, data=b"a2")
blob_b = make_object(Blob, data=b"b")
blob_b2 = make_object(Blob, data=b"b2")
> x1, y2, m3 = self.make_commits(
[[1], [2], [3, 1, 2]],
trees={
1: [(b"x/a", blob_a)],
2: [(b"y/b", blob_b)],
3: [(b"x/a", blob_a2), (b"y/b", blob_b2)],
},
)
E TypeError: cannot unpack non-iterable NoneType object
tests/test_walk.py:589: TypeError
Patch diff
diff --git a/dulwich/bundle.py b/dulwich/bundle.py
index f8ccfd2f..9386bab6 100644
--- a/dulwich/bundle.py
+++ b/dulwich/bundle.py
@@ -27,6 +27,34 @@ class Bundle:
return False
return True
+def write_bundle(f, bundle: Bundle) -> None:
+ """Write a bundle file.
+
+ Args:
+ f: File-like object to write to
+ bundle: Bundle object to write
+ """
+ if bundle.version is None:
+ f.write(b'# v2 git bundle\n')
+ else:
+ f.write(f'# v{bundle.version} git bundle\n'.encode('ascii'))
+
+ for key, value in sorted(bundle.capabilities.items()):
+ f.write(f'{key} {value}\n'.encode('ascii'))
+
+ for sha, message in bundle.prerequisites:
+ f.write(b'-' + sha + b' ' + message.encode('utf-8') + b'\n')
+
+ for name, sha in sorted(bundle.references.items()):
+ f.write(sha + b' ' + name.encode('utf-8') + b'\n')
+
+ f.write(b'\n')
+ if isinstance(bundle.pack_data, PackData):
+ write_pack_data(f, bundle.pack_data.iterobjects())
+ else:
+ for chunk in bundle.pack_data:
+ f.write(chunk)
+
def read_bundle(f):
"""Read a bundle file."""
pass
\ No newline at end of file
diff --git a/dulwich/client.py b/dulwich/client.py
index 0c7a0014..3981dca3 100644
--- a/dulwich/client.py
+++ b/dulwich/client.py
@@ -805,7 +805,7 @@ class Urllib3HttpGitClient(AbstractHttpGitClient):
else:
self.pool_manager = pool_manager
if username is not None:
- credentials = f'{username}:{password or ''}'
+ credentials = f'{username}:{password or ""}'
import urllib3.util
basic_auth = urllib3.util.make_headers(basic_auth=credentials)
self.pool_manager.headers.update(basic_auth)
diff --git a/dulwich/config.py b/dulwich/config.py
index 3295d2e1..68659e00 100644
--- a/dulwich/config.py
+++ b/dulwich/config.py
@@ -158,9 +158,91 @@ _ESCAPE_TABLE = {ord(b'\\'): ord(b'\\'), ord(b'"'): ord(b'"'), ord(b'n'): ord(b'
_COMMENT_CHARS = [ord(b'#'), ord(b';')]
_WHITESPACE_CHARS = [ord(b'\t'), ord(b' ')]
+def _check_variable_name(name: bytes) -> bool:
+ """Check that a variable name is valid.
+
+ Args:
+ name: Name to check
+ Returns: boolean indicating whether the name is valid
+ """
+ for c in name:
+ if c in (ord(b' '), ord(b','), ord(b'\\'), ord(b'"'), ord(b'.')):
+ return False
+ return True
+
+def _check_section_name(name: bytes) -> bool:
+ """Check that a section name is valid.
+
+ Args:
+ name: Name to check
+ Returns: boolean indicating whether the name is valid
+ """
+ for c in name:
+ if c in (ord(b' '), ord(b','), ord(b'\\'), ord(b'"')):
+ return False
+ return True
+
+def get_xdg_config_home_path(*args) -> str:
+ """Get the XDG config home path.
+
+ Args:
+ *args: Path components to join to the XDG config home path
+ Returns: Path to XDG config home directory
+ """
+ path = os.environ.get('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
+ return os.path.join(path, *args)
+
+def _parse_string(value: bytes) -> bytes:
+ """Parse a string from a git config file.
+
+ Args:
+ value: The string to parse
+ Returns: The parsed string
+ """
+ if value.startswith(b'"') and value.endswith(b'"'):
+ value = value[1:-1]
+ i = 0
+ ret = []
+ while i < len(value):
+ if value[i] == ord(b'\\'):
+ i += 1
+ if i >= len(value):
+ break
+ c = value[i]
+ if c == ord(b'\\'):
+ ret.append(ord(b'\\'))
+ elif c == ord(b'n'):
+ ret.append(ord(b'\n'))
+ elif c == ord(b't'):
+ ret.append(ord(b'\t'))
+ elif c == ord(b'"'):
+ ret.append(ord(b'"'))
+ elif c == ord(b'b'):
+ ret.append(ord(b'\b'))
+ else:
+ ret.append(c)
+ else:
+ ret.append(value[i])
+ i += 1
+ return bytes(ret)
+ return value
+
+def _format_string(value: bytes) -> bytes:
+ """Format a string for inclusion in a git config file.
+
+ Args:
+ value: The string to format
+ Returns: The formatted string
+ """
+ if any(c in value for c in (ord(b'\n'), ord(b'\t'), ord(b'"'))):
+ return b'"' + value.replace(b'\\', b'\\\\').replace(b'\n', b'\\n').replace(b'\t', b'\\t').replace(b'"', b'\\"') + b'"'
+ return value
+
def _escape_value(value: bytes) -> bytes:
"""Escape a value."""
- pass
+ if value.startswith(b'"') and value.endswith(b'"'):
+ return value[1:-1].replace(b'\\\\', b'\\').replace(b'\\n', b'\n').replace(b'\\t', b'\t').replace(b'\\"', b'"')
+ return value
class ConfigFile(ConfigDict):
"""A Git configuration file, like .git/config or ~/.gitconfig."""
diff --git a/dulwich/credentials.py b/dulwich/credentials.py
index 92155898..821b81c2 100644
--- a/dulwich/credentials.py
+++ b/dulwich/credentials.py
@@ -8,9 +8,27 @@ from typing import Iterator, Optional
from urllib.parse import ParseResult, urlparse
from .config import ConfigDict, SectionLike
+def match_urls(url1: str, url2: str) -> bool:
+ """Match two URLs.
+
+ Args:
+ url1: First URL to match
+ url2: Second URL to match
+ Returns: True if URLs match, False otherwise
+ """
+ parsed1 = urlparse(url1)
+ parsed2 = urlparse(url2)
+ return (parsed1.scheme == parsed2.scheme and
+ parsed1.netloc == parsed2.netloc and
+ parsed1.path == parsed2.path)
+
def match_partial_url(valid_url: ParseResult, partial_url: str) -> bool:
"""Matches a parsed url with a partial url (no scheme/netloc)."""
- pass
+ if not partial_url:
+ return True
+ if partial_url.startswith('/'):
+ return valid_url.path == partial_url
+ return valid_url.path.endswith(partial_url)
def urlmatch_credential_sections(config: ConfigDict, url: Optional[str]) -> Iterator[SectionLike]:
"""Returns credential sections from the config which match the given URL."""
diff --git a/dulwich/diff_tree.py b/dulwich/diff_tree.py
index e4ed578e..c2fcfc7a 100644
--- a/dulwich/diff_tree.py
+++ b/dulwich/diff_tree.py
@@ -22,6 +22,21 @@ REWRITE_THRESHOLD = None
class TreeChange(namedtuple('TreeChange', ['type', 'old', 'new'])):
"""Named tuple a single change between two trees."""
+def _is_tree(mode: int) -> bool:
+ """Return True if the mode indicates this is a tree."""
+ return stat.S_ISDIR(mode)
+
+def _tree_change_key(entry):
+ """Sort key for tree changes.
+
+ Args:
+ entry: TreeEntry to get sort key for
+ Returns: Sort key for the entry
+ """
+ if entry.type == b'tree':
+ return entry.path + b'/'
+ return entry.path
+
def _merge_entries(path, tree1, tree2):
"""Merge the entries of two trees.
@@ -36,7 +51,22 @@ def _merge_entries(path, tree1, tree2):
entry will have all attributes set to None. If neither entry's path is
None, they are guaranteed to match.
"""
- pass
+ entries = []
+ if tree1 is None:
+ for entry in tree2.iteritems():
+ entries.append((_NULL_ENTRY, entry))
+ elif tree2 is None:
+ for entry in tree1.iteritems():
+ entries.append((entry, _NULL_ENTRY))
+ else:
+ entries1 = dict(tree1.iteritems())
+ entries2 = dict(tree2.iteritems())
+ all_keys = set(entries1) | set(entries2)
+ for key in sorted(all_keys):
+ entry1 = entries1.get(key, _NULL_ENTRY)
+ entry2 = entries2.get(key, _NULL_ENTRY)
+ entries.append((entry1, entry2))
+ return entries
def walk_trees(store, tree1_id, tree2_id, prune_identical=False):
"""Recursively walk all the entries of two trees.
diff --git a/dulwich/graph.py b/dulwich/graph.py
index acde4e6a..a94091ef 100644
--- a/dulwich/graph.py
+++ b/dulwich/graph.py
@@ -7,6 +7,53 @@ class WorkList:
def __init__(self):
self.pq = []
+def _find_lcas(repo, commit_ids):
+ """Find lowest common ancestors of commit_ids.
+
+ Args:
+ repo: Repository object
+ commit_ids: list of commit ids
+ Returns:
+ list of lowest common ancestor commit_ids
+ """
+ if not commit_ids:
+ return []
+ if len(commit_ids) == 1:
+ return [commit_ids[0]]
+
+ # Build a list of all commits reachable from each commit_id
+ reachable = []
+ for commit_id in commit_ids:
+ reachable_from_commit = set()
+ worklist = [commit_id]
+ while worklist:
+ commit_id = worklist.pop()
+ if commit_id in reachable_from_commit:
+ continue
+ reachable_from_commit.add(commit_id)
+ commit = repo[commit_id]
+ worklist.extend(commit.parents)
+ reachable.append(reachable_from_commit)
+
+ # Find the intersection of all reachable sets
+ lcas = reachable[0]
+ for r in reachable[1:]:
+ lcas &= r
+
+ # Remove commits that have descendants in lcas
+ result = set(lcas)
+ for commit_id in lcas:
+ commit = repo[commit_id]
+ worklist = list(commit.parents)
+ while worklist:
+ parent_id = worklist.pop()
+ if parent_id in result:
+ result.remove(parent_id)
+ parent = repo[parent_id]
+ worklist.extend(parent.parents)
+
+ return sorted(result)
+
def find_merge_base(repo, commit_ids):
"""Find lowest common ancestors of commit_ids[0] and *any* of commits_ids[1:].
@@ -16,7 +63,16 @@ def find_merge_base(repo, commit_ids):
Returns:
list of lowest common ancestor commit_ids
"""
- pass
+ if not commit_ids:
+ return []
+ if len(commit_ids) == 1:
+ return [commit_ids[0]]
+
+ # Find LCAs between first commit and each other commit
+ result = set(_find_lcas(repo, [commit_ids[0], commit_ids[1]]))
+ for commit_id in commit_ids[2:]:
+ result |= set(_find_lcas(repo, [commit_ids[0], commit_id]))
+ return sorted(result)
def find_octopus_base(repo, commit_ids):
"""Find lowest common ancestors of *all* provided commit_ids.
diff --git a/dulwich/index.py b/dulwich/index.py
index 769a9723..caead9e5 100644
--- a/dulwich/index.py
+++ b/dulwich/index.py
@@ -326,9 +326,46 @@ def build_file_from_blob(blob: Blob, mode: int, target_path: bytes, *, honor_fil
pass
INVALID_DOTNAMES = (b'.git', b'.', b'..', b'')
+def validate_path_element_ntfs(element: bytes) -> bool:
+ """NTFS path validator.
+
+ Args:
+ element: Path element to validate
+ Returns: True if the path element is valid, False otherwise
+ """
+ if element in INVALID_DOTNAMES:
+ return False
+ if element.endswith(b'.'):
+ return False
+ if element.endswith(b' '):
+ return False
+ if any(c in element for c in (ord(b':'), ord(b'<'), ord(b'>'), ord(b'"'), ord(b'|'), ord(b'?'), ord(b'*'))):
+ return False
+ if any(c < 32 for c in element):
+ return False
+ return True
+
+def validate_path_element_default(element: bytes) -> bool:
+ """Default path validator that just checks for .git/.
+
+ Args:
+ element: Path element to validate
+ Returns: True if the path element is valid, False otherwise
+ """
+ return element not in INVALID_DOTNAMES
+
def validate_path(path: bytes, element_validator=validate_path_element_default) -> bool:
- """Default path validator that just checks for .git/."""
- pass
+ """Default path validator that just checks for .git/.
+
+ Args:
+ path: Path to validate
+ element_validator: Function to validate path elements
+ Returns: True if the path is valid, False otherwise
+ """
+ for element in path.split(b'/'):
+ if not element_validator(element):
+ return False
+ return True
def build_index_from_tree(root_path: Union[str, bytes], index_path: Union[str, bytes], object_store: ObjectContainer, tree_id: bytes, honor_filemode: bool=True, validate_path_element=validate_path_element_default, symlink_fn=None):
"""Generate and materialize index from a tree.
diff --git a/dulwich/objects.py b/dulwich/objects.py
index 2f7197ce..eb625fa3 100644
--- a/dulwich/objects.py
+++ b/dulwich/objects.py
@@ -40,31 +40,43 @@ def S_ISGITLINK(m):
m: Mode to check
Returns: a ``boolean``
"""
- pass
+ return (m & 0o170000) == S_IFGITLINK
def sha_to_hex(sha):
"""Takes a string and returns the hex of the sha within."""
- pass
+ return binascii.hexlify(sha)
def hex_to_sha(hex):
"""Takes a hex sha and returns a binary sha."""
- pass
+ return binascii.unhexlify(hex)
def hex_to_filename(path, hex):
"""Takes a hex sha and returns its filename relative to the given path."""
- pass
+ dir = os.path.join(path, hex[:2])
+ return os.path.join(dir, hex[2:])
def filename_to_hex(filename):
"""Takes an object filename and returns its corresponding hex sha."""
- pass
+ if os.path.sep != '/':
+ filename = filename.replace(os.path.sep, '/')
+ base = os.path.basename(filename)
+ dir = os.path.basename(os.path.dirname(filename))
+ return dir + base
def object_header(num_type: int, length: int) -> bytes:
"""Return an object header for the given numeric type and text length."""
- pass
+ return ('%s %d\0' % (object_class(num_type).type_name.decode('ascii'), length)).encode('ascii')
def serializable_property(name: str, docstring: Optional[str]=None):
"""A property that helps tracking whether serialization is necessary."""
- pass
+ def set(obj, value):
+ setattr(obj, '_' + name, value)
+ obj._needs_serialization = True
+
+ def get(obj):
+ return getattr(obj, '_' + name)
+
+ return property(get, set, doc=docstring)
def object_class(type: Union[bytes, int]) -> Optional[Type['ShaFile']]:
"""Get the object class corresponding to the given type.
@@ -74,7 +86,33 @@ def object_class(type: Union[bytes, int]) -> Optional[Type['ShaFile']]:
Returns: The ShaFile subclass corresponding to the given type, or None if
type is not a valid type name/number.
"""
- pass
+ if isinstance(type, int):
+ for cls in (Blob, Tree, Commit, Tag):
+ if cls.type_num == type:
+ return cls
+ return None
+ elif isinstance(type, bytes):
+ for cls in (Blob, Tree, Commit, Tag):
+ if cls.type_name == type:
+ return cls
+ return None
+ else:
+ raise TypeError("type must be bytes or int")
+
+def valid_hexsha(hex):
+ """Check if a string is a valid hex sha string.
+
+ Args:
+ hex: Hex string to check
+ Returns: bool indicating whether the string is valid
+ """
+ if len(hex) != 40:
+ return False
+ try:
+ int(hex, 16)
+ return True
+ except ValueError:
+ return False
def check_hexsha(hex, error_msg):
"""Check if a string is a valid hex sha string.
@@ -85,7 +123,8 @@ def check_hexsha(hex, error_msg):
Raises:
ObjectFormatException: Raised when the string is not valid
"""
- pass
+ if not valid_hexsha(hex):
+ raise ObjectFormatException(error_msg)
def check_identity(identity: bytes, error_msg: str) -> None:
"""Check if the specified identity is valid.
@@ -96,7 +135,14 @@ def check_identity(identity: bytes, error_msg: str) -> None:
identity: Identity string
error_msg: Error message to use in exception
"""
- pass
+ try:
+ email_start = identity.index(b" <")
+ email_end = identity.index(b">", email_start)
+ if email_end + 1 != len(identity):
+ if identity[email_end + 1:].strip() != b"":
+ raise ValueError
+ except ValueError:
+ raise ObjectFormatException(error_msg)
def check_time(time_seconds):
"""Check if the specified time is not prone to overflow error.
@@ -107,11 +153,12 @@ def check_time(time_seconds):
time_seconds: time in seconds
"""
- pass
+ if time_seconds > MAX_TIME:
+ raise ObjectFormatException("Date field is too large to fit in a 32-bit signed integer")
def git_line(*items):
"""Formats items into a space separated line."""
- pass
+ return b" ".join(items) + b"\n"
class FixedSha:
"""SHA object that behaves like hashlib's but is given a fixed value."""
@@ -127,11 +174,11 @@ class FixedSha:
def digest(self) -> bytes:
"""Return the raw SHA digest."""
- pass
+ return self._sha
def hexdigest(self) -> str:
"""Return the hex SHA digest."""
- pass
+ return self._hexsha.decode('ascii')
class ShaFile:
"""A git SHA file."""
@@ -321,6 +368,25 @@ class Blob(ShaFile):
super().__init__()
self._chunked_text = []
self._needs_serialization = False
+
+ def _get_data(self) -> bytes:
+ """Get blob data."""
+ return b''.join(self._chunked_text)
+
+ def _set_data(self, data: bytes) -> None:
+ """Set blob data."""
+ self._chunked_text = [data]
+ self._needs_serialization = False
+
+ def _get_chunked(self) -> List[bytes]:
+ """Get blob data as chunks."""
+ return self._chunked_text
+
+ def _set_chunked(self, chunks: List[bytes]) -> None:
+ """Set blob data as chunks."""
+ self._chunked_text = chunks
+ self._needs_serialization = False
+
data = property(_get_data, _set_data, doc='The text contained within the blob object.')
chunked = property(_get_chunked, _set_chunked, doc='The text in the blob object, as chunks (not necessarily lines)')
@@ -330,14 +396,14 @@ class Blob(ShaFile):
Raises:
ObjectFormatException: if the object is malformed in some way
"""
- pass
+ super().check()
def splitlines(self) -> List[bytes]:
"""Return list of lines in this blob.
This preserves the original line endings.
"""
- pass
+ return self.data.split(b'\n')
def _parse_message(chunks: Iterable[bytes]) -> Iterator[Union[Tuple[None, None], Tuple[Optional[bytes], bytes]]]:
"""Parse a message with a list of fields and a body.
@@ -382,7 +448,18 @@ class Tag(ShaFile):
Returns: tuple of (object class, sha).
"""
- pass
+ return (self._object_class, self._object_sha)
+
+ def _set_object(self, value):
+ """Set the object pointed to by this tag.
+
+ Args:
+ value: Tuple of (object class, sha)
+ """
+ self._object_class = value[0]
+ self._object_sha = value[1]
+ self._needs_serialization = True
+
object = property(_get_object, _set_object)
name = serializable_property('name', 'The name of this tag')
tagger = serializable_property('tagger', 'Returns the name of the person who created this tag')
diff --git a/dulwich/pack.py b/dulwich/pack.py
index bbd1b188..cb78ea2b 100644
--- a/dulwich/pack.py
+++ b/dulwich/pack.py
@@ -168,6 +168,59 @@ class UnpackedObject:
return '{}({})'.format(self.__class__.__name__, ', '.join(data))
_ZLIB_BUFSIZE = 4096
+def _encode_copy_operation(offset: int, length: int) -> bytes:
+ """Encode a copy operation.
+
+ Args:
+ offset: Offset to copy from
+ length: Length of data to copy
+ Returns: Encoded copy operation
+ """
+ ret = []
+ cmd = 0x80
+ for i, value in enumerate([offset, length]):
+ cmd |= (value & 0x7f) << (i * 4)
+ value >>= 7
+ while value:
+ ret.append(value & 0x7f | 0x80)
+ value >>= 7
+ ret.insert(0, cmd)
+ return bytes(ret)
+
+def _delta_encode_size(size: int) -> bytes:
+ """Encode size as a git variable length number.
+
+ Args:
+ size: Integer to encode
+ Returns: Encoded size
+ """
+ ret = []
+ c = size & 0x7f
+ size >>= 7
+ while size:
+ ret.append(c | 0x80)
+ c = size & 0x7f
+ size >>= 7
+ ret.append(c)
+ return bytes(ret)
+
+def full_unpacked_object(unpacked: UnpackedObject) -> UnpackedObject:
+ """Return a full copy of an UnpackedObject with all deltas resolved.
+
+ Args:
+ unpacked: An UnpackedObject to resolve deltas for.
+ Returns: A copy of the UnpackedObject with all deltas resolved.
+ """
+ if unpacked.pack_type_num not in DELTA_TYPES:
+ return unpacked
+ if unpacked.obj_type_num is None or unpacked.obj_chunks is None:
+ raise UnresolvedDeltas([unpacked.sha()])
+ return UnpackedObject(
+ unpacked.obj_type_num,
+ decomp_chunks=unpacked.obj_chunks,
+ sha=unpacked._sha,
+ offset=unpacked.offset)
+
def read_zlib_chunks(read_some: Callable[[int], bytes], unpacked: UnpackedObject, include_comp: bool=False, buffer_size: int=_ZLIB_BUFSIZE) -> bytes:
"""Read zlib data from a buffer.
@@ -192,7 +245,40 @@ def read_zlib_chunks(read_some: Callable[[int], bytes], unpacked: UnpackedObject
Raises:
zlib.error: if a decompression error occurred.
"""
- pass
+ if include_comp:
+ comp_chunks = []
+ unpacked.comp_chunks = comp_chunks
+ else:
+ comp_chunks = None
+ decomp_chunks = unpacked.decomp_chunks
+ decomp_len = 0
+ crc32 = unpacked.crc32
+
+ # Start streaming the data to zlib
+ d = zlib.decompressobj()
+ while True:
+ add_data = read_some(buffer_size)
+ if not add_data:
+ break
+ if comp_chunks is not None:
+ comp_chunks.append(add_data)
+ if crc32 is not None:
+ crc32 = zlib.crc32(add_data, crc32)
+ decomp = d.decompress(add_data)
+ decomp_len += len(decomp)
+ decomp_chunks.append(decomp)
+ if d.unused_data:
+ leftover = d.unused_data
+ if comp_chunks is not None:
+ comp_chunks[-1] = add_data[:-len(leftover)]
+ if crc32 is not None:
+ crc32 = zlib.crc32(add_data[:-len(leftover)], crc32)
+ break
+ else:
+ leftover = b''
+ unpacked.decomp_len = decomp_len
+ unpacked.crc32 = crc32
+ return leftover
def iter_sha1(iter):
"""Return the hexdigest of the SHA1 over a set of names.
diff --git a/dulwich/protocol.py b/dulwich/protocol.py
index 761853e4..5a9a08be 100644
--- a/dulwich/protocol.py
+++ b/dulwich/protocol.py
@@ -1,6 +1,7 @@
"""Generic functions for talking the git smart server protocol."""
from io import BytesIO
from os import SEEK_END
+from typing import Dict, List, Optional, Tuple
import dulwich
from .errors import GitProtocolError, HangupException
TCP_GIT_PORT = 9418
@@ -50,6 +51,20 @@ COMMAND_DONE = b'done'
COMMAND_WANT = b'want'
COMMAND_HAVE = b'have'
+def agent_string():
+ """Return a string identifying this agent.
+
+ Returns: String identifying this agent.
+ """
+ return f"dulwich/{'.'.join(str(x) for x in dulwich.__version__)}"
+
+def capability_agent():
+ """Return agent capability string.
+
+ Returns: String describing agent capability.
+ """
+ return CAPABILITY_AGENT + b'=' + agent_string().encode('ascii')
+
def pkt_line(data):
"""Wrap data in a pkt-line.
@@ -58,7 +73,9 @@ def pkt_line(data):
Returns: The data prefixed with its length in pkt-line format; if data was
None, returns the flush-pkt ('0000').
"""
- pass
+ if data is None:
+ return b'0000'
+ return ('%04x' % (len(data) + 4)).encode('ascii') + data
class Protocol:
"""Class for interacting with a remote git process over the wire.
@@ -184,6 +201,96 @@ class ReceivableProtocol(Protocol):
self._rbuf = BytesIO()
self._rbufsize = rbufsize
+def parse_capability(capability: bytes) -> Tuple[bytes, Optional[bytes]]:
+ """Parse a capability string.
+
+ Args:
+ capability: Capability string
+ Returns: Tuple of (capability name, optional value)
+ """
+ parts = capability.split(b'=', 1)
+ if len(parts) == 1:
+ return parts[0], None
+ return parts[0], parts[1]
+
+def format_capability_line(name: bytes, value: Optional[bytes]=None) -> bytes:
+ """Format a capability line.
+
+ Args:
+ name: Capability name
+ value: Optional capability value
+ Returns: Capability line
+ """
+ if value is None:
+ return name
+ return name + b'=' + value
+
+def format_ref_line(name: bytes, sha: bytes, capabilities: Optional[List[bytes]]=None) -> bytes:
+ """Format a ref line.
+
+ Args:
+ name: Name of the ref
+ sha: SHA1 of the ref
+ capabilities: Optional list of capabilities
+ Returns: Ref line
+ """
+ if capabilities:
+ return sha + b'\x00' + b' '.join(capabilities) + b' ' + name + b'\n'
+ return sha + b' ' + name + b'\n'
+
+def format_shallow_line(sha: bytes) -> bytes:
+ """Format a shallow line.
+
+ Args:
+ sha: SHA1 to mark as shallow
+ Returns: Shallow line
+ """
+ return b'shallow ' + sha + b'\n'
+
+def format_unshallow_line(sha: bytes) -> bytes:
+ """Format an unshallow line.
+
+ Args:
+ sha: SHA1 to mark as unshallow
+ Returns: Unshallow line
+ """
+ return b'unshallow ' + sha + b'\n'
+
+def symref_capabilities(refs: Dict[bytes, bytes]) -> List[bytes]:
+ """Get symref capabilities for a set of refs.
+
+ Args:
+ refs: Dict of refs to get capabilities for
+ Returns: List of symref capabilities
+ """
+ ret = []
+ for name, target in refs.items():
+ if name.startswith(SYMREF):
+ ret.append(CAPABILITY_SYMREF + b'=' + name[len(SYMREF):] + b':' + target)
+ return ret
+
+def format_ack_line(sha: bytes, ack_type: bytes=b'', line_end: bytes=b'\n') -> bytes:
+ """Format an ack line.
+
+ Args:
+ sha: SHA1 to ack
+ ack_type: Optional ack type
+ line_end: Optional line ending
+ Returns: Ack line
+ """
+ if ack_type:
+ return b'ACK ' + sha + b' ' + ack_type + line_end
+ return b'ACK ' + sha + line_end
+
+def extract_capability_names(capabilities):
+ """Extract capability names from a capabilities list.
+
+ Args:
+ capabilities: List of capabilities as bytes
+ Returns: List of capability names as bytes
+ """
+ return [c.split(b'=', 1)[0] for c in capabilities]
+
def extract_capabilities(text):
"""Extract a capabilities list from a string, if present.
@@ -191,7 +298,10 @@ def extract_capabilities(text):
text: String to extract from
Returns: Tuple with text with capabilities removed and list of capabilities
"""
- pass
+ if not text.endswith(b'\0'):
+ return text, []
+ text, capabilities = text[:-1].split(b'\0', 1)
+ return text, capabilities.split(b' ')
def extract_want_line_capabilities(text):
"""Extract a capabilities list from a want line, if present.
diff --git a/dulwich/refs.py b/dulwich/refs.py
index 27ab6d1f..108c48de 100644
--- a/dulwich/refs.py
+++ b/dulwich/refs.py
@@ -460,14 +460,98 @@ def write_packed_refs(f, packed_refs, peeled_refs=None):
"""
pass
-def write_info_refs(refs, store: ObjectContainer):
+def read_info_refs(f) -> Dict[bytes, bytes]:
+ """Read info refs file.
+
+ Args:
+ f: File-like object to read from
+ Returns: Dict mapping ref names to SHA1s
+ """
+ ret = {}
+ for line in f:
+ if not line.strip():
+ continue
+ sha, name = line.rstrip(b'\n').split(b'\t')
+ if name.endswith(PEELED_TAG_SUFFIX):
+ name = name[:-3]
+ ret[name] = sha
+ return ret
+
+def write_info_refs(refs, store: ObjectContainer) -> bytes:
"""Generate info refs."""
- pass
+ ret = []
+ for name, sha in sorted(refs.items()):
+ ret.append(git_line(sha, name))
+ if name.startswith(LOCAL_TAG_PREFIX):
+ try:
+ obj = store[sha]
+ if obj.type_name == b'tag':
+ ret.append(git_line(obj.object[1], name + PEELED_TAG_SUFFIX))
+ except KeyError:
+ pass
+ return b''.join(ret)
+
+def _import_remote_refs(refs: Dict[bytes, bytes], remote_refs: Dict[bytes, bytes], base: bytes) -> None:
+ """Import refs from remote repository.
+
+ Args:
+ refs: Dict to add remote refs to
+ remote_refs: Dict with remote refs
+ base: Base prefix to add to remote refs
+ """
+ for name, value in remote_refs.items():
+ refs[base + b'/' + name] = value
+
+def serialize_refs(refs: Dict[bytes, bytes]) -> bytes:
+ """Serialize refs into a string.
+
+ Args:
+ refs: Dict of refs to serialize
+ Returns: Serialized refs as bytes
+ """
+ ret = []
+ for name, value in sorted(refs.items()):
+ ret.append(git_line(value, name))
+ return b''.join(ret)
def strip_peeled_refs(refs):
"""Remove all peeled refs."""
- pass
+ return {k: v for k, v in refs.items() if not k.endswith(PEELED_TAG_SUFFIX)}
+
+def _set_head(refs: RefsContainer, target: bytes, ref_message: Optional[bytes]=None) -> None:
+ """Set HEAD to point at target.
+
+ Args:
+ refs: RefsContainer to set HEAD in
+ target: Target to point HEAD at
+ ref_message: Optional reflog message
+ """
+ refs.set_symbolic_ref(HEADREF, target, message=ref_message)
+
+def _set_origin_head(refs: RefsContainer, origin: bytes, origin_head: bytes, ref_message: Optional[bytes]=None) -> None:
+ """Set origin HEAD.
+
+ Args:
+ refs: RefsContainer to set origin HEAD in
+ origin: Origin name
+ origin_head: Origin HEAD target
+ ref_message: Optional reflog message
+ """
+ ref = LOCAL_REMOTE_PREFIX + origin + b'/' + HEADREF
+ refs.set_symbolic_ref(ref, origin_head, message=ref_message)
def _set_default_branch(refs: RefsContainer, origin: bytes, origin_head: bytes, branch: bytes, ref_message: Optional[bytes]) -> bytes:
- """Set the default branch."""
- pass
\ No newline at end of file
+ """Set the default branch.
+
+ Args:
+ refs: RefsContainer to set default branch in
+ origin: Origin name
+ origin_head: Origin HEAD target
+ branch: Branch name
+ ref_message: Optional reflog message
+ Returns: Default branch name
+ """
+ _set_head(refs, branch, ref_message)
+ if origin and origin_head:
+ _set_origin_head(refs, origin, origin_head, ref_message)
+ return branch
\ No newline at end of file
diff --git a/dulwich/web.py b/dulwich/web.py
index bb7bf698..44b4426a 100644
--- a/dulwich/web.py
+++ b/dulwich/web.py
@@ -27,7 +27,13 @@ def url_prefix(mat) -> str:
original string. Normalized to start with one leading slash and end
with zero.
"""
- pass
+ prefix = mat.string[0:mat.start()]
+ n = len(prefix)
+ if n == 0 or prefix[0] != '/':
+ prefix = '/' + prefix
+ if n > 0 and prefix[n - 1] == '/':
+ prefix = prefix[0:n - 1]
+ return prefix
def get_repo(backend, mat) -> BaseRepo:
"""Get a Repo instance for the given backend and URL regex match."""
@@ -193,6 +199,141 @@ class WSGIServerLogger(WSGIServer):
"""Handle an error."""
pass
+def get_text_file(req: HTTPGitRequest, backend: Backend, mat: re.Match) -> Iterator[bytes]:
+ """Get a text file from the repository.
+
+ Args:
+ req: The HTTPGitRequest object.
+ backend: The backend object.
+ mat: The regex match object.
+ Returns: An iterator over the file contents.
+ """
+ repo = get_repo(backend, mat)
+ path = mat.group(0).lstrip('/')
+ try:
+ with repo.get_named_file(path) as f:
+ return send_file(req, f, 'text/plain')
+ except (KeyError, IOError):
+ yield req.not_found('Object not found')
+
+def get_info_refs(req: HTTPGitRequest, backend: Backend, mat: re.Match) -> Iterator[bytes]:
+ """Get info/refs, which is used for the initial git clone/fetch.
+
+ Args:
+ req: The HTTPGitRequest object.
+ backend: The backend object.
+ mat: The regex match object.
+ Returns: An iterator over the response.
+ """
+ repo = get_repo(backend, mat)
+ service = req.environ.get('QUERY_STRING', '').startswith('service=git-') and not req.dumb
+ if service:
+ service = req.environ['QUERY_STRING'].split('=', 1)[1]
+ handler_cls = req.handlers.get(service, None)
+ if handler_cls is None:
+ yield req.forbidden('Unsupported service')
+ return
+ req.nocache()
+ write = req.respond(content_type='application/x-%s-advertisement' % service)
+ proto = ReceivableProtocol(BytesIO().read, write)
+ handler = handler_cls(backend, [url_prefix(mat)], proto, stateless_rpc=True, advertise_refs=True)
+ handler.proto.write_pkt_line(b'# service=' + service.encode('ascii') + b'\n')
+ handler.proto.write_pkt_line(None)
+ handler.handle()
+ else:
+ req.nocache()
+ write = req.respond(content_type='text/plain')
+ refs = generate_info_refs(repo)
+ write(refs)
+ yield None
+
+def get_info_packs(req: HTTPGitRequest, backend: Backend, mat: re.Match) -> Iterator[bytes]:
+ """Get info/packs, which is used to get the pack files.
+
+ Args:
+ req: The HTTPGitRequest object.
+ backend: The backend object.
+ mat: The regex match object.
+ Returns: An iterator over the response.
+ """
+ repo = get_repo(backend, mat)
+ req.cache_forever()
+ write = req.respond(content_type='text/plain')
+ write(generate_objects_info_packs(repo))
+ yield None
+
+def get_loose_object(req: HTTPGitRequest, backend: Backend, mat: re.Match) -> Iterator[bytes]:
+ """Get a loose object from the repository.
+
+ Args:
+ req: The HTTPGitRequest object.
+ backend: The backend object.
+ mat: The regex match object.
+ Returns: An iterator over the response.
+ """
+ repo = get_repo(backend, mat)
+ sha = (mat.group(1) + mat.group(2)).encode('ascii')
+ try:
+ with repo.get_raw(sha) as f:
+ return send_file(req, f, 'application/x-git-loose-object')
+ except KeyError:
+ yield req.not_found('Object not found')
+
+def get_pack_file(req: HTTPGitRequest, backend: Backend, mat: re.Match) -> Iterator[bytes]:
+ """Get a pack file from the repository.
+
+ Args:
+ req: The HTTPGitRequest object.
+ backend: The backend object.
+ mat: The regex match object.
+ Returns: An iterator over the response.
+ """
+ repo = get_repo(backend, mat)
+ sha = mat.group(1).encode('ascii')
+ try:
+ with repo.get_raw_pack(sha) as f:
+ return send_file(req, f, 'application/x-git-packed-objects')
+ except KeyError:
+ yield req.not_found('Object not found')
+
+def get_idx_file(req: HTTPGitRequest, backend: Backend, mat: re.Match) -> Iterator[bytes]:
+ """Get a pack index file from the repository.
+
+ Args:
+ req: The HTTPGitRequest object.
+ backend: The backend object.
+ mat: The regex match object.
+ Returns: An iterator over the response.
+ """
+ repo = get_repo(backend, mat)
+ sha = mat.group(1).encode('ascii')
+ try:
+ with repo.get_raw_pack_idx(sha) as f:
+ return send_file(req, f, 'application/x-git-packed-objects-toc')
+ except KeyError:
+ yield req.not_found('Object not found')
+
+def handle_service_request(req: HTTPGitRequest, backend: Backend, mat: re.Match) -> Iterator[bytes]:
+ """Handle a service request.
+
+ Args:
+ req: The HTTPGitRequest object.
+ backend: The backend object.
+ mat: The regex match object.
+ Returns: An iterator over the response.
+ """
+ service = os.path.basename(req.environ['PATH_INFO'])
+ handler_cls = req.handlers.get(service, None)
+ if handler_cls is None:
+ yield req.forbidden('Unsupported service')
+ return
+ input = req.environ['wsgi.input']
+ write = req.respond(content_type='application/x-%s-result' % service)
+ proto = ReceivableProtocol(input.read, write)
+ handler = handler_cls(backend, [url_prefix(mat)], proto, stateless_rpc=True)
+ handler.handle()
+ yield None
+
def main(argv=sys.argv):
"""Entry point for starting an HTTP git server."""
pass