diff --git a/tools/stubgen.py b/tools/stubgen.py index 444820d64..2c296b929 100644 --- a/tools/stubgen.py +++ b/tools/stubgen.py @@ -211,7 +211,8 @@ def main(argv=None): ap.add_argument("--td-out", required=False, default=None, help="output file for TechnicalDebt lines, which go in docs/dev/debt/MODULE.md, default stderr when code uses stdout, otherwise stdout") ap.add_argument("--td-only", action="store_true", help="print only TechnicalDebt lines, no code") args = ap.parse_args(argv) - sys.stdout.reconfigure(encoding="utf-8", newline="\n") + if hasattr(sys.stdout, "reconfigure"): + sys.stdout.reconfigure(encoding="utf-8", newline="\n") try: if not args.td_only and args.out and args.td_out and same_file(args.out, args.td_out): ap.error("--out and --td-out must name different files")