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 path
print(os)
* package/foo.py:
foo
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
components
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
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:
import multiprocessing
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 module).
The attached patch (just
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
verbose (as I believe
Antony Lee added the comment:
Nobody replied so far...
https://mail.python.org/pipermail/python-ideas/2013-December/024538.html
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20011
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.
--
components: Library
Antony Lee added the comment:
Submitted new patch as suggested.
--
Added file: http://bugs.python.org/file33913/inspect.py.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19573
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 rep...@bugs.python.org
http://bugs.python.org/issue20267
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, it has
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
severity
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
performance
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 rep...@bugs.python.org
http://bugs.python.org/issue21127
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
This should be changed to either
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 at both modules show
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(foo)'.
The implementation is also simpler with it, as it can reuse
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 done in (e.g.)
with_name and with_suffix
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_spec)
File /usr/lib/python3.4
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: None); s2 = signature(lambda
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
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 _getfinalpathname
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.open
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
then close it, e.g.
class
Antony Lee added the comment:
Yes, but this will make the context-manager approach (with
NamedTemporaryFile(closed=True): do stuff) 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
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):
Return
Antony Lee added the comment:
I don't feel strongly about this, so either way is fine.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20267
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 any expressions producing
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:
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):
File stdin, line 1, in module
TypeError
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: dbm.open
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
severity: normal
status: open
title
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
nosy
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 attached patch reimplements gzip's already existing command-line interface
using argparse, both to provide command-line help and to avoid manual argument
parsing.
--
components: Library (Lib)
files: gzip-argparse-cli.patch
keywords: patch
messages
New submission from Antony Lee:
Since PEP445, the suppressions should target _PyObject_{Free,Realloc} instead
of PyObject_{Free,Realloc}.
--
messages: 242382
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: Valgrind suppression file should be updated
versions
New submission from Antony Lee:
ZipFile.{open,read} could raise IsADirectoryError when called on a directory
entry, rather than return an empty bytes.
ZipFile.writestr could fail writing non-empty bytes to a directory entry.
Use case for open and read: I was trying to write a zip merger
New submission from Antony Lee:
itertools.repeat and itertools.count could be made into indexable iterables
(rather than iterators), rather than iterators, like range is right now.
--
components: Library (Lib)
messages: 240096
nosy: Antony.Lee
priority: normal
severity: normal
status
New submission from Antony Lee:
All's in the title: the output of pydoc foo where foo is a namespace package
(... e.g. any directory in the cwd) says that the package is defined as a
builtin (under the FILE entry) -- which is certainly incorrect.
--
components: Library (Lib)
messages
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.
--
assignee: docs
New submission from Antony Lee:
Support for python -mrunnable-stdlib-module [-h|--help] is a bit patchy right
now:
$ python -mpdb -h
usage: pdb.py [-c command] ... pyfile [arg] ...
help elided
$ python -mpdb --help
Traceback (most recent call last):
File /usr/lib/python3.4/runpy.py, line
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
actual value (...) in the docs as well
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 (also why I
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] file [ARGS]
Meta-options:
--helpDisplay this help then exit.
--version Output
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 <rep...@bugs.python.org>
<http://bugs.python.org/i
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:
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:
$ 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: ws_comma
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
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:
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.
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
New submission from Antony Lee:
Consider the following example:
def f(x=1):
def g():
y = 2
raise Exception
g()
f()
$ python -mpdb -ccontinue example.py
<... traceback ...>
> /tmp/example.py(4)g()
-> raise Exception
(Pdb) p x
##
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
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
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:
`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 function.
(Note
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 <rep...@bugs.python.org>
<http://bugs.python.org/i
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:
The docs for `tokenize.detect_encoding` state `Use open() to open Python source
files: it uses detect_encoding() to detect the file encoding.`
Unfortunately, clicking on `open` redirects to the builtin `open` function, not
to `tokenize.open` as it should
New submission from Antony Lee:
Currently, for a module that uses __future__ imports, the DATA section of
`pydoc foo` contains these imports interspersed with the "real" data from the
module.
Even though it is fully-featured _Feature objects that are imported, it
probably makes sen
New submission from Antony Lee:
subprocess.__doc__ currently contains copies for the docstrings of a bunch of
functions in the module (... but not subprocess.run). The docs for the Popen
class should be moved into that class' docstring. The module's docstring also
mentions the list2cmdline
New submission from Antony Lee:
Running
```
from pathlib import Path
import numpy as np
np.arange(30) / Path("foo")
```
raises
```
TypeError: argument should be a path or str object, not
During handling of the above exception, another exception occurred:
SystemError:
returne
Antony Lee added the comment:
I think mentioning calcsize is still helpful, so perhaps something like
"The buffer must contain exactly as many bytes (I think this is clearer than
"the amount of data") as required by the format (this number can be obtained as
`stru
New submission from Antony Lee:
The docstring of struct.unpack currently reads
Unpack from the buffer buffer (presumably packed by pack(fmt, ...)) according
to the format string fmt. The result is a tuple even if it contains exactly one
item. The buffer must contain exactly the amount of data
Antony Lee added the comment:
Kindly bumping the issue.
I'd suggest overriding `PurePath.relative_to` in the `Path` class, to something
like `PurePath.relative_to(self, other, *, allow_ancestor=False): ...`, which
would resolve each ancestor of `self` successively to check whether it is also
New submission from Antony Lee:
$ pydoc runpy
run_module(mod_name, init_globals=None, run_name=None, alter_sys=False)
Execute a module's code without importing it
Returns the resulting top level namespace dictionary
run_path(path_name, init_globals=None
Changes by Antony Lee <anntzer@gmail.com>:
--
nosy: -Antony.Lee
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29661>
___
_
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, ...)
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().append
Changes by Antony Lee <anntzer@gmail.com>:
--
nosy: -Antony.Lee
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26240>
___
_
Changes by Antony Lee <anntzer@gmail.com>:
--
nosy: -Antony.Lee
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26072>
___
_
Changes by Antony Lee <anntzer@gmail.com>:
--
nosy: -Antony.Lee
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24459>
___
_
Changes by Antony Lee <anntzer@gmail.com>:
--
nosy: -Antony.Lee
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24459>
___
_
Antony Lee added the comment:
PYTHONUSERBASE is also missing.
--
nosy: +Antony.Lee
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
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 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
Changes by Antony Lee <anntzer@gmail.com>:
--
nosy: -Antony.Lee
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19896>
___
_
Antony Lee added the comment:
For cross-referencing purposes: I have proposed in
http://bugs.python.org/issue25293 to allow passing a Thread/Process subclass as
argument instead of an initializer function, which would both handle Mark
Dickinson's comment (http://bugs.python.org/issue21423
New submission from Antony Lee:
Currently, the fields, types and defaults used to define a typing.NamedTuple
need to be retrieved from three different attributes: `_fields`,
`_field_types`, and `_field_defaults` (the first two are combined in
`__annotations__`, but that still misses
New submission from Antony Lee:
Python 3.6.1, virtualenv 15.1.0 (Arch Linux, distro packages)
```
export PIP_CONFIG_FILE=/dev/null # just to be sure
# python -mvirtualenv outer-env # using /usr/bin/python(3)
python2 -mvirtualenv outer-env # using /usr/bin/python(3)
source outer-env/bin
Antony Lee added the comment:
Sorry, that was a sloppy report. This is a better repro:
$ export PIP_CONFIG_FILE=/dev/null # just to be sure
python -mvirtualenv outer-env # using /usr/bin/python(3)
source outer-env/bin/activate
python -mvenv inner-env # using outer-env's python
source inner
Antony Lee added the comment:
I'll just repost the issue there for now
(https://github.com/python/typing/issues/454). May work on a patch at some
point (looks relatively simple) but no guarantees, so if someone else wants to
take over feel free to do so
New submission from Antony Lee:
All's in the title: "pth files in site-packages of venvs are executed twice".
For example, the following code sample prints "1" twice.
python -mvenv /tmp/tmpenv
echo 'import os; print(1)' >/tmp/tmpenv/lib/python3.6/site-packages/foo.p
Antony Lee added the comment:
The use case is to generate a mapping of weakly-held objects to unique ids,
with something like
id_map = WeakKeyDictionaryWithMissing(lambda *, _counter=itertools.count():
next(_counter))
Of course, as always when using defaultdict, it is easy enough to instead
New submission from Antony Lee:
The following example, which raises a KeyError, shows that in a
WeakKeyDictionary subclass that defines __missing__, that method doesn't get
called.
from weakref import WeakKeyDictionary
class WeakKeyDictionaryWithMissing(WeakKeyDictionary
New submission from Antony Lee:
In https://docs.python.org/3.7/reference/datamodel.html#object.__hash__ I think
x.__hash__() returns an appropriate value such that x == y implies both that x
is y and hash(x) == hash(y).
should be
x.__hash__() returns an appropriate value such that x == y
Antony Lee added the comment:
The original example did not cover the use case and was only there to show the
current behavior. The real use case is more something like
obj = (get obj as argument to function, caller has a hard reference to it)
uid = d[obj
1 - 100 of 219 matches
Mail list logo