Steven Bethard added the comment:
The argparse changes and tests look good. The new method needs to be
documented. You can see some other things (e.g. Misc/NEWS) that also need to be
updated by running "make patchcheck" as described here:
http://docs.python.org/devguide/
Steven Bethard added the comment:
Looks good. There was one typo in "parametres" that I've fixed. Should be ready
to apply.
--
Added file: http://bugs.python.org/file26469/11807_3.patch
___
Python tracker
<http://bugs.pyt
Changes by Steven Bethard :
--
resolution: -> duplicate
status: open -> closed
superseder: -> argparse: Default Help Message Lists Required Args As Optional
___
Python tracker
<http://bugs.python.or
Steven Bethard added the comment:
I agree that this looks like a bug. I think the fix is something like the
attached patch, but it needs some tests to make sure that it fixes your problem.
--
keywords: +patch
Added file: http://bugs.python.org/file26471/issue9625.diff
Steven Bethard added the comment:
Yeah, overwriting the existing parser is probably not typically what the user
intended.
However, I could see someone doing this if, say, they had a parser designed by
another module writer, and they wanted to use it but just change one of the
sub-parsers or
Steven Bethard added the comment:
I think it makes a lot of sense to allow people to disable abbreviations, so +1
on the feature request.
The patch looked good. There was one typo - using "accept_abbrev" in the
docstring instead of "allow_abbrev" as in the implementati
Steven Bethard added the comment:
Sorry, my mistake, the doc changes were already in the patch. I just checked
them and they look good too. So everything's ready to commit.
Thanks for your contribution!
--
___
Python tracker
Steven Bethard added the comment:
On the off chance that someone was waiting for feedback from me, I'll say:
(1) A simple boolean --foo/--no-foo action seems useful to me. I would probably
call it BooleanOptionalAction rather than FlagAction. (Almost anything could be
considered a
Steven Bethard added the comment:
The fix looks right, but we definitely need a test. I tried to write one, but
I'm not sure how to do this properly given how test_argparse redirects standard
input and output (so that fileno() doesn't work anymore). I've attached my
current (f
Steven Bethard added the comment:
The tests look like they're testing the right things, but the tests should
instead be written like the rest of the argparse tests. For example, look at
TestOptionalsNargs3 and TestPositionalsNargs2. You could write your tests to
look something like
Steven Bethard added the comment:
Your patch is a good start, but it needs to handle all the related situations,
e.g. nargs='?' and the possibility of having more than one zero-length argument
at the end.
I believe the following patch achieves this. Please test it out.
-
New submission from Steven Bethard :
>From http://bugs.python.org/issue14191#msg155202:
ArgumentParser.parse_args(args=None, namespace=None)
...
However, nowhere is the args= parameter explained. One example is given at the
end of 15.4.4.6 showing the use of args= which apparently accept
Steven Bethard added the comment:
I created Issue 15427 for the parse_args documentation bug. So let's make this
issue just about parsing intermixed arguments.
Yes, if someone would like to provide a patch for this, please create a method
"parse_intermixed_args" rather than a
Steven Bethard added the comment:
I don't think this is a bug. You've specified two arguments with the same
destination, "foo". This means that argparse will parse the first one, assign
it to the attribute "foo" and then parse the second one and assign it
Steven Bethard added the comment:
I'm sympathetic to the idea that '-' should be translated similarly for
optional and positional arguments, but as you've noted, it would be a risky
patch because it's already possible for people to use getattr on hyphenated
argumen
Steven Bethard added the comment:
Thanks for working on this! I think keeping the first example as simple is
possible is probably a good idea. And I didn't have time to read through the
whole patch, but as far as I went, the pizza examples looked
Changes by Steven Bethard :
--
resolution: -> duplicate
status: open -> closed
superseder: -> argparse: Default Help Message Lists Required Args As Optional
___
Python tracker
<http://bugs.python.or
Steven Bethard added the comment:
I'm changing the title because I keep seeing duplicates.
Documentation patches still welcome!
--
title: argparse: Default Help Message Lists Required Args As Optional ->
argparse required arguments displayed under "optional argume
Steven Bethard added the comment:
I don't think there's any easy way for argparse to automatically do what you
want. However, there's a simple workaround - just use the dest= argument and
specify two different destinations:
>>> parser = argparse.ArgumentParser()
New submission from Steven Bethard :
Several bugs (e.g. Issue 15327 and Issue 15271) have been filed suggesting that
people aren't really clear on how argparse handles argument name collisions or
how they can get it to do what they want.
I think these problems could probably be solved
Steven Bethard added the comment:
If you'd like to help improve the documentation so that the workaround for your
problem is more obvious, please contribute to Issue 15428.
--
___
Python tracker
<http://bugs.python.org/is
Steven Bethard added the comment:
I'm going to close this issue, since argparse is doing what you've asked it to,
even if that wasn't what you expected.
But I think the documentation for this kind of thing could be improved. If
you'd like to help document the workaround f
Steven Bethard added the comment:
Definitely a bug here. Attached is a patch and a test, based on Russell Sim's
suggestion, that should fix it.
--
keywords: +patch
versions: +Python 3.4
Added file: http://bugs.python.org/file26486/13720.
Changes by Steven Bethard :
--
resolution: -> duplicate
superseder: -> argparse optionals with nargs='+' can't be followed by
positionals
___
Python tracker
<http://bu
Changes by Steven Bethard :
--
status: open -> closed
___
Python tracker
<http://bugs.python.org/issue15433>
___
___
Python-bugs-list mailing list
Unsubscri
Steven Bethard added the comment:
So Kotan's patch doesn't actually solve the original problem. Instead, it
inserts the workaround into the help message of the parser. I think this is
probably not the right fix. We should probably do two things:
(1) Right now: create a documenta
Steven Bethard added the comment:
And I guess Issue 9182 is the right place for (1).
--
___
Python tracker
<http://bugs.python.org/issue9338>
___
___
Python-bug
Steven Bethard added the comment:
Ok, here's what I think needs to go into the documentation here:
(1) Add a separate section to the argparse docs about '--'. Give examples like
the ones in this issue, and show how '--' can solve them
(2) Cross-reference the s
Steven Bethard added the comment:
I've updated the patch for the current trunk. Should be ready to commit.
--
Added file: http://bugs.python.org/file26490/Issue13249-4.patch
___
Python tracker
<http://bugs.python.org/is
New submission from Steven D'Aprano:
math.nan fails on some Decimal NANs. For example, while this works:
>>> import math
>>> from decimal import Decimal
>>> math.isnan(Decimal('nan'))
True
These both fail with ValueError:
math.isnan(Dec
Changes by Steven D'Aprano :
--
components: +Library (Lib)
type: -> behavior
___
Python tracker
<http://bugs.python.org/issue15544>
___
___
Python-bug
Steven D'Aprano added the comment:
Attached is a patch for decimal.py, and test_decimal.py. I cannot provide a
patch for the C decimal implementation, sorry.
Following Mark's suggestion, my patch keeps the sign but discards the payload
for quiet NANs, and raises ValueError for signa
Steven D'Aprano added the comment:
On 03/08/12 22:06, Mark Dickinson wrote:
>
>> Decimal('snan').is_nan() just returns true and I am under the impression
>> that IEEE 754 specifies the same.
>
> Sure, but IEEE 754 also specifies that math.sqrt() should
Steven D'Aprano added the comment:
On 05/08/12 03:45, Mark Dickinson wrote:
> It would make sense to add float.is_infinite and (possibly) float.is_finite
> methods at the same time.
If you don't add is_finite, you know someone is going to express surprise that
it wasn't
New submission from Steven Collins:
Given the way the documentation is written for re.VERBOSE - "Whitespace within
the pattern is ignored, except when in a character class or preceded by an
unescaped backslash" - I would expect all three of the findall() commands below
to return su
Steven Collins added the comment:
Fair enough, but in that case I still think the current behavior should be
documented. Attached is a possible patch. (This is my first interaction with
the Python issue tracker, by the way; apologies if I ought to have set some
field differently or left some
New submission from Steven Willis:
There are a number of issues dealing with the offset and length checks in
offset, such as issue12556.
I'm running into this issue as well, but with a normal file that happens to be
empty. I'm trying to access it with:
mmap.mmap(f.fileno(), length
Steven Bethard added the comment:
@gcbirzan: Could you please open up a new issue? The current issue is fixed -
it's just that the fix caused a new issue.
I would say that the `args` parameter was never intended to be anything but a
list, so currently there's a documentation bug
Changes by Steven Bethard :
--
resolution: -> duplicate
status: open -> closed
___
Python tracker
<http://bugs.python.org/issue15832>
___
___
Python-bugs-
Steven Bethard added the comment:
It's a bug, but it's already been reported in Issue 12776. There's a patch
there, but someone needs to commit it.
--
superseder: -> argparse: type conversion function should be called only once
Steven Bethard added the comment:
The fix looks about right to me.
There's a bug in the tests though:
parser.parse_args(('x'))
should probably be:
parser.parse_args(('x',))
since I assume the intent was to test tuples.
--
_
Steven Willis added the comment:
Here's a patch for 2.7. I don't know if it cleanly applies to the rest.
--
keywords: +patch
Added file: http://bugs.python.org/file27140/issue15676.patch
___
Python tracker
<http://bugs.python.o
Steven Bethard added the comment:
Interesting idea! The regex would need a little extra care to interoperate
properly with prefix_chars, but the approach doesn't seem crazy. I'd probably
call the constructor option something like "args_default_to_positional" (the
Steven Bethard added the comment:
You could try declaring a type converter and using the type= parameter of
add_argument. Your type converter could look something like:
def expanded_path(arg):
return os.path.expandvars(arg)
Would that work
Steven Willis added the comment:
Here's a patch for 3.1
--
Added file: http://bugs.python.org/file27153/issue15676-3.1.patch
___
Python tracker
<http://bugs.python.org/is
Steven Willis added the comment:
Here's a patch for 3.2
--
Added file: http://bugs.python.org/file27154/issue15676-3.2.patch
___
Python tracker
<http://bugs.python.org/is
Steven Willis added the comment:
Here's a branch against the default branch in mercurial. I couldn't find a
branch for 3.3 or 3.4.
--
Added file: http://bugs.python.org/file27155/issue15676-default.patch
___
Python tracker
<http://bu
Changes by Steven Willis :
--
versions: +Python 3.1
___
Python tracker
<http://bugs.python.org/issue15676>
___
___
Python-bugs-list mailing list
Unsubscribe:
Steven Willis added the comment:
Sorry, I thought that's what jcea was asking for. Here's an updated patch for
the default branch in mercurial that uses assertRaisesRegex in the test.
--
Added file: http://bugs.python.org/file27156/issue15676-def
Steven Bethard added the comment:
If you need to get things that aren't valid Python identifiers, use vars() to
get the dictionary:
http://docs.python.org/dev/library/argparse.html#the-namespace-object
Changing all non-alphanumeric characters to underscores would be a backwards
incompa
Steven Bethard added the comment:
It looks like the correct fix was already applied, but just to chime in here:
(1) Yes, the error is that the isinstance(action.default, str) check was lost
(2) Yes, it is intended that you can use a string value as your default and the
type= converter will be
Steven Bethard added the comment:
I haven't been following python-dev recently, but the only discussion I
remember was for non-strings in __dict__, not non-identifiers.
--
___
Python tracker
<http://bugs.python.org/is
Steven Bethard added the comment:
Oh, I see, you're right - the recent changes from the Roundup Robot are exactly
the wrong changes - special casing _StoreAction, not string defaults.
--
___
Python tracker
<http://bugs.python.org/is
Steven Bethard added the comment:
I see. So right now, both string defaults and non-string defaults are being
converted with the type= function. That seems suspect to me since the
documentation explicitly says "type= can take any callable that takes a single
string argument and return
Steven Bethard added the comment:
Ok, sounds good. Let's make the test check the documented behavior, and then
add back the isinstance(action.default, str) check.
--
___
Python tracker
<http://bugs.python.org/is
Steven Bethard added the comment:
Patch, with the basestring amendment, looks good.
> Do we need a new test for conversion of string defaults?
Yeah, I guess go ahead and add one. That will at least document our intentions
here, and if we decide to change that later, then it will force us
Steven Bethard added the comment:
Looks good to me.
--
___
Python tracker
<http://bugs.python.org/issue15935>
___
___
Python-bugs-list mailing list
Unsubscribe:
Changes by Steven D'Aprano :
--
nosy: +stevenjd
___
Python tracker
<http://bugs.python.org/issue16104>
___
___
Python-bugs-list mailing list
Unsubsc
Steven D'Aprano added the comment:
A question came up on Python-ideas about readline apparently missing a standard
function. See:
http://mail.python.org/pipermail/python-ideas/2012-October/016329.html
For debugging issues with readline, it would be be very useful to be able to
quer
Changes by Steven D'Aprano :
--
nosy: +stevenjd
___
Python tracker
<http://bugs.python.org/issue5845>
___
___
Python-bugs-list mailing list
Unsubsc
Steven Bethard added the comment:
Yeah, looks like we can close this. If anyone finds a specific bug in the use
of SUPPRESS, please open a new issue.
--
resolution: -> duplicate
status: open -> closed
superseder: -> document argparse's
Steven D'Aprano added the comment:
I don't think the relevant information -- that re match and search return None
in the case of no match -- is that distant from the paragraph quoted. This fact
is already mentioned FOUR times in the page, in each of the re.match, re.search
fun
New submission from Steven Myint:
In multiprocessing.pool, ExceptionWithTraceback is not derived from Exception.
Thus when it is raised, we get the exception, "TypeError: exceptions must
derive from BaseException". Attached is a patch that fixes this.
See below example traceback tha
Steven Myint added the comment:
I didn't quite understand the multiprocessing test cases, but attached is a
standalone test case that reproduces the problem. The problem only shows up
when using ThreadPool.
$ python thread_pool_exception_test.py
Traceback (most recent call last):
Steven Myint added the comment:
This bug was introduced in #13831.
--
versions: +Python 3.5
___
Python tracker
<http://bugs.python.org/issue20980>
___
___
Pytho
Steven D'Aprano added the comment:
If any of the docs are unclear, I would be very happy take suggestions to
improve them. But I'm not entirely sure that the docs are the right place to
show the equations. You should be able to look them up on Wikipedia or Wolfram
Mathworld if you
Steven D'Aprano added the comment:
Personally, I think that the second reason given in the footnote, that it makes
for confusing tests, is bogus, or at least it's a matter of opinion. I for one
don't think they are confusing, and would like to see mixed output/tracebacks
suppor
New submission from Steven D'Aprano:
If you know the population mean mu, you should calculate the sample variance by
passing mu as an explicit argument to statistics.pvariance. Unfortunately, it
doesn't work as designed:
py> data = [1, 2, 2, 2, 3, 4] # sample from a population w
Changes by Steven D'Aprano :
--
resolution: invalid ->
stage: -> needs patch
status: closed -> open
type: behavior -> enhancement
versions: +Python 3.5 -Python 2.7, Python 3.4
___
Python tracker
<http://bugs.p
Steven D'Aprano added the comment:
On Wed, Apr 09, 2014 at 08:20:42AM +, Wolfgang Maier wrote:
> I do not think this is a bug in the module, but rather incorrect usage.
[...]
No, it is legitimate usage. See, for example, "Numerical Recipes in
Pascal" by Press et al.
New submission from Steven Hiscocks:
I've seen an issue with using urandom on Python 3.4. I've traced down to fd
being closed (not by core CPython, but by third party library code). After
this, access to urandom fails.
I assume this is related to persistent fd for urando
Steven Hiscocks added the comment:
I agree in part, but it's quite common to close fd's in some cases like in a
child process after using "os.fork()". There is no way, as far as I'm aware, to
identify which fd is associated with /dev/urandom to keep it open; or anywa
Steven Hiscocks added the comment:
Just to add for those interested: a possible work around solution is using
"os.path.sameopenfile" to check fds against another known fd for urandom.
And for those wish to have a bit of fun (and maybe a security consideration):
python -c "impor
Steven Hiscocks added the comment:
Issue where I hit this is in Fail2Ban:
https://github.com/fail2ban/fail2ban/issues/687
Lines of code where this occurs:
https://github.com/fail2ban/fail2ban/blob/1c65b946171c3bbc626ddcd9320ea2515018677b/fail2ban/server/server.py#L518-530
There are other
Steven Barker added the comment:
A recent Stack Overflow question (http://stackoverflow.com/q/23192359/1405065)
relates to this bug. The questioner was surprised that filecmp.cmp is much
slower than usual for certain large files, despite the "shallow" parameter
being True.
It is pr
Steven D'Aprano added the comment:
Can't you just re-direct stdout or stderr? I'm sure that works even on Windows.
E.g.
py -${PY_QUALIFIER} -m compileall -q "$INSTDIR\pkgs" 2> null
Is there a reason you cannot do this? I think that adding functionality to
compilea
Changes by Steven D'Aprano :
--
nosy: -steven.daprano
___
Python tracker
<http://bugs.python.org/issue16104>
___
___
Python-bugs-list mailing list
Unsubscr
New submission from Steven Barker:
The "repr" of bound method objects can be misleading in certain situations. The
repr is always is of the format:
>
But "x" is often incorrect.
Here are some examples where the current code gets it wrong:
# inherited metho
Steven D'Aprano added the comment:
3.1, 3.2, 3.3 and 3.4 are all in feature-freeze, so this is only an option for
3.5.
A very tentative +1 on this feature. But I fear it may need to be discussed on
python-ideas first.
--
nosy: +steven.daprano
type: -> enhancement
versions:
Steven D'Aprano added the comment:
Actually, no, it is a staticmethod. See Guido's tutorial from way back in
version 2.2:
[quote]
__new__ is a static method. When defining it, you don't need to (but may!) use
the phrase "__new__ = staticmethod(__new__)", because thi
New submission from steven Michalske:
The asyncio documentation should comment on how to mute and increase some of
it's logging.
18.5.7.3. Logging
The asyncio module logs information with the logging module in the logger
'asyncio'.
Adding a bit of text that mentions the follo
Steven Barker added the comment:
Here's a patch against the default branch that fixes filecmp.cmp's behavior
when "shallow" is True, including an update to the module's docs (correcting
the previous ambiguity discussed in the 2011 python-dev thread mentioned by
San
New submission from Steven Barker:
While working on a fix for issue 1234674, I found that the first test method in
Lib/test/test_filecmp.py (FileCompareTestCase.test_matching) has switched up
messages in its AssertEquals calls. The first two asserts have the message that
should belong to the
Steven Barker added the comment:
Here's a patch that changes the behavior of method_repr in
Objects/classobject.c . It first tries to use __func__.__qualname__, then tries
__func__.__name__ as a fallback and finally uses "?" if neither of those
attributes are available.
I
Steven Barker added the comment:
Ah, I figured out why using %R may be bad. It breaks for the following silly
class:
class C():
def __repr__(self):
return repr(self.__repr__) # or use any other bound method
repr(C()) will recurse until the recursion limit is hit, both
Steven D'Aprano added the comment:
On Fri, May 16, 2014 at 07:50:16AM +, Ezio Melotti wrote:
> Do you want to propose a patch?
I'm really not sure that I agree with this request. I'm currently
sitting on the fence, undecided, about 60% against and 40% in favour of
expl
Changes by Steven Myint :
--
nosy: +myint
___
Python tracker
<http://bugs.python.org/issue21540>
___
___
Python-bugs-list mailing list
Unsubscribe:
Steven Barker added the comment:
The behavior of !s with the format() methods isn't exactly the same as %s with
% formatting. With the latter, the conversion depends on the type of the result
string, which in turn depends on whether the format string *or any of the
values values* is un
Steven D'Aprano added the comment:
On Wed, May 28, 2014 at 02:43:29PM +, Thomas Dybdahl Ahle wrote:
> I have written some proof of concept code here [1], I would appreciate
> you commenting on it, before I turn it into a patch, as I haven't
> contributed code to Pyt
Steven D'Aprano added the comment:
I've run some performance tests on six variations of the O(N) select algorithm,
based on Tim Peters' and Thomas Ahle's code, comparing them to the naive O(N
log N) "sort first" algorithm, and sorting is consistently faster up
Steven D'Aprano added the comment:
On Sat, Jun 07, 2014 at 01:02:52PM +, Julian Taylor wrote:
> but a selection algorithm is useful on its own for all of python and
> then a multiselect should be considered.
I like the idea of a select and/or multiselect for 3.5. As a
new
Steven D'Aprano added the comment:
I have been using something like this for many years now and it is very handy.
I have an early version of the code posted here:
http://code.activestate.com/recipes/577896
Over the next week or so, I'll prepare a patch.
Because it's a new feat
Steven D'Aprano added the comment:
On Mon, Jun 16, 2014 at 02:09:22AM +, Raymond Hettinger wrote:
> Perhaps a time-elapsed context manager would be a better fit in the
> contextlib module (which contains more general purpose macro-level
> tools usable for many different task
New submission from Steven Kryskalla:
I heard someone complain about this code appearing in the official
documentation in a few places:
for line in open("file.txt"):
print(line)
This code will print two newlines.
I went through the current "default" and "2.7&
Changes by Steven Kryskalla :
--
versions: +Python 2.7
Added file: http://bugs.python.org/file28192/r80699.patch
___
Python tracker
<http://bugs.python.org/issue16
Changes by Steven Kryskalla :
Removed file: http://bugs.python.org/file28192/r80699.patch
___
Python tracker
<http://bugs.python.org/issue16598>
___
___
Python-bugs-list m
Changes by Steven Kryskalla :
Added file: http://bugs.python.org/file28193/r80694.py27.patch
___
Python tracker
<http://bugs.python.org/issue16598>
___
___
Python-bug
Steven D'Aprano added the comment:
On Sun, Oct 13, 2013 at 09:21:13AM +, Nick Coghlan wrote:
>
> Nick Coghlan added the comment:
>
> Are the ReST docs the only missing piece here?
As far as I know, the only blocker is that the ReST docs are missing.
Also Guido woul
Steven D'Aprano added the comment:
Oscar Benjamin has just made a proposal to me off-list that has *almost*
convinced me to make statistics.sum a private implementation detail, at
least for the 3.4 release. I won't go into detail about Oscar's
proposal, but it has caused me to
Steven D'Aprano added the comment:
Here is the updated version which I hope is not too late for alpha 4. Main
changes:
* sum is now private
* docstrings have been simplified and shrunk somewhat
* I have a draft .rst file, however I'm having trouble getting Sphinx working
on my sy
1401 - 1500 of 1942 matches
Mail list logo