[issue42513] Socket.recv hangs

2021-01-07 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

If the edge-case is vaguely socket/file descriptor-related and not 
application-specific or otherwise secret do you mind sharing what is it? (I'm 
just curious)

--

___
Python tracker 
<https://bugs.python.org/issue42513>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42513] Socket.recv hangs

2020-12-27 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue42513>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42673] Optimize round_size for rehashing

2020-12-18 Thread Jakub Stasiak

Jakub Stasiak  added the comment:

I'd be especially curious about branch (mis)prediction stats before and after 
applying this patch – including such information seems necessary in a patch 
that's about optimization.

--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue42673>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42590] Something like Rust's std::sync::Mutex – combining a mutex primitive and a piece of data it's protecting

2020-12-07 Thread Jakub Stasiak

New submission from Jakub Stasiak :

I've been wondering if it's worth it to have something like Rust's 
std::sync::Mutex[1] which is used like this:

let data = Mutex::new(0);
{
let mut unlocked = data.lock().unwrap();
*unlocked += 1;
}
// unlocked is no longer available here, we need to use data.lock() again


Our (Python) [R]Lock is typically used like this:

data_to_protect = whatever()
lock = Lock()

# ...
with lock:
data_to_protect.do_something()


The inconvenience of this is obvious to me and it's more error prone if one 
forgets the lock when accessing data_to_protect. I wrote a quick prototype to 
get something like Mutex in Python:

import threading
from contextlib import contextmanager
from typing import Any, cast, Dict, Generator, Generic, Optional, TypeVar

T = TypeVar('T')


class LockedData(Generic[T]):
def __init__(self, data: T, lock: Any = None) -> None:
self._data = data
if lock is None:
lock = threading.Lock()
self._lock = lock

@contextmanager
def unlocked(self, timeout: float = -1.0) -> Generator[T, None, None]:
acquired = None
unlocked = None
try:
acquired = self._lock.acquire(timeout=timeout)
if acquired is False:
raise LockTimeout()
unlocked = UnlockResult(self._data)
yield unlocked
finally:
if acquired is True:
if unlocked is not None:
unlocked._unlocked = False
self._data = unlocked._data
unlocked._data = None
self._lock.release()


class UnlockResult(Generic[T]):
_data: Optional[T]

def __init__(self, data: T) -> None:
self._data = data
self._unlocked = True

@property
def data(self) -> T:
assert self._unlocked
return cast(T, self._data)

@data.setter
def data(self, data: T) -> None:
assert self._unlocked
self._data = data


class LockTimeout(Exception):
pass


if __name__ == '__main__':
locked_dict: LockedData[Dict[str, bool]] = LockedData({})

# Mutating the dictionary
with locked_dict.unlocked() as result:
result.data['hello'] = True

with locked_dict.unlocked() as result:
print(result.data)

# Replacing the dictionary
with locked_dict.unlocked() as result:
result.data = {'a': True, 'b': False}

with locked_dict.unlocked() as result:
print(result.data)

# Trying to access data after context closes
print(result._data)
print(result.data)

Now this is obviously quite far from what Rust offers, as there's nothing to 
prevent a person from doing something like this:

with locked_dict.unlocked() as result:
data = result.data

print('Oh no, look: %r' % (data,))

but it seems to me it's still an improvement.


[1] https://doc.rust-lang.org/std/sync/struct.Mutex.html

--
components: Library (Lib)
messages: 382650
nosy: benjamin.peterson, jstasiak, pitrou, vstinner
priority: normal
severity: normal
status: open
title: Something like Rust's std::sync::Mutex – combining a mutex primitive and 
a piece of data it's protecting
type: enhancement
versions: Python 3.10

___
Python tracker 
<https://bugs.python.org/issue42590>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42390] Other Python implementations may not expose the module name in datetime type names

2020-11-18 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue42390>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42202] Optimize function annotation

2020-11-17 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

Yurii, I don't believe that benchmark measures what you need to measure (once 
imported module is kept imported forever until unloaded, so successive imports 
are no-ops).

See how the side effects of importing bbb only happen once: 

% cat bbb.py 
import time
time.sleep(1)
with open('bbb.log', 'a') as f:
written = f.write('hello\n')
assert written == 6

% time python -m timeit "import bbb"
1 loop, best of 5: 515 nsec per loop
python -m timeit "import bbb"  0.03s user 0.01s system 4% cpu 1.050 total

% cat bbb.log 
hello

--

___
Python tracker 
<https://bugs.python.org/issue42202>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42202] Optimize function annotation

2020-11-16 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue42202>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17852] Built-in module _io can lose data from buffered files in reference cycles

2020-11-12 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue17852>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42319] The `functools.singledispatchmethod` example in the document cannot run

2020-11-12 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

There's an earlier issue created that relates to this 
(https://bugs.python.org/issue39679) and there are some possible solutions to 
get singledispatchmethod and classmethod work there.

--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue42319>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42237] test_socket.SendfileUsingSendfileTest fails on illumos

2020-11-12 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
pull_requests: +22143
pull_request: https://github.com/python/cpython/pull/23246

___
Python tracker 
<https://bugs.python.org/issue42237>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42269] Add ability to set __slots__ in dataclasses

2020-11-11 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

As a moderately-heavy dataclass user I support this. :)

--

___
Python tracker 
<https://bugs.python.org/issue42269>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38323] asyncio: MultiLoopWatcher has a race condition (test_asyncio: test_close_kill_running() hangs on AMD64 RHEL7 Refleaks 3.x)

2020-11-05 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

FYI your PR 20142 together with my PR 
https://github.com/python/cpython/pull/23154 allow me to run the whole 
test_asyncio test suite on OpenIndiana 5.11:

$ ./python -m unittest -v test.test_asyncio
(...)
Ran 2298 tests in 71.668s

OK (skipped=52)


without your PR at least one of the tests is hanging forever. So, this PR 
improves Solaris/SunOS/illumos/OpenIndiana side of things as well.

--

___
Python tracker 
<https://bugs.python.org/issue38323>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41843] Reenable sendfile in shutil.copyfile() on Solaris

2020-11-05 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue41843>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42269] Add ability to set __slots__ in dataclasses

2020-11-05 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue42269>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41839] Solaris: Fix error checking in sched_get_priority_ functions

2020-11-05 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

I think negative values aren't possible on Linux if one's to trust the 
sched_get_priority_min man page:


   Linux allows the static priority range 1 to 99 for the SCHED_FIFO and
   SCHED_RR policies, and the priority 0 for the remaining policies.
   Scheduling priority ranges for the various policies are not
   alterable.

But yeah, it seems that negative values need to be accepted on Solaris.

--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue41839>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38323] asyncio: MultiLoopWatcher has a race condition (test_asyncio: test_close_kill_running() hangs on AMD64 RHEL7 Refleaks 3.x)

2020-11-05 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue38323>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42173] Drop Solaris support

2020-11-05 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue42173>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42237] test_socket.SendfileUsingSendfileTest fails on illumos

2020-11-04 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

Thank you! I submitted a PR with a slightly modified patch (the comparison only 
happens on Solaris family of systems), I'd appreciate your confirmation that it 
still works (it's working for me on openindiana).

--

___
Python tracker 
<https://bugs.python.org/issue42237>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42237] test_socket.SendfileUsingSendfileTest fails on illumos

2020-11-04 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
pull_requests: +22066
pull_request: https://github.com/python/cpython/pull/23154

___
Python tracker 
<https://bugs.python.org/issue42237>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42237] test_socket.SendfileUsingSendfileTest fails on illumos

2020-11-04 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

I thought I'd give it a shot and I believe i found the issue. Let's use the 
testCount test as an example.

The client side (or the data sending side) looks like this:

def _testCount(self):
address = self.serv.getsockname()
file = open(os_helper.TESTFN, 'rb')
sock = socket.create_connection(address,
timeout=support.LOOPBACK_TIMEOUT)
with sock, file:
count = 507
meth = self.meth_from_sock(sock)
sent = meth(file, count=count)
self.assertEqual(sent, count)
self.assertEqual(file.tell(), count)

So we're sending 507 bytes of data at once to a socket that has a timeout 
of 5.0 seconds set (default in those tests).

Somewhere along the way socket._sendfile_use_sendfile() is called and in it 
there's a loop:

try:
while True:
(...)
try:
sent = os_sendfile(sockno, fileno, offset, blocksize)
except BlockingIOError:
if not timeout:
# Block until the socket is ready to send some
# data; avoids hogging CPU resources.
selector_select()
continue
(...)
return total_sent

On my test VM running openindiana 5.11 (I think that's the version number?) 
this is basically an infinite loop (I think it'll end at some point, but I 
didn't have the patience to verify this). That's because trying to send 507 
bytes to that socket with 5 seconds timeout will trigger BlockingIOError. Why?

This is the relevant part of os.sendfile() implementation from posixmodule.c:

do {
Py_BEGIN_ALLOW_THREADS
ret = sendfile(out_fd, in_fd, , count);
Py_END_ALLOW_THREADS
} while (ret < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
if (ret < 0)
return (!async_err) ? posix_error() : NULL;
return Py_BuildValue("n", ret);


offset is 0 in our case, but its exact value doesn't matter. The trouble is 
this is what illumos sendfile man page[1] says:


RETURN VALUES

   (...) In some error cases sendfile() may still write some
   data before encountering an error and returning -1.  When that occurs,
   off is updated to point to the byte that follows the last byte copied and
   should be compared with its value before calling sendfile() to determine
   how much data was sent.

After some input from Jakub Kulik I believe this is a unique behavior (Linux, 
Oracle Solaris, Mac OS, FreeBSD and likely all or almost all other OSes don't 
do this) and it lacks handling on the Python side.

I tested this and indeed the sendfile(out_fd, in_fd, , count) call 
*does* do partial writes in our case which gets reported as EAGAIN which gets 
converted to BlockingIOError which makes socket._sendfile_use_sendfile() retry 
again and again, each time resending the very beginning of the data and not 
going any further, therefore accumulating a lot of garbage on the receiving 
socket's side.

This patch works for me and I run the whole test_socket test suite with it, no 
more failures:

diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 203f98515dfd..eeff11b5b8ea 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -9475,13 +9475,20 @@ os_sendfile_impl(PyObject *module, int out_fd, int 
in_fd, PyObject *offobj,
}
#endif

+off_t original_offset = offset;
do {
Py_BEGIN_ALLOW_THREADS
ret = sendfile(out_fd, in_fd, , count);
Py_END_ALLOW_THREADS
} while (ret < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
-if (ret < 0)
-return (!async_err) ? posix_error() : NULL;
+if (ret < 0) {
+   if (offset != original_offset) {
+   ret = offset - original_offset;
+   }
+   else {
+   return (!async_err) ? posix_error() : NULL;
+   }
+}
return Py_BuildValue("n", ret);
#endif
}

If it's verified to be a good change I'm happy to resubmit it in a PR with 
appropriate illumos-specific #ifndefs.


[1] https://illumos.org/man/3ext/sendfile

--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue42237>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42230] Document that asyncio's wait() and as_completed() accept arbitrary iterables

2020-11-02 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
pull_requests: +22022
pull_request: https://github.com/python/cpython/pull/23105

___
Python tracker 
<https://bugs.python.org/issue42230>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42140] asyncio.wait function creates futures set two times

2020-11-01 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

I opened https://bugs.python.org/issue42230 to make the documentation reflect 
the reality in this matter.

--

___
Python tracker 
<https://bugs.python.org/issue42140>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42230] Document that asyncio's wait() and as_completed() accept arbitrary iterables

2020-11-01 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
keywords: +patch
pull_requests: +21993
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23073

___
Python tracker 
<https://bugs.python.org/issue42230>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42230] Document that asyncio's wait() and as_completed() accept arbitrary iterables

2020-11-01 Thread Jakub Stasiak


New submission from Jakub Stasiak :

The documentation explicitly says "sets" but arbitrary iterables are accepted 
and various non-sets are passed to those in real world almost certainly.

--
components: asyncio
messages: 380128
nosy: asvetlov, jstasiak, yselivanov
priority: normal
severity: normal
status: open
title: Document that asyncio's wait() and as_completed() accept arbitrary 
iterables
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue42230>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42140] asyncio.wait function creates futures set two times

2020-11-01 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue42140>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40901] It's not clear what "interface name" means in socket if_nameindex/if_nametoindex/if_indextoname on Windows

2020-10-19 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

Cheers!

--

___
Python tracker 
<https://bugs.python.org/issue40901>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41081] Exclude __pycache__ directories from backups using CACHEDIR.TAG

2020-06-22 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
keywords: +patch
pull_requests: +20231
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21060

___
Python tracker 
<https://bugs.python.org/issue41081>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41081] Exclude __pycache__ directories from backups using CACHEDIR.TAG

2020-06-22 Thread Jakub Stasiak


New submission from Jakub Stasiak :

It'd be nice of __pycache__ directories didn't pollute backups. Granted, one 
can add __pycache__ directory to their backup-tool-of-choice exclusion list, 
but those lists are ever growing and maybe it'd be good to help the tools and 
the users.

There's a Cache Directory Tagging Specification[1] which some backup tools like 
Borg, restic, GNU Tar and attic use out of the box (well, with a switch) and 
other tools (like rsync, Bacula, rdiff-backup and I imagine others) can be made 
to use it with a generic exclude-directories-with-this-file-present option 
(partially, just the existence of the tag file is used, not its content).


I wasn't sure what to select in Components, so I went with Library.
[1] https://bford.info/cachedir/

--
components: Library (Lib)
messages: 372109
nosy: jstasiak
priority: normal
severity: normal
status: open
title: Exclude __pycache__ directories from backups using CACHEDIR.TAG
type: enhancement
versions: Python 3.10

___
Python tracker 
<https://bugs.python.org/issue41081>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40548] Always run GitHub action jobs, even on documentation-only jobs

2020-06-14 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue40548>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40901] It's not clear what "interface name" means in socket if_nameindex/if_nametoindex/if_indextoname on Windows

2020-06-07 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

if_nameindex(), if_indextoname() and if_nametoindex() have been implemented as 
part of https://bugs.python.org/issue37007

While working on ifaddr I discovered that all three different kinds of names 
ifaddr fetches for an interface on Windows are not what Python socket functions 
use so I thought it'd be useful to document it for the next person who bumps 
into this.

--
nosy: +ZackerySpytz, dtantsur

___
Python tracker 
<https://bugs.python.org/issue40901>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40901] It's not clear what "interface name" means in socket if_nameindex/if_nametoindex/if_indextoname on Windows

2020-06-07 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
keywords: +patch
pull_requests: +19909
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/20694

___
Python tracker 
<https://bugs.python.org/issue40901>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40901] It's not clear what "interface name" means in socket if_nameindex/if_nametoindex/if_indextoname on Windows

2020-06-07 Thread Jakub Stasiak


New submission from Jakub Stasiak :

On Windows there are different names for the same interface in different 
contexts.

--
components: Library (Lib), Windows
messages: 370894
nosy: jstasiak, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: It's not clear what "interface name" means in socket 
if_nameindex/if_nametoindex/if_indextoname on Windows
type: enhancement
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue40901>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38580] select()'s documentation claims only sequences are accepted, but it allows all iterables

2020-05-26 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

Cheers for backporting this, Tal, you beat me to it!

--

___
Python tracker 
<https://bugs.python.org/issue38580>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27501] Add typing.py class describing a PEP 3118 buffer object

2020-05-19 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue27501>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37339] os.path.ismount returns true on nested btrfs subvolumes

2020-04-22 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue37339>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39318] NamedTemporaryFile could cause double-close on an fd if _TemporaryFileWrapper throws

2020-02-06 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue39318>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-02-06 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
pull_requests: +17766
pull_request: https://github.com/python/cpython/pull/18379

___
Python tracker 
<https://bugs.python.org/issue39491>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-02-06 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue39491>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-02-03 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +levkivskyi

___
Python tracker 
<https://bugs.python.org/issue39491>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-02-03 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +gvanrossum

___
Python tracker 
<https://bugs.python.org/issue39491>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39298] add BLAKE3 to hashlib

2020-02-01 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue39298>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-01-29 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
keywords: +patch
pull_requests: +17636
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/18260

___
Python tracker 
<https://bugs.python.org/issue39491>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-01-29 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
components: Library (Lib)
nosy: jstasiak
priority: normal
severity: normal
status: open
title: Import PEP 593 (Flexible function and variable annotations) support 
already implemented in typing_extensions
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue39491>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38580] select()'s documentation claims only sequences are accepted, but it allows all iterables

2019-10-24 Thread Jakub Stasiak

New submission from Jakub Stasiak :

Excerpt from the documentation:

"""This is a straightforward interface to the Unix select() system call. The 
first three arguments are sequences of ‘waitable objects’: either integers 
representing file descriptors or objects with a parameterless method named 
fileno() returning such an integer:"""

In reality it accepts for example dictionary key views (that's how I discovered 
it) due to its internal usage of PySequence_Fast, which (from 
https://docs.python.org/3/c-api/sequence.html#c.PySequence_Fast):

"""Return the sequence or iterable o as an object usable by the other 
PySequence_Fast* family of functions. If the object is not a sequence or 
iterable, raises TypeError with m as the message text. Returns NULL on 
failure."""

I made a pull request to document this behavior in select 
(https://github.com/python/cpython/pull/16832) but it was recommended that I 
create this issue because the solution may not be obvious here.

--
components: Library (Lib)
messages: 355325
nosy: corona10, jstasiak
priority: normal
pull_requests: 16447
severity: normal
status: open
title: select()'s documentation claims only sequences are accepted, but it 
allows all iterables
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue38580>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-10-10 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue13322>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29847] Path takes and ignores **kwargs

2019-05-17 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue29847>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34700] typing.get_type_hints doesn't know about typeshed

2019-05-17 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 
<https://bugs.python.org/issue34700>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27494] 2to3 parser failure caused by a comma after a generator expression

2018-07-31 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

I appreciate the example, but I'd claim that's a "missing fixer" issue, not a 
"parser accepts too much" issue. Considering the syntax wasn't ambiguous (I 
think) and had been accepted before 3.7 I'll remain not totally convinced here.

--

___
Python tracker 
<https://bugs.python.org/issue27494>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27494] 2to3 parser failure caused by a comma after a generator expression

2018-07-31 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

Apologies for only responding now, I've not received any notifications after my 
original pull request had been merged. I only learned about the change being 
reverted from https://github.com/python/cpython/pull/8580, so let me leave my 
two cents here:

I don't think the syntax not being valid (formally - since forever, practically 
- since 3.7) is good enough reason to make (lib)2to3 reject it. 2to3 is 
supposed to handle old syntax, isn't it? I'd argue that since it is (or was) 
possible to use this syntax in Python 2.x it should be handled gracefully.

--

___
Python tracker 
<https://bugs.python.org/issue27494>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27494] 2to3 parser failure caused by a comma after a generator expression

2017-10-01 Thread Jakub Stasiak

Jakub Stasiak <jakub+python@stasiak.at> added the comment:

By "forbid" do you mean "forbid in Python" (as in change Python syntax)? I like 
the idea but that seems like a more serious change and 2to3 arguably needs to 
handle code targeting older Python versions anyway.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue27494>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27494] 2to3 parser failure caused by a comma after a generator expression

2017-09-26 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
keywords: +patch
pull_requests: +3758
stage:  -> patch review

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue27494>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28629] Emit ResourceWarning when implicitly terminating a suspended frame?

2017-07-19 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28629>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12857] Expose called function on frame object

2017-07-18 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12857>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20692] Tutorial and FAQ: how to call a method on an int

2017-07-03 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20692>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27494] 2to3 parser failure caused by a comma after a generator expression

2017-02-15 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
versions: +Python 3.6, Python 3.7

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27494>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27494] 2to3 parser failure caused by a comma after a generator expression

2017-02-15 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
pull_requests: +87

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27494>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8840] truncate() semantics changed in 3.1.2

2016-09-12 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8840>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27494] 2to3 parser failure caused by a comma after a generator expression

2016-07-12 Thread Jakub Stasiak

New submission from Jakub Stasiak:

Test file (test.py):

print(set(x for x in range(2),))

Python runs it nicely:

% python2 test.py 
set([0, 1])
% python3 test.py
{0, 1}

2to3 parser (on both Python 2.7.11 and 3.5.2) chokes on it though:

% 
/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/2to3
 test.py 
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Can't parse test.py: ParseError: bad input: type=8, 
value=u')', context=('', (1, 30))
RefactoringTool: No files need to be modified.
RefactoringTool: There was 1 error:
RefactoringTool: Can't parse test.py: ParseError: bad input: type=8, 
value=u')', context=('', (1, 30))

% 
/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/bin/2to3
 test.py 
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Can't parse test.py: ParseError: bad input: type=8, value=')', 
context=('', (1, 30))
RefactoringTool: No files need to be modified.
RefactoringTool: There was 1 error:
RefactoringTool: Can't parse test.py: ParseError: bad input: type=8, value=')', 
context=('', (1, 30))


For reference: https://github.com/smarkets/flake8-strict/issues/9 (project 
using lib2to3 parser)

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 270236
nosy: jstasiak
priority: normal
severity: normal
status: open
title: 2to3 parser failure caused by a comma after a generator expression
type: crash
versions: Python 2.7, Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27494>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26058] PEP 509: Add ma_version to PyDictObject

2016-05-15 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26058>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26219] implement per-opcode cache in ceval

2016-05-15 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26219>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26110] Speedup method calls 1.2x

2016-05-15 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26110>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25998] doctest terminates when accessing __wrapped__ raises an error

2016-05-11 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25998>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23507] Tuple creation is too slow

2016-05-09 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23507>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26814] [WIP] Add a new _PyObject_FastCall() function which avoids the creation of a tuple or dict for arguments

2016-05-09 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26814>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25609] Add a ContextManager ABC and type

2016-03-18 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25609>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26396] Create json.JSONType

2016-03-09 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26396>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26335] Make mmap.write return the number of bytes written like other write methods

2016-03-02 Thread Jakub Stasiak

Jakub Stasiak added the comment:

Glad I could help, thanks for merging!

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26335>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26435] Fix versionadded/versionchanged documentation directives

2016-02-25 Thread Jakub Stasiak

New submission from Jakub Stasiak:

A double colon seems to be required for a directive to work, please find a 
patch attached.

--
assignee: docs@python
components: Documentation
files: typos.patch
keywords: patch
messages: 260848
nosy: docs@python, jstasiak
priority: normal
severity: normal
status: open
title: Fix versionadded/versionchanged documentation directives
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file42027/typos.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26435>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26335] Make mmap.write return the number of bytes written like other write methods

2016-02-25 Thread Jakub Stasiak

Jakub Stasiak added the comment:

Thank you. I didn't know whether to add an entry to Doc/whatsnew/3.6.rst, 
Misc/NEWS or both so I chose both, feel free to modify/remove as needed.

The new patch also doesn't have a typo in the versionchanged directive present 
in the version 2. I noticed more typos like this (single colon instead of 
double colon), I'll create a separate issue.

--
Added file: http://bugs.python.org/file42026/mmap_write_return_count3.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26335>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26335] Make mmap.write return the number of bytes written like other write methods

2016-02-23 Thread Jakub Stasiak

Jakub Stasiak added the comment:

Oops, sorry for the silliness in the C code, thanks for reviewing. I modified 
as suggested, please find the new patch attached.

--
Added file: http://bugs.python.org/file42014/mmap_write_return_count2.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26335>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15873] datetime: add ability to parse RFC 3339 dates and times

2016-02-12 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15873>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26335] Make mmap.write return the number of bytes written like other write methods

2016-02-10 Thread Jakub Stasiak

New submission from Jakub Stasiak:

Since mmap objects are said to "behave like both bytearray and like file 
objects" I believe it's appropriate for the mmap.write() method to return the 
number of bytes written like write() of other file objects/interfaces I could 
find in the standard library for consistency reasons:

https://docs.python.org/3/library/io.html#io.BufferedIOBase.write
https://docs.python.org/3/library/io.html#io.BufferedWriter.write
https://docs.python.org/3/library/io.html#io.RawIOBase.write
https://docs.python.org/3/library/io.html#io.TextIOBase.write

Why I believe this would be useful: code that writes to file objects and tests 
the number of bytes/characters written right now will likely fail when it's 
passed a mmap object because its write() method returns None. With this patch 
applied it'll work transparently.

Please find proposed patch attached, I included information about the exception 
type in the documentation as it seems fitting (apologies for generating the 
patch using Git, I'll generate using Mercurial if necessary).

--
components: IO, Library (Lib)
keywords: patch
messages: 260053
nosy: jstasiak
priority: normal
severity: normal
status: open
title: Make mmap.write return the number of bytes written like other write 
methods
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file41890/mmap_write_return_count.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26335>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26292] Raw I/O writelines() broken

2016-02-05 Thread Jakub Stasiak

Changes by Jakub Stasiak <jakub+python@stasiak.at>:


--
nosy: +jstasiak

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26292>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25586] socket.sendall broken when a socket has a timeout

2015-11-10 Thread Jakub Stasiak

Jakub Stasiak added the comment:

That's fair and thanks for the links.

Please find a quick patch attached, feel free to use that or any modification 
of it. While I believe the documentation is technically correct right now it 
won't hurt to clarify this I think.

--
keywords: +patch
Added file: http://bugs.python.org/file40994/socket-docs.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25586>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25586] socket.sendall broken when a socket has a timeout

2015-11-09 Thread Jakub Stasiak

Jakub Stasiak added the comment:

This is exactly what I'm thinking. Do you think it's sensible to move that 
sentence + some additional information (following your suggestion) into a 
"Warning" block?

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25586>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25586] socket.sendall broken when a socket has a timeout

2015-11-08 Thread Jakub Stasiak

New submission from Jakub Stasiak:

It is my understanding that socket.sendall effectively calls the underlying 
socket.send's implementation in a retry loop, possibly multiple times.

It is also my understanding that each one of those low level send calls can 
timeout on its own if a socket timeout is set.

Considering the above I believe it's undesired to ever call socket.sendall with 
a socket that has a timeout set because if:

1. At least one send call succeeds
2. A send call after that times out

then a socket timeout error will be raised and the information about the sent 
data will be lost.

Granted, the documentation says that "On error, an exception is raised, and 
there is no way to determine how much data, if any, was successfully sent". I 
believe, however, that such API is very easy to misuse (I've seen it used with 
sockets with timeout set, because of small payload sizes and other 
circumstances it would appear to work fine most of the time and only fail every 
N hours or days).

Possible improvements I see:

1. Explicitly mention interaction between socket's timeout and sendall's 
behavior in the documentation
2. Make sendall raise an error when the socket it's called with has a timeout 
set (I can see the backwards compatibility being a concern here but I can't 
think of any reason to remain compatible with behavior I believe to be broken 
anyway)
3. Both of the above

I'm happy to procure an appropriate patch for any of the above. Please correct 
me if my understanding of this is off.

--
assignee: docs@python
components: Documentation, IO, Library (Lib)
messages: 254357
nosy: docs@python, jstasiak
priority: normal
severity: normal
status: open
title: socket.sendall broken when a socket has a timeout
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25586>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25586] socket.sendall broken when a socket has a timeout

2015-11-08 Thread Jakub Stasiak

Jakub Stasiak added the comment:

Martin: While I'd consider timeout in HTTPConnection(timeout=...) or 
urlopen(timeout=...) to be the timeout for the entire operation, just just for 
the data sending part and HTTPConnection/urlopen can achieve the timeout 
behavior using just send I concede there may be valid use cases for "either 
sendall succeeds or we don't care about what we've sent anyway" and in this 
light my second suggestion is problematic.

Victor: The behavior change in 3.5 does't affect my concern from what I see.  
The concern is sendall timing out after some data has already been sent which 
can create some subtle issues. I've seen code like this:

def x(data, sock):
while True:
# some code here
try:
sock.sendall(data)
return
except timeout:
pass


Now I'll agree the code is at fault for ever attempting to retry sendall but I 
also think the API is easy to misuse like this. And it many cases it'll just 
work most of the time because sendall won't timeout.

Maybe explicitly mentioning sendall's behavior concerning sockets with timeouts 
could improve this? I'm honestly not sure anymore, technically "On error, an 
exception is raised, and there is no way to determine how much data, if any, 
was successfully sent." should be enough.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25586>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-16 Thread Jakub Stasiak

Jakub Stasiak added the comment:

That's right, I was actually wondering about it few minutes before you pointed 
it out. Find new patch attached.

--
Added file: http://bugs.python.org/file31792/timeit-v4-actual-changes.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18975
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-15 Thread Jakub Stasiak

Jakub Stasiak added the comment:

Antoine: I agree that it does look weird to have thousands separators at one 
place and not at the other but IMO it's still slightly better - the number 
formatted with separators is simply more readable that separator-less one.

R. David Murray: what's the acceptable separator then? Modifying it to be 
locale-aware would make it inconsistent with the rest of the output (which, 
admittedly, is also the case with introducing space separator, dot still is the 
fraction separator though).

I modified my patch to not have the separators at all, please find 
timeit-v3-actual-changes-no-separators.patch - if that's the condition for 
accepting this patch then so be it - the description of the patch would be 
print number of loops per second and the example output is:

1 loops, best of 3: 34.6 usec per loop (28870 loops/s)

--
Added file: 
http://bugs.python.org/file31786/timeit-v3-actual-changes-no-separators.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18975
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Jakub Stasiak

New submission from Jakub Stasiak:

This patch includes:
* making code more PEP8-compatible and refactoring it a bit
* printing number of loops per second when using command line interface
* using thousands separators when printing numbers of loops (also in command 
line interface)
* changing examples in the module documentation

The output is changed from this:

1 loops, best of 3: 40.3 usec per loop

to that:

10,000 loops, best of 3: 34.6 usec per loop, 28,870.783/s

I'm still not sure about details of 28,870.783/s part:
* whether it should always include the fractional part (in this example it 
doesn't make any sense)
* maybe it should say loops/s rather than just /s

--
components: Library (Lib)
files: timeit.patch
keywords: patch
messages: 197274
nosy: jstasiak
priority: normal
severity: normal
status: open
title: timeit: Use thousands separators and print number of loops per second
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31672/timeit.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18975
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Jakub Stasiak

Jakub Stasiak added the comment:

Oops, forgot to patch the tests, please find correct patch attached.

--
Added file: http://bugs.python.org/file31673/timeit-v2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18975
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Jakub Stasiak

Jakub Stasiak added the comment:

I agree with both notes. Splitting the patch won't be a problem.

As much as I don't fancy , as thousands separator either - I just used what's 
in the standard library but I'll think about the best way of putting spaces 
there.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18975
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Jakub Stasiak

Jakub Stasiak added the comment:

To me the point of this patch is adding number of loops per second information 
- using thousands separators was just an addition which I'm happy to drop.

Please find attached 2 patches:
- one containing actual changes - loops per second added, fractional part is 
printed when the number is less than 100, space is used as thousands separator; 
old part of the message is not affected
- one containing PEP8 reformatting

So:

1 loops, best of 3: 34.6 usec per loop (28 870 loops/s)

--
Added file: http://bugs.python.org/file31683/timeit-v3-actual-changes.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18975
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Jakub Stasiak

Changes by Jakub Stasiak jakub+python@stasiak.at:


Added file: http://bugs.python.org/file31684/timeit-v3-pep8.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18975
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18983] Specify time unit for timeit CLI

2013-09-08 Thread Jakub Stasiak

Jakub Stasiak added the comment:

My 2 cents - I'd split timeit.main function into processing part and argument 
parsing + data printing part so that you could use Python to call the first one 
to get the actual results (timings, numbers of loops etc.) and then present the 
data to the outside world in any needed format - no text parsing needed.

--
nosy: +jstasiak

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18983
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-09-05 Thread Jakub Stasiak

Jakub Stasiak added the comment:

I don't see an obvious way of solving that. One thing I could think of is 
creating a wrapper for file method being returned from __getattr__ that holds 
reference to _TemporaryFileWrapper instance until the method gets called, 
please find a patch attached.

--
keywords: +patch
nosy: +jstasiak
Added file: http://bugs.python.org/file31598/tempfile.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18879
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17862] itertools.chunks(iterable, size, fill=None)

2013-09-02 Thread Jakub Stasiak

Jakub Stasiak added the comment:

I'm just gonna leave my implementation of chunk function (not sure about the 
name yet) here, it's basically what itertools.chunks from the previous patch is 
but it works for arbitrary iterables + few tests and documentation. The last 
chunk is currently truncated if there are not enough elements to fill it 
completely.

--
nosy: +jstasiak
Added file: http://bugs.python.org/file31565/itertools.chunk.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17862
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18795] pstats - allow stats sorting by cumulative time per call and total time per call

2013-09-01 Thread Jakub Stasiak

Jakub Stasiak added the comment:

I'd change cumulativepercall and totalpercall to cumpercall and percall (and/or 
intpercall) but that's a detail, this patch works for me.

Data structure affected by this patch is produced and consumed internally by 
the sort method so it looks like nothing changes from the point of view of 
client code.

--
nosy: +jstasiak

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18795
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com