[issue15598] relative import unexpectedly binds name

2012-08-08 Thread Antony Lee
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

[issue17635] Doc of multiprocessing.connection mentions answerChallenge instead of answer_challenge

2013-04-04 Thread Antony Lee
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

[issue19573] Fix the docstring of inspect.Parameter and the implementation of _ParameterKind

2013-11-13 Thread Antony Lee
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

[issue19890] Typo in multiprocessing docs

2013-12-04 Thread Antony Lee
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

[issue19895] Cryptic error when subclassing multiprocessing classes

2013-12-05 Thread Antony Lee
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

[issue19896] Exposing q and Q to multiprocessing.sharedctypes

2013-12-05 Thread Antony Lee
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

[issue20011] Changing the signature for Parameter's constructor

2013-12-17 Thread Antony Lee
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

[issue20011] Changing the signature for Parameter's constructor

2013-12-18 Thread Antony Lee
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

[issue20247] Condition._is_owned is wrong

2014-01-13 Thread Antony Lee
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

[issue20267] TemporaryDirectory does not resolve path when created using a relative path

2014-01-14 Thread Antony Lee
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

[issue19573] Fix the docstring of inspect.Parameter and the implementation of _ParameterKind

2014-02-04 Thread Antony Lee
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

[issue20267] TemporaryDirectory does not resolve path when created using a relative path

2014-02-07 Thread Antony Lee
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

[issue20247] Condition._is_owned is wrong

2014-02-07 Thread Antony Lee
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

[issue20765] Pathlib docs fail to mention with_name, with_suffix

2014-02-24 Thread Antony Lee
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

[issue21127] Path objects cannot be constructed from str subclasses

2014-04-01 Thread Antony Lee
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

[issue21127] Path objects cannot be constructed from str subclasses

2014-04-08 Thread Antony Lee
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

[issue21127] Path objects cannot be constructed from str subclasses

2014-04-11 Thread Antony Lee
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

[issue21714] Path.with_name can construct invalid paths

2014-06-10 Thread Antony Lee
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

[issue21717] Exclusive mode for ZipFile and TarFile

2014-06-11 Thread Antony Lee
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

[issue21714] Path.with_name can construct invalid paths

2014-06-11 Thread Antony Lee
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

[issue21714] Path.with_name can construct invalid paths

2014-06-22 Thread Antony Lee
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

[issue21969] WindowsPath constructor does not check for invalid characters

2014-07-12 Thread Antony Lee
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

[issue21969] WindowsPath constructor does not check for invalid characters

2014-07-12 Thread Antony Lee
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

[issue22201] python -mzipfile fails to unzip files with folders created by zip

2014-08-14 Thread Antony Lee
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

[issue20334] make inspect Signature hashable

2014-08-15 Thread Antony Lee
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

[issue20334] make inspect Signature hashable

2014-08-15 Thread Antony Lee
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

[issue22219] python -mzipfile fails to add empty folders to created zip

2014-08-17 Thread Antony Lee
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

[issue22370] pathlib OS detection

2014-09-09 Thread Antony Lee
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

[issue22387] Making tempfile.NamedTemporaryFile a class

2014-09-11 Thread Antony Lee
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

[issue22387] Making tempfile.NamedTemporaryFile a class

2014-09-11 Thread Antony Lee
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

[issue22387] Making tempfile.NamedTemporaryFile a class

2014-09-11 Thread Antony Lee
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

[issue20334] make inspect Signature hashable

2014-09-12 Thread Antony Lee
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

[issue20267] TemporaryDirectory does not resolve path when created using a relative path

2014-09-26 Thread Antony Lee
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

[issue20267] TemporaryDirectory does not resolve path when created using a relative path

2014-09-26 Thread Antony Lee
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

[issue22531] Turn contextlib.{redirect_stdout, suppress} into ContextDecorators

2014-10-01 Thread Antony Lee
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

[issue12029] Catching virtual subclasses in except clauses

2014-10-01 Thread Antony Lee
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

[issue20267] TemporaryDirectory does not resolve path when created using a relative path

2014-10-04 Thread Antony Lee
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

[issue22955] Pickling of methodcaller and attrgetter

2014-11-26 Thread Antony Lee
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

[issue22964] dbm.open(..., x)

2014-11-28 Thread Antony Lee
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

[issue23008] pydoc enum.{,Int}Enum fails

2014-12-07 Thread Antony Lee
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

[issue23076] path.glob() fails with IndexError

2014-12-17 Thread Antony Lee
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

[issue23080] BoundArguments.arguments should be unordered

2014-12-18 Thread Antony Lee
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

[issue23596] gzip argparse interface

2015-03-05 Thread Antony Lee
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

[issue24111] Valgrind suppression file should be updated

2015-05-02 Thread Antony Lee
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

[issue23991] ZipFile sanity checks

2015-04-17 Thread Antony Lee
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

[issue23871] turning itertools.{repeat, count} into indexable iterables

2015-04-04 Thread Antony Lee
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

[issue24253] pydoc for namespace packages indicates FILE as built-in

2015-05-20 Thread Antony Lee
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

[issue24459] Mention PYTHONFAULTHANDLER in the man page

2015-06-16 Thread Antony Lee
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

[issue24644] --help for runnable stdlib modules

2015-07-16 Thread Antony Lee
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

[issue24647] Document argparse.REMAINDER as being equal to ...

2015-07-16 Thread Antony Lee
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

[issue24644] --help for runnable stdlib modules

2015-07-16 Thread Antony Lee
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

[issue24649] python -mtrace --help is wrong

2015-07-16 Thread Antony Lee
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

[issue25417] Minor typo in Path.samefile docstring

2015-10-21 Thread Antony Lee
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

[issue25477] text mode for pkgutil.get_data

2015-10-25 Thread Antony Lee
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

[issue25632] Document BUILD_*_UNPACK opcodes

2015-11-15 Thread Antony Lee
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

[issue25527] Invalid (... and confusing) warning raised by 2to3 regarding repeat

2015-11-01 Thread Antony Lee
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

[issue25417] Minor typo in Path.samefile docstring

2015-10-15 Thread Antony Lee
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

[issue25330] Two issues with pkgutil.get_data

2015-10-06 Thread Antony Lee
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.

[issue24970] Make distutils.Command an ABC

2015-08-31 Thread Antony Lee
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

[issue25024] Allow passing "delete=False" to TemporaryDirectory

2015-09-07 Thread Antony Lee
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.

[issue25293] Hooking Thread/Process instantiation in concurrent.futures.

2015-10-01 Thread Antony Lee
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

[issue26072] pdb fails to access variables closed over

2016-01-09 Thread Antony Lee
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 ##

[issue26051] Non-data descriptors in pydoc

2016-01-08 Thread Antony Lee
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

[issue26052] pydoc for __init__ with not docstring

2016-01-08 Thread Antony Lee
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

[issue25912] Use __spec__.__name__ instead of __name__ in the docs where appropriate

2015-12-19 Thread Antony Lee
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

[issue27320] ./setup.py --help-commands should sort extra commands

2016-06-14 Thread Antony Lee
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

[issue27161] Confusing exception in Path().with_name

2016-05-30 Thread Antony Lee
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

[issue27161] Confusing exception in Path().with_name

2016-05-31 Thread Antony Lee
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

[issue27161] Confusing exception in Path().with_name

2016-05-31 Thread Antony Lee
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

[issue27161] Confusing exception in Path().with_name

2016-05-31 Thread Antony Lee
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

[issue27175] Unpickling Path objects

2016-06-01 Thread Antony Lee
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

[issue26127] Broken link in docs for tokenize

2016-01-15 Thread Antony Lee
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

[issue26120] pydoc: move __future__ imports out of the DATA block

2016-01-14 Thread Antony Lee
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

[issue26240] Docstring of the subprocess module should be cleaned up

2016-01-29 Thread Antony Lee
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

[issue26453] SystemError on invalid numpy.ndarray / Path operation

2016-02-27 Thread Antony Lee
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

[issue26535] Minor typo in the docs for struct.unpack

2016-03-10 Thread Antony Lee
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

[issue26535] Minor typo in the docs for struct.unpack

2016-03-10 Thread Antony Lee
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

[issue20012] Re: Allow Path.relative_to() to accept non-ancestor paths

2016-03-23 Thread Antony Lee
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

[issue26792] docstrings of runpy.run_{module,path} are rather sparse

2016-04-17 Thread Antony Lee
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

[issue29661] Typo in the docstring of timeit.Timer.autorange

2017-02-26 Thread Antony Lee
Changes by Antony Lee <anntzer@gmail.com>: -- nosy: -Antony.Lee ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29661> ___ _

[issue29661] Typo in the docstring of timeit.Timer.autorange

2017-02-26 Thread Antony Lee
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, ...)

[issue27865] WeakMethod does not support builtin methods

2016-08-25 Thread Antony Lee
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

[issue26240] Docstring of the subprocess module should be cleaned up

2016-10-17 Thread Antony Lee
Changes by Antony Lee <anntzer@gmail.com>: -- nosy: -Antony.Lee ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26240> ___ _

[issue26072] pdb fails to access variables closed over

2016-11-15 Thread Antony Lee
Changes by Antony Lee <anntzer@gmail.com>: -- nosy: -Antony.Lee ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26072> ___ _

[issue24459] Mention PYTHONFAULTHANDLER in the man page

2016-11-13 Thread Antony Lee
Changes by Antony Lee <anntzer@gmail.com>: -- nosy: -Antony.Lee ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24459> ___ _

[issue24459] Mention PYTHONFAULTHANDLER in the man page

2016-11-19 Thread Antony Lee
Changes by Antony Lee <anntzer@gmail.com>: -- nosy: -Antony.Lee ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24459> ___ _

[issue24459] Mention PYTHONFAULTHANDLER in the man page

2016-11-19 Thread Antony Lee
Antony Lee added the comment: PYTHONUSERBASE is also missing. -- nosy: +Antony.Lee ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue29117] dir() should include dunder attributes of the unbound method

2016-12-30 Thread Antony Lee
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

[issue29111] Strange signature for memoryview constructor

2016-12-29 Thread Antony Lee
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

[issue19896] Exposing "q" and "Q" to multiprocessing.sharedctypes

2017-07-14 Thread Antony Lee
Changes by Antony Lee <anntzer@gmail.com>: -- nosy: -Antony.Lee ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19896> ___ _

[issue21423] concurrent.futures.ThreadPoolExecutor/ProcessPoolExecutor should accept an initializer argument

2017-07-26 Thread Antony Lee
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

[issue31006] typing.NamedTuple should add annotations to its constructor (__new__) parameters.

2017-07-24 Thread Antony Lee
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

[issue30811] A venv created and activated from within a virtualenv uses the outer virtualenv's site-packages rather than its own.

2017-06-30 Thread Antony Lee
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

[issue30811] A venv created and activated from within a virtualenv uses the outer virtualenv's site-packages rather than its own.

2017-06-30 Thread Antony Lee
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

[issue31006] typing.NamedTuple should add annotations to its constructor (__new__) parameters.

2017-07-28 Thread Antony Lee
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

[issue31542] pth files in site-packages of venvs are executed twice

2017-09-21 Thread Antony Lee
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

[issue31254] WeakKeyDictionary/Mapping doesn't call __missing__

2017-08-24 Thread Antony Lee
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

[issue31254] WeakKeyDictionary/Mapping doesn't call __missing__

2017-08-22 Thread Antony Lee
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

[issue31295] typo in __hash__ docs

2017-08-28 Thread Antony Lee
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

[issue31254] WeakKeyDictionary/Mapping doesn't call __missing__

2017-08-24 Thread Antony Lee
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   2   >