You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a requirements file references itself (directly or indirectly), an RecursionError is raised.
Expected behavior
The RecursionError isn't strictly wrong, but the cause of the error may not be obvious as it results in a hard interpreter crash. It would be desirable to detect the recursion, and report the source of the problem rather than crashing the Python interpreter.
pip version
24.0
Python version
3.10 (but should affect any version)
OS
macOS (but should affect any OS)
How to Reproduce
Construct a requirements.txt that contains:
-r requirements.txt
Run pip install -r requirements.txt
This is the simplest case; other loops (such as requirements files that include each other, and cycles of 3 or more requirements files) also cause the problem.
Output
ERROR: Exception:
Traceback (most recent call last):
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
status = run_func(*args)
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper
return func(self, options, args)
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 342, in run
reqs = self.get_requirements(args, options, finder, session)
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 433, in get_requirements
forparsed_reqin parse_requirements(
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/req/req_file.py", line 156, in parse_requirements
forparsed_linein parser.parse(filename, constraint):
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/req/req_file.py", line 337, in parse
yield from self._parse_and_recurse(filename, constraint)
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/req/req_file.py", line 366, in _parse_and_recurse
yield from self._parse_and_recurse(req_path, nested_constraint)
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/req/req_file.py", line 366, in _parse_and_recurse
yield from self._parse_and_recurse(req_path, nested_constraint)
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/req/req_file.py", line 366, in _parse_and_recurse
yield from self._parse_and_recurse(req_path, nested_constraint)
[Previous line repeated 972 more times]
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/req/req_file.py", line 342, in _parse_and_recurse
forlinein self._parse_file(filename, constraint):
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/req/req_file.py", line 379, in _parse_file
args_str, opts = self._line_parser(line)
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/req/req_file.py", line 398, in parse_line
parser = build_parser()
File "/Users/rkm/beeware/toga/venv3.10/lib/python3.10/site-packages/pip/_internal/req/req_file.py", line 444, in build_parser
parser = optparse.OptionParser(add_help_option=False)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/optparse.py", line 1191, in __init__
self.set_usage(usage)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/optparse.py", line 1266, in set_usage
self.usage = _("%prog [options]")
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 742, in gettext
return dgettext(_current_domain, message)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 666, in dgettext
t = translation(domain, _localedirs.get(domain, None))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 587, in translation
mofiles = find(domain, localedir, languages, all=True)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 558, in find
fornelangin _expand_lang(lang):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 213, in _expand_lang
loc = locale.normalize(loc)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/locale.py", line 461, in normalize
return _replace_encoding(code, encoding)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/locale.py", line 368, in _replace_encoding
norm_encoding = encodings.normalize_encoding(encoding)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/encodings/__init__.py", line 55, in normalize_encoding
if isinstance(encoding, bytes):
RecursionError: maximum recursion depth exceeded while calling a Python object
Description
If a requirements file references itself (directly or indirectly), an RecursionError is raised.
Expected behavior
The RecursionError isn't strictly wrong, but the cause of the error may not be obvious as it results in a hard interpreter crash. It would be desirable to detect the recursion, and report the source of the problem rather than crashing the Python interpreter.
pip version
24.0
Python version
3.10 (but should affect any version)
OS
macOS (but should affect any OS)
How to Reproduce
requirements.txt
that contains:pip install -r requirements.txt
This is the simplest case; other loops (such as requirements files that include each other, and cycles of 3 or more requirements files) also cause the problem.
Output
Code of Conduct
The text was updated successfully, but these errors were encountered: