Paul Moore added the comment:
That's correct. The problem here is that it's not possible to know what version
of Python a virtualenv has (at least, not without running it, which isn't
appropriate in the launcher). So the only case it's possible to
Paul Moore added the comment:
Hmm, I didn't know that (although virtualenv-based environments don't have an
equivalent to pyvenv.cfg).
But there's some confusion here. This patch only affects command line usage
(running "py.exe" to start Python). I don't really
Paul Moore added the comment:
Thanks. Updated patch with the new mime-type.
Looks like there's disk errors on that file with the CRC check. Lovely :-)
--
Added file: http://bugs.python.org/file38192/pep441.patch
___
Python tracker
Paul Moore added the comment:
On 20 February 2015 at 16:31, Wolfgang Maier wrote:
>> The scope of this PEP is just to make the "py" command (with no explicit
>> version) use an active virtualenv before falling back to the default Python.
>> This is specifically t
New submission from Paul Hobbs:
Using pid namespacing it is possible to have multiple processes with the same
pid. "semlock_new" creates a semaphore file with the template
"/dev/shm/mp{pid}-{counter}". This can conflict if the same semaphore file
already exists due to an
Paul Moore added the comment:
Looks OK to me.
I assume the differences between the math and cmath code and tests is because
cmath uses Argument Clinic and math doesn't, and cmath uses unittest.main
whereas math adds the suites manually? As far as I can see, that's what
New submission from Paul Marks:
Python's web servers were formerly reachable from IPv6 clients, as evidenced by
this example code for socket.getaddrinfo():
https://docs.python.org/3/library/socket.html#socket.getaddrinfo
But today, www.python.org is IPv4-only:
>>>
paul j3 added the comment:
And the corresponding bug issue
http://bugs.python.org/issue9351
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue24
paul j3 added the comment:
Another example of this patch causing backward compatibility problems
http://bugs.python.org/issue24251
--
___
Python tracker
<http://bugs.python.org/issue9
paul j3 added the comment:
The code that converts '-' to '_' is independent of the code that uses
'prefix_chars'.
The '-' conversion handles a long standing UNIX practice of allowing that
character in the middle of option flags. It's an attempt
paul j3 added the comment:
Off hand I don't see a problem with this patch (but I haven't tested it yet).
But I have a couple of cautions:
The docs say, regarding the Namespace class:
> This class is deliberately simple, just an object subclass with a readable
> string repre
paul j3 added the comment:
An alternative would be to wrap a non-identifier name in 'repr()':
def repr1(self):
def fmt_name(name):
if name.isidentifier():
return name
else:
return repr(name)
type_name =
paul j3 added the comment:
http://bugs.python.org/issue15125
argparse: positional arguments containing - in name not handled well
Discussion on whether positionals 'dest' should translate '-' to '_'.
--
___
Python tr
paul j3 added the comment:
Yes, the '_' makes it accessible as an attribute name. But the presence of '-'
in the option name has a UNIX history. That is a flag like '--a-b-c' is
typical, '--a_b_c' is not.
There is less of precedent for a flag like
paul j3 added the comment:
I mentioned in the related bug/issue that no one has to use odd characters and
spaces in the Namespace. While they are allowed by 'getattr' etc, the
programmer has the option of supplying rational names in the 'dest' parameter.
There's
Paul Moore added the comment:
I'm still somewhat confused as to why we're looking at this in the context of
manually building an extension. It's *certainly* true that anyone attempting to
build a Python extension by hand (as per Matthew Barnett's instructions) should
be
New submission from Paul Sokolovsky:
This issue was brought is somewhat sporadic manner on python-tulip mailing
list, hence this ticket. The discussion on the ML:
https://groups.google.com/d/msg/python-tulip/JA0-FC_pliA/knMvVGxp2WsJ
(all other messages below threaded from this)
https
Paul Sokolovsky added the comment:
No, I haven't brought this "many times before". Discussion on the mailing list
last week was first time I brought up *this* issue. But it's indeed not the
first time I provide feedback regarding various aspects of asyncio, so I wonde
Paul Sokolovsky added the comment:
Thanks for the response.
> and an API with more choices is not necessarily better.
I certainly agree, and that's why I try to implement MicroPython's uasyncio
solely in terms of coroutines, without Futures and Transports. But I of course
ca
Paul Moore added the comment:
Personally, I'm OK with the wording in the 3.5.0b2 docs, as far as basic
terminology and glossary-style information goes.
I think coroutines, async, and event loops are badly under-documented in the
broader context, though - there is very little in the
paul j3 added the comment:
Does this work for
help='choices: %(choices)s'
Without setting up my own test case, I'm guessing that the problem is with an
empty help string. `help=''` should be ok, but the test handle that probably
occurs earlier.
Choices, e
Changes by paul j3 :
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue24441>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.pyth
paul j3 added the comment:
What are you trying to accomplish in the examples with a 'dest'? For a
positional, 'dest' is derived from the 'foo' name. There is no need to supply
'dest', in fact produces the error you get. It has nothing to with
paul j3 added the comment:
None of the `append` actions makes sense with positionals. The name (and hence
the 'dest') must be unique. And positionals can't be repeated.
There are other ways to put a pair of values in the Namespace. For example,
after parsing
args.x
paul j3 added the comment:
You can give the positional any custom name (the first parameter). You just
can't reuse it (by giving 2 positionals the same name). And if you don't like
what the 'help' shows, you can set the 'metavar'. That way only you see the
pos
paul j3 added the comment:
(Important correction at the end of this post)
The test that you are complaining about occurs at the start of the
'add_argument' method:
def add_argument(self, *args, **kwargs):
"""
add_argument(dest, ..., name=value,
Paul Moore added the comment:
+1 from me on this. Are there any specific technical implications (in terms of
ease of interoperability, ability to use a different compiler to build Python,
or whatever)? Whether there are or not, I'm still in favour - I think it's a
good thing anyway
Paul Moore added the comment:
Cool. Easier distribution is good. Better compatibility with GPL requirements
(depending only on "system facilities") is probably helpful for the general
community, too.
Embedding in C++ built with a different version of the compiler is always going
t
paul j3 added the comment:
To wrap this up, the correct way to specify that 2 or more positionals share a
'dest' is to supply that dest as the first parameter. If the help should have
something else, use the `metavar`.
import argparse
parser = argparse.Argu
Paul Moore added the comment:
On 30 June 2015 at 23:30, M.-A. Lemburg wrote:
> I don't remember the details of why this feature was added,
> but can imagine that it was supposed to enable installation
> of new importers via .pth files.
I don't know for certain if this
Paul Moore added the comment:
As noted, this behaviour is as documented, and is deliberately designed to
execute the shebang line as either an executable (which calc is) or one of a
specific set of "virtual" entries (which does not include /bin/env).
--
resolution: -&
Paul Koning added the comment:
Sure, you can use a vfs. That's true for a lot of mock functions; the benefit
of mock, including mock_open, is that it provides an easier and better packaged
way. The behavior expected is "be like a file". So in that last example, if
you open i
Paul Koning added the comment:
So if I understand right, it seems to me the 3.5/mock 1.1.4 behavior is
correct. mock_open(read_data="f") acts like a file that contains f, and m()
acts like an open() of that file. So if I call open once, I should read the f,
then EOF. If I open t
Paul Koning added the comment:
I suppose. And it certainly is much better than the original behavior. But if
this is the approach chosen, it should be clearly called out in the
documentation, because the current wording suggests the 1.1.4 behavior, not the
one you recommended
Paul Koning added the comment:
Section 26.7.7 of the library manual describes mock_open with the words:
A helper function to create a mock to replace the use of open. It works for
open called directly or used as a context manager.
which implies that it works just like open. Given that it
paul j3 added the comment:
Right, the only arguments that a `store_true` Action class accepts are:
option_strings, dest, default=False,required=False, help=None
parser.add_argument() massages its parameters a bit, and then uses the 'action'
parameter to construct an Actio
paul j3 added the comment:
argparse.FileType serves 2 purposes
- handling filenames for simple quick shell-like scripts
- as a model for custom 'types', specifically one that uses a class to generate
the desired type callable.
Other bug-issues show that it hasn't aged well.
paul j3 added the comment:
These two types of groups serve different purposes and aren't designed to nest
or interact.
An argument group groups arguments in the help lines. It does not affect
parsing at all. It can't be used to add a 'group' of arguments to another
paul j3 added the comment:
Also, argparse.PARSER is '+...'
'? * +' have closely matched analogs in regex patterns. '...' and '+...' do
not. So Python users will have an intuitive idea of what "nargs='*'" means.
"nargs=
Paul Moore added the comment:
This is standard Windows behaviour. Executables are always located first in the
directory where your program (in this case the Python executable) is running
from - even before searching PATH.
If you want to use a different Python, you should specify the full path
New submission from Paul Murphy:
This is a duplicate of Issue 23654, except it occurs on GCC 5.1 with -O2 when
building for a ppc64le target.
GCC is optimizes this as a tail call, removing the accesses to the "unused"
stack variables.
--
components: Extension Mod
Paul Murphy added the comment:
Somehow, you need to preserve access to the stack memory. The generated code is
still growing the stack, it just fails to touch any of it.
I'm guessing a volatile access would just add an extra non-stack access to the
infinite loop.
Initially, I had
Paul Murphy added the comment:
...
#pragma GCC optimize ("no-optimize-sibling-calls")
...
Does preserve the desired behavior under -O2 and -O3, probably a bit nicer than
using O0.
--
___
Python tracker
<http://bugs.python.o
New submission from Paul Clarke:
in "subprocess" module documentation has a section for "replacing older
functions with subprocess", specifically 17.1.4.5 "replacing os.popen", which
includes the example on "return code handling", specifically this li
Paul Moore added the comment:
Now that "Add Python to PATH" is an option on the front screen of the installer
(not hidden behind the scary "customize" option) this can be closed.
I recall Steve suggesting there might be issues with the way a user install
results in the
paul j3 added the comment:
A related issue which Sworddragon found just before starting this issue is
http://bugs.python.org/issue9625
The handling of defaults in argparse is a bit complicated. In general it errs
on the side of giving the user/developer freedom to set them how ever they
Paul Moore added the comment:
> Maybe we can special-case pip uninstalling it from the site-packages folder?
> *Paul* - any thoughts?
Sorry, I've been following this thread but it's been moving pretty fast, so I'm
probably replying too late to be helpful now :-(
One alte
New submission from Paul Moore:
At the moment, building an application that embeds Python requires the user to
have a full install of Python on the build machine, to get access to the
include and library files.
Now that we provide an embeddable build of Python on Windows, would it be worth
paul j3 added the comment:
`parser.set_defaults` lets you set a default for any `dest`. It does not have
to be connected with an argument. See what the docs say about using it to set
an action linked to a subparser.
`arg1 = parser.add_argument(...)` returns an `Action` object. The parser
paul j3 added the comment:
`get_default` and `set_defaults` are parser methods, and do more than set or
get a particular Action attribute. 'Set' for example changes both the
'parser._defaults' attribute, and a 'action.default' attribute. Defaults are
complex an
paul j3 added the comment:
This assertion error caused by brackets (and other 'odd' characters) in the
metavar is a known issue.
http://bugs.python.org/issue11874
http://bugs.python.org/issue14046
The formatter that handles line wrapping of the usage line is fragile.
-
paul j3 added the comment:
The `type` parameter is a *function* that takes a string, and returns a valid
value. If it can't convert the string it is supposed to raise an error. The
default one is a do-nothing identity (take a string, return the string). `int`
is the Python function
paul j3 added the comment:
Here's a type function that enumerates the enum in the error message:
def enumtype(astring):
try:
return CustomEnumType[astring.upper()]
except KeyError:
msg = ', '.join([t.name.lower() for t in CustomEnumType])
msg =
paul j3 added the comment:
I'm not quite sure what you mean by 'the enum type to be stored directly'.
With my type function, the string input is converted to an enum object and that
is stored in the Namespace. You can't be any more direct than that.
Or are you thinking
paul j3 added the comment:
Here's a EnumType factory class, modeled on FileType.
class EnumType(object):
"""Factory for creating enum object types
"""
def __init__(self, enumclass):
self.enums = enumclass
def __call__(self, astring):
paul j3 added the comment:
I realized while answering a Stackoverflow question that the resolve method has
the pieces for removing an Action from the parser. It removes an existing
Action so that the new, conflicting one, can replace it.
It's meant to be used with flagged arguments
Paul Moore added the comment:
Also, the Windows build process is documented in PCBuild/readme.txt - see
https://hg.python.org/cpython/file/tip/PCbuild/readme.txt
More generally the devguide documents how to build CPython -
https://docs.python.org/devguide/setup.html#compiling
New submission from Paul Kehrer:
Python 3.5.0 (default, Sep 13 2015, 10:33:07)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import codecs
>>
paul j3 added the comment:
A related issue is
http://bugs.python.org/issue24754
argparse add_argument with action="store_true", type=bool should not crash
In this case the user specified a parameter that the 'store_true' subclass did
not accept.
In both cases, '
Changes by paul j3 :
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue25297>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.pyth
paul j3 added the comment:
My testing shows that it's a problem with the subparsers listing. When regular
arguments are long, 'max_help_position' works (within limits allowed by
'width').
--
___
Python tracker
<http:
paul j3 added the comment:
There's a bug in the HelpFormatter.add_argument method. It does not take into
account the extra indentation of subactions (sub parsers) when calculating
self._action_max_length.
The corrected method and a test case is in the attached file.
class MyForm
paul j3 added the comment:
A fix that I am exploring would wrap the Action instantiation call in
add_argument with a try/except block
That is replace:
def add_argument(...)
action = action_class(**kwargs)
...
with
try:
action
paul j3 added the comment:
The unittest file test_argparse.py tests add_argument parameters in
class TestInvalidArgumentConstructors(TestCase)
It looks at a dozen different categories of errors, mostly checking that they
return the correct TypeError or ValueError. It does not check the
paul j3 added the comment:
The unittest test_argparse.py has one related test
class TestAddSubparsers
def test_alias_help
has a long enough subparser invocation (with aliases) to produce wrapping with
the default 24 max position:
commands:
COMMAND
paul j3 added the comment:
I don't recall other issues or discussions about lining up short and long
option strings.
Producing a more compact invocation has raised in StackOverflow questions. I
don't recall if there has been bug/issue on the same.
If I recall correctly it isn
paul j3 added the comment:
http://stackoverflow.com/questions/18275023/dont-show-long-options-twice-in-print-help-from-argparse
http://stackoverflow.com/questions/9366369/python-argparse-lots-of-choices-results-in-ugly-help-output
http://stackoverflow.com/questions/23936145/python-argparse
paul j3 added the comment:
Formatter _format_action_invocation(self, action) is the key function. Notice
how it treats positionals and optionals separately. Also it calls
default = self._get_default_metavar_for_optional(action)
args_string = self._format_args(action, default)
to get
paul j3 added the comment:
I have seen questions on StackOverflow with 'store_true' and explicit
`default=False` parameters. I don't recall any where this was a problem.
Usually it's as harmless as users specifying other defaults like
`action='store'`, or a
paul j3 added the comment:
What you are asking about is the fact that different arguments can share a
'dest'.
https://docs.python.org/3/library/argparse.html#dest
The 'append_const' action has an example of shared 'dest'. It says:
The 'append_con
Changes by paul j3 :
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue18769>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.pyth
paul j3 added the comment:
Under what circumstances would this be useful?
http://bugs.python.org/issue19462 asks for a 'remove_argument' method. That
seems to be most useful if the argument is inherited from a parent parser.
A subparsers argument could be inherited from a paren
paul j3 added the comment:
There's a partial overlap with this issue
http://bugs.python.org/issue22848
which seeks to hide a subparser - both in the help lines and the choices lists.
--
___
Python tracker
<http://bugs.python.org/is
New submission from Paul Moore:
I have had a user install of Python 3.5rc3 for some time on one of my PCs. It
also had plenty of other versions on there - 3.4, 3.3, 2.7 and 2.6. The 3.5rc3
install was a user install.
I have my Python 3.4 install set up on PATH, and I've configured py.i
paul j3 added the comment:
The short `repr` is produced in Python2.7, but not 3.5.
Your test case:
action = argparse._StoreAction(['--file], dest='file_path')
error = argparse.ArgumentError(action, 'File not found.')
print(str(error))
print(repr(err
paul j3 added the comment:
This formatter produces an error if one or more of the arguments uses the
default `None` type (a string). This is because `None` does not have a
`.__name__`.
This HelpFormatter probably has been rarely, if ever, used. The metavar
parameter works just as well
Paul Moore added the comment:
It's a very personal choice, but I prefer the current icons. I'm -1 on this
change.
--
___
Python tracker
<http://bugs.python.o
Changes by Paul Moore :
--
nosy: -paul.moore
___
Python tracker
<http://bugs.python.org/issue25444>
___
___
Python-bugs-list mailing list
Unsubscribe:
paul j3 added the comment:
The choice of 'type' for this parameter is occasionally confusing, because the
connection to the Python 'type()' function or what we think of as 'native
types' is only tangential.
A name like 'converter' or 'string_co
paul j3 added the comment:
In
_ActionsContainer._add_container_actions there is this note:
# add container's mutually exclusive groups
# NOTE: if add_mutually_exclusive_group ever gains title= and
# description= then this code will need to be expanded as above
In other bug/i
paul j3 added the comment:
I've attached a file that monkey patches the
_ActionsContainer._add_container_actions method.
It corrects the `_container` attribute of the copied mutually exclusive groups.
I've only tested it for the case presented in this issue (and the relate
Sta
paul j3 added the comment:
Argument groups are not designed to be nested.
If you print_help the parent parser, you'll see that the sub_args are missing
entirely, not just displaced. They appear in the usage, but not the help
lines. sub_group has no record that it was added to global_
Paul Moore added the comment:
Why is it too late to install a new importer to sys.path_hooks when zipimport
is installed? As far as I am aware, running the stdlib from a zipfile works
fine, which seems to be equivalent to your use case.
--
nosy: +paul.moore
New submission from Paul Hammant:
It NEEDS to communicate more as to why it is rolling back the pip install
(progress bar goes backwards, install fails).
Reasons can be:
1. older/wrong versions of Python listed in the PATH - eg c:\Python27
encountered when c:\Python34 is being installed
Paul Hammant added the comment:
Steve, if you want I can attempt to reproduce this. Maybe I'll take a video of
the reproduction.
--
___
Python tracker
<http://bugs.python.org/is
Paul Hammant added the comment:
That's all the files in the %TEMP% dir beginning with Python* - right?
--
___
Python tracker
<http://bugs.python.org/is
paul j3 added the comment:
There are 2 issues
parsing - how to reserve one or more arguments for use by following
'positionals'. Fixes have been proposed in other bug/issues, but aren't
trivial.
usage formatting - the stock formatter displays all optionals first, f
paul j3 added the comment:
I can understand changing
'7'.split()
but this change is IMO ugly:
- >>> print(parser.parse_args('--foo B cmd --arg1 XX ZZ'.split()))
+ >>> print(parser.parse_args(['--foo', 'B', 'cmd'
paul j3 added the comment:
How about:
These store the values True and False respectively (and default to False
and True if absent).
The reference to `store_const` is confusing, since almost no one uses that
action.
The `store_const` paragraph has:
(Note that the const keyword
New submission from paul j3:
The documentation for Mutual exclusion
https://docs.python.org/3/library/argparse.html#mutual-exclusion
needs a note that a mutually exclusive group may contain one positional
argument. But that argument must be either nargs='?', or nargs='*
Paul Hammant added the comment:
Chronalog for today, below. Status - can reproduce at will, can't produce
%TEMP% files was for - there aren't any.
0. I deleted all Python prefixed files from %TEMP%
1. I uninstalled Python 3.4 via it's windows installer. It progressed to
comp
Paul Moore added the comment:
Just to clarify, it's intended that you simply "python -m pip install --upgrade
pip setuptools" to get the latest version.
--
nosy: +paul.moore
___
Python tracker
<http://bugs.pyt
Changes by Paul Moore :
--
keywords: +easy
___
Python tracker
<http://bugs.python.org/issue26336>
___
___
Python-bugs-list mailing list
Unsubscribe:
New submission from Paul Moore:
See the following test (in Python 3.5):
>>> u'a\nb£'.encode('utf-8').splitlines()
['a', 'b\xc2\xa3']
I encode a string in UTF-8, then use the (bytes) splitlines function on it. The
return value is a list of st
Paul Moore added the comment:
That's weird. I can confirm it's working for me on 3.5.1. I'll double check I
wan't in 2.7 when I'm back at my work PC, but I didn't *think* I was. But
regardless, there's clearly no bug
Paul Moore added the comment:
Sigh. I had installed Python 2.7 at some point, and py.exe picked it up by
default :-(
Isn't it about time that py.exe defaulted to the latest version installed, not
the latest version of Python 2?
--
___
P
paul j3 added the comment:
This has been raised before. I think
http://bugs.python.org/issue9253
is the correct issue.
It used to be that 'subparsers' were required. But there was a change in how
'required' arguments were tested, and 'subparsers' fell throug
paul j3 added the comment:
The usage line formatter needs a major rewrite.
Currently it formats usage for all the arguments as one line (two actually,
optionals and positionals are handled separately), and then breaks it into
'wrappable parts'. It then compiles the lines from t
Changes by paul j3 :
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue26394>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.pyth
paul j3 added the comment:
I need to study that patch more, but I don't like the fact that it operates at
the core of the parsing (e.g. in 'take_action'). That's a dangerous place to
add features. Unexpected behaviors and backwards compatibility problems are
too likely.
2401 - 2500 of 3213 matches
Mail list logo