[issue30064] BaseSelectorEventLoop.sock_{recv, sendall}() don't remove their callbacks when canceled

2017-04-13 Thread Evgeny Kapun
New submission from Evgeny Kapun: Code: import asyncio as a import socket as s @a.coroutine def coro(): s1, s2 = s.socketpair() s1.setblocking(False) s2.setblocking(False) try: yield from a.wait_for(loop.sock_recv(s2, 1), 1

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-12 Thread Evgeny Kapun
Evgeny Kapun added the comment: The problem is that the task doesn't catch CancelledError, yet it disappears. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-11 Thread Evgeny Kapun
New submission from Evgeny Kapun: If I run this code: import asyncio as a @a.coroutine def coro1(): yield from a.ensure_future(coro2()) print("Still here") yield from a.sleep(1) print("Still here 2") @a.coroutine def co

[issue28445] Wrong documentation for GzipFile.peek

2016-10-14 Thread Evgeny Kapun
New submission from Evgeny Kapun: >From the documentation for GzipFile.peek(): At most one single read on the compressed stream is done to satisfy the call. If "compressed stream" means the underlying file object, then this is not true. The method tries to return at l

[issue13322] buffered read() and write() does not raise BlockingIOError

2016-10-14 Thread Evgeny Kapun
Changes by Evgeny Kapun <abacabadabac...@gmail.com>: -- nosy: +abacabadabacaba ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue15994] memoryview to freed memory can cause segfault

2016-10-13 Thread Evgeny Kapun
Changes by Evgeny Kapun <abacabadabac...@gmail.com>: -- nosy: +abacabadabacaba ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue28436] GzipFile doesn't properly handle short reads and writes on the underlying stream

2016-10-13 Thread Evgeny Kapun
New submission from Evgeny Kapun: GzipFile's underlying stream can be a raw stream (such as FileIO), and such streams can return short reads and writes at any time (e.g. due to signals). The correct behavior in case of short read or write is to retry the call to read or write the remaining

[issue27085] Make it possible to select return type for os.listdir

2016-05-23 Thread Evgeny Kapun
Evgeny Kapun added the comment: Unfortunately, on Linux, handling names as Unicode can cause some problems. For example, merely print()-ing such a name can cause UnicodeEncodeError. -- ___ Python tracker <rep...@bugs.python.org>

[issue27085] Make it possible to select return type for os.listdir

2016-05-23 Thread Evgeny Kapun
Evgeny Kapun added the comment: Unfortunately, this doesn't work if I pass a file descriptor. -- resolution: rejected -> status: closed -> open ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue27084] Add dir_fd and follow_symlinks kwargs to os.listdir and os.scandir

2016-05-22 Thread Evgeny Kapun
Evgeny Kapun added the comment: Mostly for consistency with other functions. Also, this provides an easy way to walk a directory tree recursively: just call listdir on every member, and if it doesn't raise OSError, that member must be a directory. With follow_symlinks=False, this method

[issue27086] Add closefd argument to os.listdir

2016-05-22 Thread Evgeny Kapun
Evgeny Kapun added the comment: Not a problem, just two unnecessary syscalls. Also, I think that many of those who pass a file descriptor to os.listdir don't need it afterwards, because after you fstat() a file descriptor (to discover that it points to a directory) and read the directory

[issue27084] Add dir_fd and follow_symlinks kwargs to os.listdir and os.scandir

2016-05-22 Thread Evgeny Kapun
Evgeny Kapun added the comment: 1. Yes, it's possible to emulate dir_fd this way, so this is just for convenience. 2. If follow_symlinks is False, O_NOFOLLOW is passed to the underlying open(2) syscall. Of course, this doesn't make sense if a file descriptor is passed already

[issue27086] Add closefd argument to os.listdir

2016-05-22 Thread Evgeny Kapun
New submission from Evgeny Kapun: Currently, when given a file descriptor, os.listdir will duplicate it so that the original file descriptor is not closed. In many cases, a file descriptor is not needed anymore after directory is listed, so this is not necessary. I propose adding a keyword

[issue27085] Make it possible to select return type for os.listdir

2016-05-22 Thread Evgeny Kapun
New submission from Evgeny Kapun: Currently, os.listdir returns a list of strings, unless called with a bytes argument, in which case a list of byte strings is returned. I think that there should be a keyword argument to override this selection. -- components: Library (Lib) messages

[issue25996] Add support of file descriptor in os.scandir()

2016-05-22 Thread Evgeny Kapun
Changes by Evgeny Kapun <abacabadabac...@gmail.com>: -- nosy: +abacabadabacaba ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue27084] Add dir_fd and follow_symlinks kwargs to os.listdir and os.scandir

2016-05-22 Thread Evgeny Kapun
New submission from Evgeny Kapun: Many functions in os module support dir_fd and follow_symlinks keyword arguments. I think that os.listdir and os.scandir should do likewise. See also: issue25996. -- components: Library (Lib) messages: 266091 nosy: abacabadabacaba priority: normal

[issue26254] ssl should raise an exception when trying to load an unusable key (ECC key not using a named curve)

2016-02-01 Thread Evgeny Kapun
Evgeny Kapun added the comment: So, it looks like OpenSSL doesn't support keys using arbitrary curves at all. Then why don't I get an exception when trying to load such a key? Instead it just quietly disables all authenticated ciphersuites (anonymous ciphersuites still work) and then I get

[issue26254] ssl server doesn't work with ECC certificates

2016-01-31 Thread Evgeny Kapun
New submission from Evgeny Kapun: I tried to use ssl module to create a server with a certificate that uses an ECC key. However, this didn't work. Here is how to reproduce this: First, generate a key and a certificate: $ openssl req -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -x509

[issue2142] difflib.unified_diff(...) produces invalid patches

2015-11-04 Thread Evgeny Kapun
Changes by Evgeny Kapun <abacabadabac...@gmail.com>: -- nosy: +abacabadabacaba ___ Python tracker <rep...@bugs.python.org> <http://bugs.pytho

[issue18531] Undocumented different between METH_KEYWORDS and **kws

2015-10-30 Thread Evgeny Kapun
Changes by Evgeny Kapun <abacabadabac...@gmail.com>: -- nosy: +abacabadabacaba ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue25454] operator.methodcaller should accept additional arguments during the call

2015-10-25 Thread Evgeny Kapun
Evgeny Kapun added the comment: There are methods that accept a single argument and behave like a binary operation or a predicate. It would be useful to be able to turn them into binary functions for use with higher-order functions like map and reduce: reduce(methodcaller("combine&qu

[issue25454] operator.methodcaller should accept additional arguments during the call

2015-10-21 Thread Evgeny Kapun
New submission from Evgeny Kapun: Currently, operator.methodcaller behaves like this: def methodcaller(name, *args, **kwargs): def caller(obj): return getattr(obj, name)(*args, **kwargs) return caller That is, it is possible to supply arguments when the object

[issue25455] Some repr implementations don't check for self-referential structures

2015-10-21 Thread Evgeny Kapun
New submission from Evgeny Kapun: Implementations of repr for some of the types in the standard library doesn't check for self-referential structures. As a result, when calling repr() on such objects, Python crashes due to infinite recursion. Example: >>> import functo

[issue24129] Incorrect (misleading) statement in the execution model documentation

2015-06-22 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24129 ___ ___ Python

[issue24260] TabError behavior doesn't match documentation

2015-05-24 Thread Evgeny Kapun
Evgeny Kapun added the comment: Prohibiting tabs after spaces is not enough. For example, Python rejects this code: if 1: spaceif 1: tabpass because its indentation is invalid if tab width is 1. However, it accepts this code: if 1: tabif 1: 10 spacespass despite its

[issue24260] TabError behavior doesn't match documentation

2015-05-21 Thread Evgeny Kapun
New submission from Evgeny Kapun: In the documentation, it is said: Indentation is rejected as inconsistent if a source file mixes tabs and spaces in a way that makes the meaning dependent on the worth of a tab in spaces; a TabError is raised in that case. But that's not true

[issue24261] Add a command line flag to suppress default signal handlers

2015-05-21 Thread Evgeny Kapun
New submission from Evgeny Kapun: Currently, Python always changes handling of certain signals on startup: SIGPIPE is ignored, and SIGINT is handled by a function that raises KeyboardInterrupt exception. As a result, if the user presses Ctrl-C, a backtrace is printed to stderr. Some program

[issue14228] Don't display traceback when import site is interrupted by CTRL+c

2015-05-21 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python

[issue22672] float arguments in scientific notation not supported by argparse

2015-03-28 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22672 ___ ___ Python

[issue23689] Memory leak in Modules/sre_lib.h

2015-03-18 Thread Evgeny Kapun
Evgeny Kapun added the comment: This patch doesn't fix the issue. The problem is that the list starting with state-repeat doesn't necessarily contains all repeat contexts that are allocated. Indeed, here [1] and here [2] repeat contexts are temporarily removed from the list. If the match

[issue2636] Adding a new regex module (compatible with re)

2015-03-18 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2636 ___ ___ Python

[issue23689] Memory leak in Modules/sre_lib.h

2015-03-17 Thread Evgeny Kapun
Evgeny Kapun added the comment: Memory leak only happens if match operation terminates abruptly, e.g. because of SIGINT. In this case, DO_JUMP doesn't come back. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23689

[issue23689] Memory leak in Modules/sre_lib.h

2015-03-17 Thread Evgeny Kapun
Evgeny Kapun added the comment: Tracemalloc code: import re import signal import tracemalloc class AlarmError(Exception): pass def handle_alarm(signal, frame): raise AlarmError signal.signal(signal.SIGALRM, handle_alarm) s1

[issue23691] re.finditer iterator is not reentrant, but doesn't protect against nested calls to __next__

2015-03-17 Thread Evgeny Kapun
New submission from Evgeny Kapun: Iterator returned by re.finditer includes a SRE_STATE value, which is not designed to be used concurrently. However, it is possible to call __next__ on such iterator while another such call is in progress, e.g. from a signal handler. This may result

[issue9134] sre bug: lastmark_save/restore

2015-03-17 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9134 ___ ___ Python

[issue23690] re functions never release GIL

2015-03-17 Thread Evgeny Kapun
Evgeny Kapun added the comment: Aren't Python strings immutable? Also, match functions still permit execution of signal handlers, which can execute any Python code. If GIL is needed during matching, can it be released temporarily to permit thread switching

[issue433030] SRE: Atomic Grouping (?...) is not supported

2015-03-17 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue433030 ___ ___ Python

[issue23692] Undocumented feature prevents re module from finding certain matches

2015-03-17 Thread Evgeny Kapun
New submission from Evgeny Kapun: This pattern matches: re.match('(?:()|(?(1)()|z)){2}(?(2)a|z)', 'a') But this doesn't: re.match('(?:()|(?(1)()|z)){0,2}(?(2)a|z)', 'a') The difference is that {2} is replaced by {0,2}. This shouldn't prevent the pattern from matching anywhere where

[issue23689] Memory leak in Modules/sre_lib.h

2015-03-17 Thread Evgeny Kapun
New submission from Evgeny Kapun: In Modules/sre_lib.h on line 882 [1], a block of memory is allocated. If SRE(match) function later terminates abruptly, either because of a signal or because subsequent memory allocation fails, this block is never released. [1] https://hg.python.org/cpython

[issue23690] re functions never release GIL

2015-03-17 Thread Evgeny Kapun
New submission from Evgeny Kapun: Looks like function in re module (match, fullmatch and so on) don't release GIL, even though these operations can take much time. As a result, other threads can't run while a pattern is being matched, and thread switching doesn't happen as well

[issue22609] Constructors of some mapping classes don't accept `self` keyword argument

2014-10-11 Thread Evgeny Kapun
New submission from Evgeny Kapun: import collections collections.Counter(self=1) Traceback (most recent call last): File stdin, line 1, in module TypeError: __init__() got multiple values for argument 'self' collections.OrderedDict(self=test) Traceback (most recent call last): File stdin

[issue22524] PEP 471 implementation: os.scandir() directory scanning function

2014-09-30 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22524 ___ ___ Python

[issue7434] general pprint rewrite

2013-11-17 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7434 ___ ___ Python

[issue19005] PyIter_Next crashes if passed a non-iterator

2013-09-11 Thread Evgeny Kapun
New submission from Evgeny Kapun: According to the documentation, PyIter_Next should raise TypeError if passed an object which is not an iterator as an argument. Instead, it calls a function through a null pointer, which leads to a crash. -- components: Interpreter Core messages

[issue17899] os.listdir() leaks FDs if invoked on FD pointing to a non-directory

2013-05-04 Thread Evgeny Kapun
Evgeny Kapun added the comment: To make fdopendir fail, just pass any valid FD which points to a non-directory, such as a file or a pipe. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17899

[issue17899] os.listdir() leaks FDs if invoked on FD pointing to a non-directory

2013-05-04 Thread Evgeny Kapun
Evgeny Kapun added the comment: Simple test: while True: try: listdir(0) except NotADirectoryError: pass -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17899

[issue11406] There is no os.listdir() equivalent returning generator instead of list

2013-05-03 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11406 ___ ___ Python

[issue17899] os.listdir() leaks FDs if invoked on FD pointing to a non-directory

2013-05-03 Thread Evgeny Kapun
New submission from Evgeny Kapun: When called with a file descriptor as an argument, os.listdir() duplicates it to pass to fdopendir(3). If this call fails, the new file descriptor is not closed, which leads to file descriptor leak. -- components: Library (Lib) messages: 188322 nosy

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2013-03-14 Thread Evgeny Kapun
Evgeny Kapun added the comment: The way how argparse currently parses option arguments is broken. If a long option requires an argument and it's value isn't specified together with the option (using --option=value syntax), then the following argument should be interpreted as that value

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2013-03-02 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9334 ___ ___ Python

[issue1508475] transparent gzip compression in urllib

2012-03-04 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1508475 ___ ___ Python

[issue12983] byte string literals with invalid hex escape codes raise ValueError instead of SyntaxError

2011-09-15 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12983 ___ ___ Python

[issue12729] Python lib re cannot handle Unicode properly due to narrow/wide bug

2011-09-15 Thread Evgeny Kapun
Changes by Evgeny Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12729 ___ ___ Python

[issue12464] tempfile.TemporaryDirectory.cleanup follows symbolic links

2011-07-01 Thread Evgeny Kapun
New submission from Evgeny Kapun abacabadabac...@gmail.com: TemporaryDirectory.cleanup follows symbolic links to directories and tries to clean them as well. Try this (on Linux): import os, tempfile with tempfile.TemporaryDirectory() as d: os.symlink(/proc, d + /test

[issue12465] gc.get_referents can be used to crash Python

2011-07-01 Thread Evgeny Kapun
New submission from Evgeny Kapun abacabadabac...@gmail.com: This code crashes Python: import gc gc.get_referents(object.__dict__)[0].clear() gc.get_referents(type.__dict__)[0].clear() type(A, (), {})() -- components: Interpreter Core messages: 139572 nosy: abacabadabacaba priority

[issue10451] memoryview can be used to write into readonly buffer

2010-11-17 Thread Evgeny Kapun
New submission from Evgeny Kapun abacabadabac...@gmail.com: This code crashes Python: import io, mmap io.BytesIO(b' ').readinto(memoryview(mmap.mmap(-1, 1, prot=mmap.PROT_READ))) -- components: Interpreter Core messages: 121446 nosy: abacabadabacaba priority: normal severity: normal