Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,15 @@ User defined functions can be used as well:

The :func:`bool` function is not recommended as a type converter. All it does
is convert empty strings to ``False`` and non-empty strings to ``True``.
This is usually not what is desired.
This is usually not what is desired::

>>> parser = argparse.ArgumentParser()
>>> _ = parser.add_argument('--verbose', type=bool)
>>> parser.parse_args(['--verbose', 'False'])
Namespace(verbose=True)

See :class:`BooleanOptionalAction` or ``action='store_true'`` for common
alternatives.

In general, the ``type`` keyword is a convenience that should only be used for
simple conversions that can only raise one of the three supported exceptions.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix building the jit stencils on Windows when the interpreter is built with
a different clang version. Patch by Chris Eibl.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Expand :mod:`argparse` documentation for ``type=bool`` with a demonstration
of the surprising behavior and pointers to common alternatives.
12 changes: 11 additions & 1 deletion Tools/jit/_llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,19 @@ async def _run(tool: str, args: typing.Iterable[str], echo: bool = False) -> str
async with _CORES:
if echo:
print(shlex.join(command))

if os.name == "nt":
# When building with /p:PlatformToolset=ClangCL, the VS build
# system puts that clang's include path into INCLUDE. The JIT's
# clang may be a different version, and mismatched headers cause
# build errors. See https://github.com/python/cpython/issues/146210.
env = os.environ.copy()
env.pop("INCLUDE", None)
else:
env = None
try:
process = await asyncio.create_subprocess_exec(
*command, stdout=subprocess.PIPE
*command, stdout=subprocess.PIPE, env=env
)
except FileNotFoundError:
return None
Expand Down
Loading