paul j3 added the comment:
This patch adds a
class TestMutuallyExclusiveGroupErrors
test_invalid_add_group() test,
closely modeled on
test_invalid_add_argument()
I'm using ValueError in group add methods (maintaining the similarity with
add_argument errors).
I ha
Changes by paul j3 :
Added file: http://bugs.python.org/file36160/issue22029_2.patch
___
Python tracker
<http://bugs.python.org/issue22029>
___
___
Python-bugs-list mailin
paul j3 added the comment:
In http://bugs.python.org/issue22029 argparse
CSS white-space: like control for individual text blocks
I propose a set of `str` subclasses that can be used to define the wrapping
style of individual text blocks. The idea is adapted from the HTML '' tag,
a
Paul Moore added the comment:
I'm not sure how relevant this is any more, as pip is the preferred installer
these days and it cleanly uninstalls projects. At least for my usage, I no
longer use wininst installers at all. I won't close this myself, though, as the
issue still exi
Changes by paul j3 :
Added file: http://bugs.python.org/file36187/issue22029_2.patch
___
Python tracker
<http://bugs.python.org/issue22029>
___
___
Python-bugs-list mailin
Changes by paul j3 :
Removed file: http://bugs.python.org/file36160/issue22029_2.patch
___
Python tracker
<http://bugs.python.org/issue22029>
___
___
Python-bugs-list m
paul j3 added the comment:
In my suggestion I used
if 'current_value is default':
without going into detail. The use of an 'is' test for integer values is
tricky, as discussed in http://bugs.python.org/issue18943
int("42") is 42# True
int(&
paul j3 added the comment:
For documentation, ['this','is','a','test'] might be a bit clearer than 'this
is a test'.split(). But generating a list of strings by split is, I think, a
pretty basic idiom.
But for testing purposes the split() ver
paul j3 added the comment:
Another issue dealing with abbreviations is close to being committed.
http://bugs.python.org/issue14910
argparse: disable abbreviation
--
___
Python tracker
<http://bugs.python.org/issue14
paul j3 added the comment:
On Stackoverflow a couple of posters have asked about nesting namespaces as a
way of separating the parser and subparser arguments.
http://stackoverflow.com/questions/15782948
http://stackoverflow.com/questions/18668227
One solution that I rather like http
paul j3 added the comment:
Reading through, but not testing, it looks like a faithful replacement. The
usage like will be a bit different.
Given optparse:
usage='usage: %prog [-d] [-t] [input [output]]
automatic argparse:
usage='usage: %prog [-d] [-t] [input] [output]
paul j3 added the comment:
I added a print line to a 'windows' example from the documentation:
from multiprocessing import Process
print 'importing multiprocessing'
def foo():
print 'hello'
p = Process(target=foo)
p.start()
Run wi
paul j3 added the comment:
I had noticed the `global _log_to_stderr` in `util.log_to_stderr()`, but hadn't
taken time to track down where it is used.
Not only is it passed from the 'util' module to the 'forking' one, but it is
also passed via a piped pickle fro
paul j3 added the comment:
It still needs a documentation patch.
And if the documentation was clearer, would sfllaw's patch still be needed?
--
___
Python tracker
<http://bugs.python.org/is
paul j3 added the comment:
The formatting of the descriptor line for this class is not consistent with the
classes for this module.
It lacks 'class'.
It is all bold
In contrast
class argparse.ArgumentParser(prog=None, ...
uses bold for onl
paul j3 added the comment:
Maybe the problem is with the latest documentation build, not your patch.
--
___
Python tracker
<http://bugs.python.org/issue13
paul j3 added the comment:
You need line continuation characters '\'
.. class:: Action(option_strings, dest, nargs=None, const=None, default=None, \
type=None, choices=None, required=False, help=None, \
me
paul j3 added the comment:
While we are talking the Action class, the documentation isn't clear that the
'add_argument' method returns an Action object, specifically one the
subclasses. More than once, when answering Stackoverflow questions I've
recommended assign
paul j3 added the comment:
The patch tests assume the test is being run in a particular way:
python -m unittest ...
But I often use
python3 -m unittest ...
or
python3 test_argparse.py
both of which fail these tests.
Testing this change might be more difficult than implementing
paul j3 added the comment:
What if the package is run without `-m`?
--
___
Python tracker
<http://bugs.python.org/issue22240>
___
___
Python-bugs-list mailin
paul j3 added the comment:
I ran into a (possibly) related compiling problem (for 'default', 3.5 branch)
in `asdl.py`:
class Module(AST):
def __init__(self, name, dfns):
...
self.types = {type.name: type.value for type in dfns}
The dictionary com
paul j3 added the comment:
Package might be the wrong term. How about a directory with a `__main__.py`
file, and no local imports (relative or not)? In my tests it runs with and
without the -m.
--
___
Python tracker
<http://bugs.python.
paul j3 added the comment:
http://bugs.python.org/issue14191
'argparse doesn't allow optionals within positionals'
implements a 'parse_intermixed_args()' method, which parses all of the
optionals with one pass, followed by a second pass that handles the
posi
paul j3 added the comment:
http://stackoverflow.com/questions/25626109/python-argparse-conditionally-required-arguments
asks about implementing a 'conditionally-required-arguments' case in
`argparse`. The post-parsing test is simple enough:
if args.argument and (args.a is None
paul j3 added the comment:
Attached is a patch for 3.5.0 dev that adds UsageGroups. Now different 'kinds'
are implemented as subclasses, which are accessed via the registry:
_XorUsageGroup - replicate action of MutuallyExclusiveGroups
_AndUsageGroup - an inclu
Paul Moore added the comment:
It's not unreasonable as a new feature, but the default behaviour shouldn't
change. It matches ini files (like it or not, ConfigParser parses ini-style
files - the docs even say so), and sectionless values are not standard ini
format.
I'd suggest
paul j3 added the comment:
When I apply `prog3.diff` to my 3.5.0dev, and run
python3 -m unittest Lib/test/test_argparse.py
I get 2 failures, both over 'usage: python3 -m [unit]test'.
It also fails with
python3 test_argparse.py
I suspect it would also fail if I ran the
paul j3 added the comment:
In argparse.py, I would put a utility function like `_prog_name` near the start
in the 'Utility functions and classes' block.
In test_argparse.py, I don't see the purpose of the `progname` changes in the
TestParentParsers class. That class wasn
paul j3 added the comment:
This assertion has triggered several bug issues, either due to an empty group
like this, or certain characters in the metavars.
http://bugs.python.org/issue17890
'argparse: mutually exclusive groups full of suppressed args can cause
AssertionErrors
paul j3 added the comment:
One way to reduce the testing burden, and to be extra safe regarding backward
compatibility is to make this action optional, rather than the default.
For example, make `_prog_name` importable (i.e. change the name), and then
expect the user to use it explicitly with
New submission from paul j3:
When there's a conflict involving an argument that was added via 'parents', and
the conflict handler is 'resolve', the action in the parent parser may be
damaged, rendering that parent unsuitable for further use.
In this example, 2 parent
paul j3 added the comment:
'sample3.py' contains a '_handle_conflict_parent' function.
With the help of a change in '_add_container_actions' it determines whether a
conflicting action occurs in multiple parsers (and argument_groups). If it
does, it deletes it f
Changes by paul j3 :
Added file: http://bugs.python.org/file36648/sample3.py
___
Python tracker
<http://bugs.python.org/issue22401>
___
___
Python-bugs-list mailin
Changes by paul j3 :
Removed file: http://bugs.python.org/file36635/sample3.py
___
Python tracker
<http://bugs.python.org/issue22401>
___
___
Python-bugs-list mailin
Changes by paul j3 :
Added file: http://bugs.python.org/file36656/sample3.py
___
Python tracker
<http://bugs.python.org/issue22401>
___
___
Python-bugs-list mailin
Changes by paul j3 :
Removed file: http://bugs.python.org/file36648/sample3.py
___
Python tracker
<http://bugs.python.org/issue22401>
___
___
Python-bugs-list mailin
paul j3 added the comment:
Your patch fails:
python3 -m unittest test_argparse.TestEmptyAndSpaceContainingArguments
specifically these 2 subcases:
(['-a badger'], NS(x='-a badger', y=None)),
(['-y', '-a badger'], NS(x=None, y='-a
Changes by paul j3 :
--
nosy: +bethard
___
Python tracker
<http://bugs.python.org/issue22401>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.pyth
Changes by paul j3 :
Added file: http://bugs.python.org/file36674/example.py
___
Python tracker
<http://bugs.python.org/issue22433>
___
___
Python-bugs-list mailin
Changes by paul j3 :
Removed file: http://bugs.python.org/file36672/example.py
___
Python tracker
<http://bugs.python.org/issue22433>
___
___
Python-bugs-list mailin
paul j3 added the comment:
Proposed patches like this are supposed to be generated against the current
development version (3.5...), especially if they are 'enhancements' (as opposed
to bugs). But there isn't much of a difference in argparse between 2.7+ and
3.4+ (except o
Paul Moore added the comment:
>From the comments here, there seems to be a belief that this is somehow
>related to VC Express only.
I have hit this error when using the MS SDK (both 7.0 on Python 2.7, and 7.1 on
Python 3.3 and 3.4) with DISTUTILS_USE_SDK set.
Unless I have s
paul j3 added the comment:
I've added a patch with tests that I think handles this case, without messing
with existing test cases. It adds a new 'space' test right before the existing
one, one that explicitly handles an '=' arg_string.
If the space is in the 1s
paul j3 added the comment:
A 'store_true' action takes 0 arguments. In effect `nargs=0`.
With an `optional` (flagged) argument, the default `False` is used if the flag
is absent, and set to `True` when the flag is encountered (its Action
`__call__` function is run).
A `posi
Changes by paul j3 :
Added file: http://bugs.python.org/file36728/sample3.py
___
Python tracker
<http://bugs.python.org/issue22401>
___
___
Python-bugs-list mailin
Changes by paul j3 :
Removed file: http://bugs.python.org/file36656/sample3.py
___
Python tracker
<http://bugs.python.org/issue22401>
___
___
Python-bugs-list mailin
paul j3 added the comment:
If the empty argument group has a 'description' it is displayed. For example
with positionals group that I mentioned earlier:
parser = argparse.ArgumentParser()
parser._action_groups[0].description = 'test'
parser.print_help()
paul j3 added the comment:
A simpler solution is to make a copy of each Action when importing a parent
parser. The current practice is to just copy references. With a copy, an
Action will belong to only one group and parser, and the 'resolve' handler will
operate without problem
paul j3 added the comment:
Normally the unix shell takes care of this expansion. If I call a simple
script that prints sys.argv and runs a simple parser, I get:
2135:~/mypy$ python2.7 filetypetest.py ~/mypy/test.txt
['filetypetest.py', '/home/paul/mypy/test.txt'
paul j3 added the comment:
In argparse.py the status of ArgumentTypeError is ambiguous.
ArgumentError is listed as a public class, ArgumentTypeError is not. It also
says 'All other classes in this module are considered implementation details.'
ArgumentTypeError is a subclass of
Paul Sokolovsky added the comment:
8 years after the original patch, there's still no trivial constant folding in
bytecode generated (because peephole of course is not a real optimizer to
consistently catch all cases):
$ cat const.py
FOO = 1
BAR = FOO + 2 + 4
$ python --version
Python
New submission from Paul Moore:
The Python 3.4b2 installer for Windows does not install a "pip.exe" wrapper
when the default options are selected. Only the "pip3.exe" and "pip3.4.exe"
commands are provided.
The documentation for ensurepip makes it clear that
Paul Moore added the comment:
Fair enough. Can the justification be recorded somewhere, please? It's
inconsistent with most other Python commands on Windows. (I don't recall what
the justification was, and can't come up with a search that locates the
di
Paul Moore added the comment:
It would not be impossible for the ensurepip call in the Windows installer to
set the --default-pip flag, if that gives a better user experience on Windows.
I'm not wedded to either answer myself, but given that versioned executable
names are uncommon on Wi
Paul Moore added the comment:
The most obvious solution would be if the onerror argument allowed for retries.
At the moment, all it can do is report issues, not recover. Suppose that
returning True from onerror meant "retry the operation". Then you could do
def set_rw(operation,
Paul Moore added the comment:
It's similar. But the problem is that it only returns a list of errors, it
doesn't let you address the error *while the rmtree is in progress*.
The key thing is that if you can fix the problem in onerror, you can avoid
needing to restart the whole
Paul Moore added the comment:
Looks like that works. At least in my case - I just did
def del_rw(action, name, exc):
os.chmod(name, stat.S_IWRITE)
os.remove(name)
shutil.rmtree(path, onerror=del_rw)
Something more robust might check if name is a directory and os.rmdir
New submission from Paul Sokolovsky:
http://docs.python.org/3.3/library/time.html#time.clock says that it's
deprecated, but pystone.py in Python-3.4.0b3 tarball still uses it.
Please kindly consider switching it to plain time.time() and not to some other
novelties.
My usecase is
Changes by Paul Sokolovsky :
--
components: +Benchmarks
versions: +Python 3.3, Python 3.4
___
Python tracker
<http://bugs.python.org/issue20475>
___
___
Python-bug
Paul Sokolovsky added the comment:
> The problem with pystone is that such tool is used to compare performances
> between different versions of Python.
That's why I just propose to switch it to time.time(), which surely is
available on each and every Python version and impleme
Paul Sokolovsky added the comment:
Yes, and my note about "scientificity" above. Also compare with your own
account of time.perf_counter() above ("Usually time.perf_counter() is the
expected function.")
Also, I didn't want to start discussion on how to do benchmark
Paul Moore added the comment:
Is there any chance this can be included in Python 3.4? It would apparently
allow numpy to be built with stock tools on Windows Python.
--
nosy: +pmoore
___
Python tracker
<http://bugs.python.org/issue16
Paul Moore added the comment:
Unfortunately not really - it's the numpy guys that need this, so hopefully the
original poster can comment.
I'll see if I can hand-patch the relevant files and do a pip install numpy to
see if it fixes that specific scenario. I'll report back.
I
Paul Moore added the comment:
Sigh. Looks like it doesn't fix the issue of building numpy - plus it doesn't
apply cleanly. My apologies for the noise, I'll report the issues with the
patch back on the numpy issue where I was told a
Paul Moore added the comment:
Maybe it's not applicable to 3.3 somehow, which is what I tried. I applied the
patch to the distutils in the system installed Python, then ran pip install
numpy from a virtualenv.
It's quite possible that a million things could have gone wrong in th
Paul Moore added the comment:
Nothing obvious or Windows-specific from what I can see. It does seem to me
that EnvironmentVarGuard doesn't monkeypatch os.environ even though it looks
like it intends to (__exit__ sets it back, but __enter__ doesn't monkeypatch
it). So maybe th
Paul Moore added the comment:
Sigh. Yes, I looked at that and wondered if os.devnul would show as existing,
but I similarly misread the test and assumed it was testing what it was meant
to test :-(
os.path.exists(os.devnull) is false on Windows (just checked) so this
assumption *is* what
Paul Moore added the comment:
In ensurepip, _disable_pip_configuration_settings has the line:
os.environ['PIP_CONFIG_FILE'] = os.devnull
On Windows, os.devnull does not behave like a real file in that
os.path.exists(os.devnull) is False even though opening it works fine. So tha
Paul Moore added the comment:
Maybe. I don't know what *else* might fail because devnull is special. The
filename gets passed straight to configparser, for a start.
But if you want to do that I'm OK with that - I just won't make that change
myself. Would the special-casing
Paul Moore added the comment:
As noted in http://bugs.python.org/issue1311 (referenced from
http://bugs.python.org/issue20541) it's not actually correct to assume that
os.path.exists(os.devnull) returns true, as on Windows the "null device" is not
a proper filesystem object.
Paul Moore added the comment:
Sounds reasonable. Having thought about it a bit more, I don't think it's a big
deal. I'll put a PR together for special-casing devnull.
--
___
Python tracker
<http://bugs.pyt
Paul Moore added the comment:
https://github.com/pypa/pip/pull/1543
--
___
Python tracker
<http://bugs.python.org/issue20053>
___
___
Python-bugs-list mailin
Paul Moore added the comment:
Fix now merged into pip 1.5.X branch
--
___
Python tracker
<http://bugs.python.org/issue20053>
___
___
Python-bugs-list mailin
Paul Moore added the comment:
I had not noticed that, but yes. It would be unreasonable on Windows to install
pip3 and pip3.4 but not plain pip. So +1 on this change.
(In fact, on Windows, omitting the versioned names would conform more closely
to how Python is installed, but it'
paul j3 added the comment:
As Steven pointed out, the existing `add_argument_group` mechanism can be used
to group required arguments. For example
- temp.py --
parser = argparse.ArgumentParser(description = 'Do something')
paul j3 added the comment:
The attached file shows how the default argument groups could be redefined,
using 'required' as the criteria.
I've implemented it as a method that is added to a subclass of ArgumentParser.
This method is invoked after arguments are defined, prior to
New submission from Paul Moore:
There appears to be a significant issue with importing from zip files on Python
3.3.4. I have tested this on Windows 7, 64-bit, using the MSI installer from
python.org.
To reproduce, download virtualenv and extract the
C:\Work\Scratch\virtualenv-pfm
Paul Moore added the comment:
This is still the case in the 3.4rc0 Windows installer. Could we get something
definite for 3.4 final? It may be too late for that to be anything other than
documenting that the command "pip" is not available, but given that most 3rd
party documents us
Paul Moore added the comment:
Apologies, cut & paste error.
3.3.2 32-bit:
PS 20:49 C:\Work\Scratch\virtualenv-pfm
>py -3.3-32 -c "import pip"
PS 20:49 C:\Work\Scratch\virtualenv-pfm
>py -3.3-32 -V
Python 3.3.2
3.4rc0 is not affected either:
PS 20:54 C:\Work\Scratch\virtua
paul j3 added the comment:
Here's another possible solution: add a `help_groups` parameter to
ArgumentParser. It is a list of base argument group names.
`parser.add_argument(...)' places the action in one of those groups.
This is a generalization of the current code which creates
Changes by paul j3 :
Added file: http://bugs.python.org/file34074/alt_grouping2.py
___
Python tracker
<http://bugs.python.org/issue9694>
___
___
Python-bugs-list mailin
Paul Moore added the comment:
I'm afraid I don't have things set up to do a Python build right now. I *might*
have time later, and if so I'll give it a try, but I can't promise. Also, I
haven't yet managed to show the issue on 3.4.0rc1, but that may be because my
ch
Paul Moore added the comment:
OK, I have a build of 3.4 that shows the bug. How do I revert
http://hg.python.org/cpython/rev/20b77ff040b6 ? hg backout -r 20b77ff040b6 says
"abort: cannot backout a merge changeset".
--
___
Python trac
Paul Moore added the comment:
I tried hg backout 2807a5f011e4. It gave errors in the form of dialog boxes
titled "Microsoft Visual Studio" saying "File '-nosplash' not found". I've no
idea where these came from and whether they matter, but I tried clicking OK
Paul Moore added the comment:
Note - we're going to have to work around this bug in Virtualenv (even if it's
just in code specific to 3.3.4) so a workaround for 3.3.4 and an explanation of
what's going wrong would be useful, a
Paul Moore added the comment:
Thanks for the workaround. I'm going to try to do some serious testing of all
this over the weekend, I'll let you know how it goes.
--
___
Python tracker
<http://bugs.python.o
paul j3 added the comment:
This patch corrects the handling of `seen_non_default_action` in another case -
a positional with '?' and `type=int` (or other conversion).
if
parser.add_argument('badger', type=int, nargs='?', default=2) # or '2'
and the
paul j3 added the comment:
The suggestion in this issue is to add a 'mutually_inclusive_group' mechanism,
one that would let users specify that certain sets of arguments must occur
together. Furthermore there was mention of allowing some sort of nesting.
Modeling
paul j3 added the comment:
Regarding a usage line like:
(-o FILE | (-O DIR & (-p PATTERN | -s SUFFIX))
The simplest option is to just a custom written 'usage' parameter.
With the existing HelpFormatter, a nested grouping like this is next to
impossible. It formats the argu
Paul Moore added the comment:
Georg - see http://bugs.python.org/issue20621#msg211209 for what I did. That
shows backing out did *not* fix the issue. But I did backout on the default
branch, and my backout may not have worked as I explained.
I just tried to do hg backout on the 3.3 branch and
Paul Moore added the comment:
OK, confirmed.
Backing out to just before revision 2807a5f011e4 the problem has disappeared.
Re-applying just 2807a5f011e4 causes the issue to appear again.
--
___
Python tracker
<http://bugs.python.org/issue20
Paul Moore added the comment:
OK, I can confirm that both the patches fix the issue when applied to the
relevant branches.
--
___
Python tracker
<http://bugs.python.org/issue20
Paul Moore added the comment:
Can anyone confirm if this is a Windows-only issue? I need to know whether I
should block Python 3.3.4 in virtualenv for everyone, or just for Windows.
I only have Windows I can test on.
--
___
Python tracker
<h
Paul Moore added the comment:
Will someone make sure this gets logged the way it needs to for Larry's 3.4rc2
cherrypick process? Ta.
--
___
Python tracker
<http://bugs.python.org/is
Paul Moore added the comment:
I have reports from virtualenv users that this is not happening on Linux, BTW.
Could it be platform-specific somehow? Have the Unix users here been able to
reproduce this?
As regards a unit test, presumably we could ship a preconstructed zipfile in
the test
Paul Moore added the comment:
Re unit tests. Doh. Of *course* there are tests for importing from zipfiles.
And I just ran them (on Windows) and they worked. So there's something more
complex going on here and I don't know how you test for it, sorry (short of by
trying an import fr
paul j3 added the comment:
This patch uses:
tests = self._registries['cross_tests'].values()
to get a list of functions to run at the end of '_parse_known_args'.
I replaced all of the mutually_exclusive_group tests (3 places) in the
ArgumentParser with a static funct
paul j3 added the comment:
This is an example of using 'patch_w_mxg2.diff' to handle the inclusive group
case proposed by the OP.
Since 'seen_non_default_actions' (and 'seen_actions') is a set of 'Actions', it
is convenient to use 'set' meth
Paul Moore added the comment:
Should this be mentioned in the 3.3.5 changelog
(http://docs.python.org/3.3/whatsnew/changelog.html)?
--
___
Python tracker
<http://bugs.python.org/issue20
paul j3 added the comment:
http://stackoverflow.com/questions/11455218
python, argparse: enable input parameter when another one has been specified
$ python myScript.py --parameter1 value1
$ python myScript.py --parameter1 value1 --parameter2 value2
$ python myScript.py --parameter2
2001 - 2100 of 3212 matches
Mail list logo