Change by Antony Lee :
--
nosy: -Antony.Lee
___
Python tracker
<https://bugs.python.org/issue19895>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Antony Lee :
--
nosy: -Antony.Lee
___
Python tracker
<https://bugs.python.org/issue22964>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Antony Lee :
--
nosy: -Antony.Lee
___
Python tracker
<https://bugs.python.org/issue30811>
___
___
Python-bugs-list mailing list
Unsubscribe:
New submission from Antony Lee :
Consider e.g.
In [2]: %timeit sorted([i for i in range(100)])
4.74 µs ± 24.3 ns per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [3]: %timeit sorted(i for i in range(100))
7.05 µs ± 25.7 ns per loop (mean ± std. dev. of 7 runs, 10
Antony Lee added the comment:
Feel free to close the issue if that's not the forum for this discussion, but
I'm still baffled by what's happening.
In the example that you give, the first case needs to look up the `list` global
and that callable (which happens to be the `list`
Antony Lee added the comment:
> But with a list or other sequence with a known length, the interpreter can
> allocate the right number of items up front, and avoid growing or shrinking
> the new list. I believe that this is the time saving you are seeing.
But certainly when
New submission from Antony Lee :
Consider the following example:
import pickle
class T:
def __init__(self):
self.attr = self.__foo
def __foo(self):
pass
print(pickle.loads(pickle.dumps(T(
This fails on 3.6 with `AttributeError:
New submission from Antony Lee :
The following example crashes Python 3.6:
from functools import partialmethod
import inspect
class T:
g = partialmethod((lambda self, x: x), 1)
print(T().g()) # Correctly returns 1.
print(T.g(T())) # Correctly returns 1.
print
New submission from Antony Lee :
At https://docs.python.org/3/c-api/arg.html#numbers, it is explicitly
documented that the unsigned number convertors do not perform overflow
checking. Implicitly, this suggests that the signed convertors *do* perform
overflow checking, which they indeed do
Antony Lee added the comment:
One could just add, immediately below the "Numbers" section, something like:
"The signed convertors (b, h, i, ...) perform overflow checking. The unsigned
convertors (B, H, I, ...) do not." That would actually be shorter than the
current ve
New submission from Antony Lee :
Python 3.6.4
In [15]: inspect.Parameter("foo", kind=inspect.Parameter.VAR_KEYWORD,
default=42)
---
ValueErrorTraceback (most recent
Change by Antony Lee :
--
nosy: -Antony.Lee
___
Python tracker
<https://bugs.python.org/issue12029>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Antony Lee :
--
nosy: -Antony.Lee
___
Python tracker
<https://bugs.python.org/issue33197>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Antony Lee :
--
nosy: -Antony.Lee
___
Python tracker
<https://bugs.python.org/issue21423>
___
___
Python-bugs-list mailing list
Unsubscribe:
Antony Lee added the comment:
I can't say I *really* need this anymore, but note that
https://bugs.python.org/issue21423 is less general as it does not handle the
case of a finalizer as proposed here.
--
___
Python tracker
&
Antony Lee added the comment:
Travis uses virtualenvs as toplevel containers for running CI. Some projects
need (or would like to) set up venvs as part of their test suites. On example
is https://github.com/airspeed-velocity/asv, which profiles a project's speed
across revisions; in
Antony Lee added the comment:
> venv, on the other hand, doesn't, but keeps a reference to its original
> Python environment. That is, I think, the reason for the difference in
> behaviour.
But for example, using the system Python to create a venv (no nesting),
packages in
Antony Lee added the comment:
I guess it's reasonable, I'll see whether we can use the workaround you
proposed. (Could a fix on virtualenv's side help?)
Thanks for the explanations.
--
___
Python tracker
<https://bugs.pyt
New submission from Antony Lee :
The stdlib docs intro include the following sentences:
It also describes some of the optional components that are commonly
included in Python distributions.
For Unix-like operating systems Python is normally provided as a collection
of packages, so it
New submission from Antony Lee :
I have a ~/.pydistutils.cfg with the following contents:
[build_ext]
force = true
inplace = true
(--force is useful because sometimes just comparing timestamps is insufficient
to know whether a package needs to be rebuilt, e.g. in the presence of
New submission from Antony Lee :
Currently, the docs for Path.relative_to read
PurePath.relative_to(*other)
Compute a version of this path relative to the path represented by other.
If it’s impossible, ValueError is raised: (examples follow)
It's a bit confusing why other is a
New submission from Antony Lee :
A quick check suggests that enum entries can be programmatically created by
assigning to locals() in the Enum body:
class E(Enum): locals()["a"] = 1
E.a # ->
However, using locals().update(...) doesn't, and silently does the wrong
Antony Lee added the comment:
I have a personal helper function for writing (Qt) GUIs that generates
ComboBoxes from Enums; essentially something like
class Choices(Enum):
choice1 = "text for choice 1"
choice2 = "text for choice 2"
def call
Antony Lee added the comment:
> encourage the common assumption that locals() returns a dict where mutating
> it actually works, since it usually doesn't.
It does at global and class scope, not at function scope.
FWIW, PEP558 (admittedly not accepted yet) proposes to
Antony Lee added the comment:
> I agree though that adding an update method would be nice though and can be
> done in just a few lines of code.
Again, this can be done just be inheriting the methods from MutableMapping.
In fact even now one can just write
class
New submission from Antony Lee :
After
$ mkdir -p foo/bar && chmod 000 foo
one gets
In [1]: glob.glob("foo/bar")
Out[1]: []
but
In [2]: list(Path("foo/bar").glob("*"))
gives a PermissionError.
I'm not arguing that pathlib should
Change by Antony Lee :
--
nosy: -Antony.Lee
___
Python tracker
<https://bugs.python.org/issue23596>
___
___
Python-bugs-list mailing list
Unsubscribe:
New submission from Antony Lee :
When checking whether a class implements all abstractmethods (to know whether
the class can be instantiated), one should only consider methods that come
*before* the abstractmethod in the MRO -- methods that come after cannot be
said to override the
Antony Lee added the comment:
There are a number of packages that can "self-import" into any Python process
depending on the presence of an environment variable, by installing a pth file
that contains something like `import os; __import__("thepkg") if
os.environ.get(&q
New submission from Antony Lee :
Currently, dataclasses created by make_dataclass are not picklable, because
their __module__ is set to "types". It seems that this would be easily fixed
by letting make_dataclass gain a `module` and a `qualname` kwarg, similarly to
the Enum funct
New submission from Antony Lee:
The language reference is clear:
"The from form does not bind the module name" (Section 6.12)
However, consider the following example:
* package/__init__.py:
foo = "FOO"
from .foo import bar
print(foo)
os = "OS"
from os import pa
New submission from Antony Lee:
Trying to construct a Path object from a str subclass, e.g.
class S(str): pass
Path(S("foo"))
fails because the subclass cannot be interned. I think that the interning
should simply be removed for non-exactly-str arguments (it is only here for
p
Antony Lee added the comment:
The attached patch should fix the issue.
--
keywords: +patch
Added file: http://bugs.python.org/file34759/pathlib.patch
___
Python tracker
<http://bugs.python.org/issue21
Antony Lee added the comment:
I am loading some structure from a MATLAB binary file using scipy.io.loadmat.
This structure contains (in particular) paths (written as bytestrings) to other
files which end up being loaded as numpy.str_ objects.
In fact, just trying to store and retrieve
New submission from Antony Lee:
Path.with_name can be used to construct paths containing slashes as name
contents (rather than as separators), as demonstrated below.
$ python -c 'from pathlib import Path;
print(Path("foo").with_name("bar/baz").name)'
bar/baz
Th
New submission from Antony Lee:
I noticed that while lzma and bz2 already support the "x" (create a new file,
raise if it already exists) flag, zipfile and tarfile don't know about it yet.
It would be an useful addition, just as it is useful for regular open.
A quick look
Antony Lee added the comment:
I have the patch almost ready, but ran into another issue: should
"path.with_name('foo/')" be allowed? It may make sense to treat it like
"path.with_name('foo')", just like 'Path("foo/") == Path("fo
New submission from Antony Lee:
The following patch corrects the docstring of `inspect.Parameter`, as the
`default` and `annotation` attributes are in fact set to `empty` if no value is
provided, and the `kind` attribute is in fact an `int` (more precisely, a
`_ParameterKind`). It also
New submission from Antony Lee:
The docs for multiprocessing refer to BaseProxy._callMethod() while it should
be _callmethod.
--
assignee: docs@python
components: Documentation
messages: 205261
nosy: Antony.Lee, docs@python
priority: normal
severity: normal
status: open
title: Typo in
New submission from Antony Lee:
Classes defined in the multiprocessing module are in fact functions that call
the internally defined class constructor with the "ctx" argument properly set;
because of that, trying to subclass them yields a (very?) cryptic error message:
New submission from Antony Lee:
multiprocessing.sharedctypes was not updated after the "q" (c_longlong) and "Q"
(c_ulonglong) typecodes were added to the array module (the docs claim that the
typecode can be "one character typecode of the kind used by the array modul
Antony Lee added the comment:
The attached patch fixes all the issues mentioned, and also integrates the
fixes of issue 20639 (issues with with_suffix) as they are quite similar.
--
keywords: +patch
Added file: http://bugs.python.org/file35735/pathlib-with_name-with_suffix.patch
New submission from Antony Lee:
PureWindowsPath("foo*") returns a path object, even though it is an invalid one
(e.g., open("foo*") on Windows throws an OSError for "invalid argument" rather
than a FileNotFoundError). Given the amount of checking that is
Antony Lee added the comment:
There is a list of always forbidden characters
(http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions),
and then a couple of obscure fs-dependent cases
(http://en.wikipedia.org/wiki/Comparison_of_file_systems) but I
New submission from Antony Lee:
With Python 3.4.1:
$ mkdir foo; zip -r foo{,}; python -mzipfile -e foo.zip dest
adding: foo/ (stored 0%)
Traceback (most recent call last):
File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"__main__", mod_sp
Antony Lee added the comment:
The hash function of the Signature class is actually incompatible with the
definition of Signature equality, which doesn't consider the order of
keyword-only arguments:
>>> from inspect import signature
>>> s1 = signature(lambda *, x, y
Antony Lee added the comment:
Actually, that specific solution (using a helper method) will fail because
there may be unhashable params (due to unhashable default values or
annotations) among the keyword-only arguments, so it may not be possible to
build a frozenset (rather, one should
New submission from Antony Lee:
Compare
$ mkdir foo; zip -q foo{,}; unzip -l foo.zip
Archive: foo.zip
Length DateTimeName
- -- -
0 2014-08-17 10:49 foo/
- ---
0 1 file
and
New submission from Antony Lee:
Currently, pathlib contains the following check for the OS in the import
section:
try:
import nt
except ImportError:
nt = None
else:
if sys.getwindowsversion()[:2] >= (6, 0):
from nt import _getfinalpathn
New submission from Antony Lee:
Currently, tempfile.TemporaryFile and tempfile.NamedTemporaryFile are
functions, not classes, despite what their names suggest, preventing
subclassing. It would arguably be not so easy to make TemporaryFile a class,
as its return value is whatever "_io
Antony Lee added the comment:
The initial idea was to solve #14243 (NamedTemporaryFile would be more useful
on Windows if you could close it without deleting) by adding a "closed" keyword
argument to the constructor of a subclass, that would set "delete" to False and
Antony Lee added the comment:
Yes, but this will make the context-manager approach (with
NamedTemporaryFile(closed=True): ) unusable, because the underlying
file object will be closed before calling __enter__. I think the only
reasonable way to implement this would be to have __enter__
Antony Lee added the comment:
While your patch works, I think it is a good opportunity to simplify the
implementation of Signature.__eq__, which is *much* more complicated than what
it should be.
Please comment on the attached patch, which uses the helper method approach I
suggested
Antony Lee added the comment:
This looks reasonable. Note that the output of gettempdir is always passed as
first argument to os.path.join (possibly via _mkstemp_inner), so perhaps you
should rather define something like
def _absolute_child_of_parent_or_tmpdir(parent, *args):
"&qu
Antony Lee added the comment:
I don't feel strongly about this, so either way is fine.
--
___
Python tracker
<http://bugs.python.org/issue20267>
___
___
Pytho
New submission from Antony Lee:
A small lib improvement suggestion could be to make contextlib.redirect_stdout
and contextlib.suppress inherit from ContextDecorator.
As a side note, the source of contextlib has some classes inheriting explicitly
from object while others don't, so perhaps
Antony Lee added the comment:
"it looks like all the avenues for arbitrary code execution while checking if
an exception handler matches a thrown an exception are closed off."
This seems to be directly contradicted by your previous sentence: "the except
clause accepts
Antony Lee added the comment:
The change would be backwards-incompatible but also mimics the behavior of
NamedTemporaryFile (which also fails to delete the file if the containing
folder has been renamed -- this is easy to verify manually).
I guess the other option would be to use fd-based
New submission from Antony Lee:
As suggested on python-ideas, this small patch changes the constructor of
inspect.Parameter so that "kind" defaults to "POSITIONAL_OR_KEYWORD", which
should make code that needs to construct Parameter objects slightly less
v
Antony Lee added the comment:
Nobody replied so far...
https://mail.python.org/pipermail/python-ideas/2013-December/024538.html
--
___
Python tracker
<http://bugs.python.org/issue20
New submission from Antony Lee:
I believe that the implementation of Condition._is_owned is wrong, as mentioned
here: https://mail.python.org/pipermail/python-list/2012-October/632682.html.
Specifically, the two return values (True and False) should be inverted.
I guess this slipped through
New submission from Antony Lee:
Essentially, the following fails:
t = tempfile.TemporaryDirectory(dir=".")
os.chdir(some_other_dir)
t.cleanup()
because t.name is a relative path. Resolving the "dir" argument when the
directory is created should(?) fix the issue.
-
Antony Lee added the comment:
Submitted new patch as suggested.
--
Added file: http://bugs.python.org/file33913/inspect.py.diff
___
Python tracker
<http://bugs.python.org/issue19
Antony Lee added the comment:
Thanks for the fix. The same fix seems should also work for mkstemp and mktemp
-- is it really worth creating a new issue for them?
--
___
Python tracker
<http://bugs.python.org/issue20
Antony Lee added the comment:
For the second half, the same behavior applies under Linux -- basically, a
simple Lock doesn't have a notion of owning thread and can the be unlocked by
any thread.
However, the first half is not correct if the lock used is a *RLock-like*
object (that is, i
New submission from Antony Lee:
I actually thought that Path.with_{name,suffix} had been removed before 3.4
when I didn't find them in the official docs...
--
assignee: docs@python
components: Documentation
messages: 212160
nosy: Antony.Lee, docs@python
priority: normal
sev
New submission from Antony Lee:
The return value of `inspect.signature(memoryview)` is rather strange:
Python 3.5.2 (default, Nov 7 2016, 11:31:36)
[GCC 6.2.1 20160830] on linux
Type "help", "copyright", "credits" or "license" for more informatio
New submission from Antony Lee:
```
Python 3.5.2 (default, Nov 7 2016, 11:31:36)
[GCC 6.2.1 20160830] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class C:
... def f(self): pass
...
>>> C.f.a
New submission from Antony Lee:
The docstring of timeit.Timer.autorange currently reads
| Return the number of loops so that total time >= 0.2.
|
| Calls the timeit method with *number* set to successive powers of
| ten (10, 100, 1000, ...) up t
Changes by Antony Lee :
--
nosy: -Antony.Lee
___
Python tracker
<http://bugs.python.org/issue29661>
___
___
Python-bugs-list mailing list
Unsubscribe:
New submission from Antony Lee:
`Path().with_name` can fail with a lot of different exceptions:
>>> Path("foo").with_name(0)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.5/pathlib.py", line 800, in with
Antony Lee added the comment:
Actually, a simpler approach may be the attached patch
(pathlib-splitroot.patch), in which case the exception is
AttributeError: 'dict' object has no attribute 'lstrip'
which is pretty commonly seen when a wrong type is passed to a functio
Antony Lee added the comment:
Would it? Note that splitroot is not public, and some quick tests did not show
any other behavior difference from the public API side.
--
___
Python tracker
<http://bugs.python.org/issue27
Antony Lee added the comment:
First, I doubt that this optimization actually changes anything measurable, but
if you want you can always replace that line by "if part.startswith(sep)" (also
solving the original issue).
Additionally, note that `parse_parts` (the only functi
New submission from Antony Lee:
Currently, pickling Path objects lead to issues when working across platforms:
Paths (and, thus, objects that contain Paths) created on a POSIX platform
(PosixPaths) cannot be unpickled on Windows and vice versa. There are a few
possibilities around this issue
New submission from Antony Lee:
Currently, `./setup.py --help-commands` displays extra commands in a random
(dict iteration, probably?) order, as can be seen with the following minimal
example:
from distutils.command.build_py import build_py
from distutils.core import setup
class
New submission from Antony Lee:
List subclasses can be weakref'd (as mentioned by the docs), but their methods
cannot be wrapped by WeakMethod, even though this makes sense semantically:
```
In [25]: class L(list): pass
In [26]: weakref.WeakMethod(L().a
New submission from Antony Lee:
The documentation for multiprocessing.connection mentions the answerChallenge
function, but it is actually called answer_challenge in 2.6, 2.7 and 3.3 -- I
guess it's also the case in 3.1 and 3.2 but I didn't check.
--
assignee: docs@python
New submission from Antony Lee:
methodcaller and attrgetter objects seem to be picklable, but in fact the
pickling is erroneous:
>>> import operator, pickle
>>> pickle.loads(pickle.dumps(operator.methodcaller("foo")))
Traceback (most recent call last):
Fi
New submission from Antony Lee:
It would be nice if dbm.open() supported the "x" flag that open() now supports
(create a new db, failing if it already exists).
--
components: Library (Lib)
messages: 231835
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title
New submission from Antony Lee:
Not a big deal, but "$ pydoc enum.Enum" and "$ pydoc enum.IntEnum" fail to
retrieve the docstrings, while they are visible with "$ pydoc enum".
--
components: Library (Lib)
messages: 232298
nosy: Antony.Lee
priority: normal
New submission from Antony Lee:
glob.glob returns an empty list when passed an empty pattern as argument, but
pathlib's Path.glob fails with IndexError. The first option seems more
reasonable (or at least it should be a ValueError).
--
components: Library (Lib)
messages: 232841
New submission from Antony Lee:
This patch makes BoundArguments.arguments an unordered dict. As discussed on
python-ideas, the rationale for this is
1. The current ordering in ba.arguments is the one of the parameters in the
signature (which is already available via the ba.signature
New submission from Antony Lee:
The man page doesn't mention PYTHONFAULTHANDER in the list of environment
variables (I haven't thoroughly checked that everyone else is there, either).
I would also suggest reordering the environment variables in alphabetical order.
--
assi
New submission from Antony Lee:
Support for python -m [-h|--help] is a bit patchy right
now:
$ python -mpdb -h
usage: pdb.py [-c command] ... pyfile [arg] ...
$ python -mpdb --help
Traceback (most recent call last):
File "/usr/lib/python3.4/runpy.py", line 170, in _run_modu
New submission from Antony Lee:
Currently the argparse docs mention the special values "+", "*" and "?" by
their actual values instead of argparse.{ONE_OR_MORE,ZERO_OR_MORE,OPTIONAL},
but argparse.REMAINDER is mentioned as is. It seems easier to just use its
ac
New submission from Antony Lee:
While working on #24644, I noticed that the help for python -mtrace is quite
wrong.
$ python -mtrace --help
Usage: /usr/lib/python3.4/trace.py [OPTIONS] [ARGS]
Meta-options:
--helpDisplay this help then exit.
--version Output
Antony Lee added the comment:
To be honest I don't really plan to contribute any patch on this specific issue
right now, the CLI interface of e.g. trace has some other serious issues (see
e.g. #24649) that I don't want to work out, and writing tests for the CLI are a
pain too (
New submission from Antony Lee:
Currently, distutils.Command is a "hand-written" ABC; i.e. direct instantiaion
or calling the "abstract" methods initialize_options, run and finalize_options
raises a RuntimeError saying that the method (not named in the error message,
wh
New submission from Antony Lee:
I would like to suggest allowing passing "delete=False" to the
TemporaryDirectory constructor, with the effect that the directory is not
deleted when the TemporaryDirectory context manager exits, or when the
TemporaryDirectory object is deleted.
I re
New submission from Antony Lee:
http://bugs.python.org/issue21423 and http://bugs.python.org/issue24980 suggest
adding an initializer/on_new_thread argument to {Thread,Process}PoolExecutor.
I would like to suggest a more unified API, that would allow not only handling
initialization, but
New submission from Antony Lee:
The docs of pkgutil.get_data say "The resource argument should be in the form
of a relative filename, using / as the path separator. The parent directory
name .. is not allowed, and nor is a rooted name (starting with a /)."
In fact (on Python 3.
New submission from Antony Lee:
The output of pydoc for Path.samefile currently reads
pathlib.Path.samefile = samefile(self, other_path)
Return whether `other_file` is the same or not as this file.
(as returned by os.path.samefile(file, other_file)).
It should arguably be something
Antony Lee added the comment:
Actually there's also an extra dot at the end of the first line of the
docstring (redundant with the one on the second line).
--
___
Python tracker
<http://bugs.python.org/is
New submission from Antony Lee:
Initially suggested in #25330: it would be helpful to provide text mode support
(returning unicode, and handling universal newlines) for pkgutil.get_data
(either as a keyword argument, or as a separate function).
--
components: Library (Lib)
messages
New submission from Antony Lee:
$ echo 'from numpy import repeat\nrepeat(2, 3)' | 2to3 -
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer
New submission from Antony Lee:
The additional unpack generalizations provided by Python3.5 rely on a new set
of opcodes, BUILD_{TUPLE,LIST,DICT,SET}_UNPACK, that are not documented in the
docs for the dis module.
--
assignee: docs@python
components: Documentation
messages: 254715
New submission from Antony Lee:
There are a couple of places in the docs where it would be appropriate to
replace __name__ by __spec__.__name__ in order to support the case where the
module is executed as the __main__ module:
- logging.getLogger should certainly use __spec__.__name__ so that
New submission from Antony Lee:
Consider the following minimal example:
class readonlyprop:
__init__ = lambda self, func: None
__get__ = lambda self, inst, cls=None: None
class C:
def bar(self):
pass
@readonlyprop
def foo(self
New submission from Antony Lee:
For a class whose __init__ has no docstring, e.g.
class C:
def __init__(self, arg):
pass
pydoc outputs
<... cropped ...>
class C(builtins.object)
| Methods defined here:
|
| __init__(sel
101 - 200 of 219 matches
Mail list logo