bpo-26967: fix flag grouping with allow_abbrev=False (GH-14316)
The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing.
However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this.
This was prompted by pytest-dev/pytest#5469, so a backport to at least 3.8 would be great :smile:
And this is my first PR to CPython, so please let me know if I've missed anything!
https://bugs.python.org/issue26967
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index b77a38c..ef2fd42 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -182,6 +182,10 @@
.. versionchanged:: 3.5
*allow_abbrev* parameter was added.
+ .. versionchanged:: 3.8
+ In previous versions, *allow_abbrev* also disabled grouping of short
+ flags such as ``-vv`` to mean ``-v -v``.
+
The following sections describe how each of these are used.