From d5ae9d10186b7dc4585d4ea016e102888af6ee7a Mon Sep 17 00:00:00 2001 From: "Austin S. Hemmelgarn" Date: Tue, 19 Sep 2017 16:23:16 -0400 Subject: [PATCH] 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 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 --- docs/bin/generate_man.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/bin/generate_man.py b/docs/bin/generate_man.py index e13ffed6f2..3493ee355d 100755 --- a/docs/bin/generate_man.py +++ b/docs/bin/generate_man.py @@ -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: