mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix build on Python 3.x by using sys.maxsize. (#30424)
As outlined in https://docs.python.org/3.1/whatsnew/3.0.html#integers, sys.maxint doesn't exist anymore in Python 3.x because there is no maximum value for integers in Python 3.x. sys.maxsize is present in all versions of Python that are currently supported by Ansible, so use that instead as an arbitrarily large index value. Fixes the following build error when building with Python 3.x: make -j1 docs mkdir -p ./docs/man/man1/ ; \ PYTHONPATH=./lib docs/bin/generate_man.py --template-file=docs/templates/man.j2 --output-dir=docs/man/man1/ --output-format man lib/ansible/cli/*.py Traceback (most recent call last): File "docs/bin/generate_man.py", line 253, in <module> allvars[cli_name] = opts_docs(cli_class_name, cli_name) File "docs/bin/generate_man.py", line 119, in opts_docs 'long_desc': trim_docstring(cli.__doc__), File "docs/bin/generate_man.py", line 34, in trim_docstring indent = sys.maxint AttributeError: module 'sys' has no attribute 'maxint' make: *** [Makefile:347: generate_asciidoc] Error 1
This commit is contained in:
parent
0a69e27e62
commit
d5ae9d1018
1 changed files with 2 additions and 2 deletions
|
@ -31,14 +31,14 @@ def trim_docstring(docstring):
|
|||
# and split into a list of lines:
|
||||
lines = docstring.expandtabs().splitlines()
|
||||
# Determine minimum indentation (first line doesn't count):
|
||||
indent = sys.maxint
|
||||
indent = sys.maxsize
|
||||
for line in lines[1:]:
|
||||
stripped = line.lstrip()
|
||||
if stripped:
|
||||
indent = min(indent, len(line) - len(stripped))
|
||||
# Remove indentation (first line is special):
|
||||
trimmed = [lines[0].strip()]
|
||||
if indent < sys.maxint:
|
||||
if indent < sys.maxsize:
|
||||
for line in lines[1:]:
|
||||
trimmed.append(line[indent:].rstrip())
|
||||
# Strip off trailing and leading blank lines:
|
||||
|
|
Loading…
Reference in a new issue