[issue41735] Thread locks in zlib module may go wrong in rare case

2020-09-06 Thread Ma Lin


Change by Ma Lin :


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

___
Python tracker 

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



[issue41735] Thread locks in zlib module may go wrong in rare case

2020-09-06 Thread Ma Lin


New submission from Ma Lin :

The code in zlib module:

self->zst.next_in = data->buf;  // set next_in
...
ENTER_ZLIB(self);   // acquire thread lock

`self->zst` is a `z_stream` struct defined in zlib, used to record states of a 
compress/decompress stream:

typedef struct z_stream_s {
Bytef*next_in;  /* next input byte */
uInt avail_in;  /* number of bytes available at next_in */
uLongtotal_in;  /* total number of input bytes read so far */

Bytef*next_out; /* next output byte will go here */
uInt avail_out; /* remaining free space at next_out */
uLongtotal_out; /* total number of bytes output so far */

... // Other states
} z_stream;

Setting `next_in` before acquiring the thread lock may mix up 
compress/decompress state in other threads.

Moreover, modify `ENTER_ZLIB` macro, don't release the GIL when the thread lock 
can be acquired immediately. This behavior is the same as the bz2/lzma modules.

--
components: Library (Lib)
messages: 376473
nosy: malin
priority: normal
severity: normal
status: open
title: Thread locks in zlib module may go wrong in rare case
type: behavior
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue38306] High level API for loop.run_in_executor(None, ...)?

2020-09-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

Really closing.

--
nosy: +gvanrossum
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue41729] test_winconsoleio fails and hangs on Windows

2020-09-06 Thread Eryk Sun

Eryk Sun  added the comment:

> ÄÄ^Z^Z^Z^Z^Z^Z^Z^Z^Z^Z

I don't know why Steve made write_input (PC/_testconsole.c) set wRepeatCount in 
each KeyEvent record to 10. Maybe it was a typo. Previous console 
implementations have ignored the repeat count, so it wasn't an issue.

test_ctrl_z checks (1) that reading a non-ASCII character works when split 
across two reads and (2) that Ctrl+Z (0x1A) as the first character of a read is 
handled as EOF, regardless of where it occurs on the line as long as it's the 
first character in the buffer. The latter has to be tested because 
_WindowsConsoleIO has to manually implement the way that WinAPI ReadFile 
handles Ctrl+Z, a behavior that WinAPI ReadConsoleW does not itself implement.

--

___
Python tracker 

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



[issue41513] High accuracy math.hypot()

2020-09-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 67c998de24985b36498b0fdac68d1beceb43aba7 by Raymond Hettinger in 
branch 'master':
bpo-41513: Expand comments and add references for a better understanding 
(GH-22123)
https://github.com/python/cpython/commit/67c998de24985b36498b0fdac68d1beceb43aba7


--

___
Python tracker 

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



[issue41713] _signal module leak: test_interpreters leaked [1424, 1422, 1424] references

2020-09-06 Thread mohamed koubaa


mohamed koubaa  added the comment:

Sounds like there needs to be some python-wide global state that perhaps the 
signal module wraps rather than owns.  I could try to prototype it if you agree

--
nosy: +koubaa

___
Python tracker 

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



[issue41513] High accuracy math.hypot()

2020-09-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21207
pull_request: https://github.com/python/cpython/pull/22123

___
Python tracker 

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



[issue41513] High accuracy math.hypot()

2020-09-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


Added file: https://bugs.python.org/file49448/test_hypot_commutativity.py

___
Python tracker 

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



[issue41513] High accuracy math.hypot()

2020-09-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


Removed file: https://bugs.python.org/file49398/test_hypot_commutativity.py

___
Python tracker 

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



[issue41734] Refactor b32{encode,decode} tests

2020-09-06 Thread Filipe Laíns

Change by Filipe Laíns :


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

___
Python tracker 

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



[issue41734] Refactor b32{encode,decode} tests

2020-09-06 Thread Filipe Laíns

New submission from Filipe Laíns :

As discussed in https://github.com/python/cpython/pull/20441, these tests could 
be improved by using the same format of the b32hex{encode,decode} tests.

--
components: Tests
messages: 376468
nosy: FFY00, p-ganssle
priority: normal
severity: normal
status: open
title: Refactor b32{encode,decode} tests
type: enhancement

___
Python tracker 

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



[issue23163] pdb docs need to contain a statement on threads/multithreaded debugging

2020-09-06 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

See also https://bugs.python.org/issue41571

--
nosy: +pablogsal

___
Python tracker 

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



[issue23163] pdb docs need to contain a statement on threads/multithreaded debugging

2020-09-06 Thread Bar Harel


Change by Bar Harel :


--
nosy: +bar.harel

___
Python tracker 

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



[issue41571] Implement thread-related commands in pdb

2020-09-06 Thread Bar Harel


Change by Bar Harel :


--
nosy: +bar.harel

___
Python tracker 

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



[issue41672] imaplib: wrong return type documented

2020-09-06 Thread Norbert Cyran


Norbert Cyran  added the comment:

@ericsmith

Sure, I can create a PR and link it here when I'm done.

--

___
Python tracker 

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



[issue28850] Regression in Python 3: Subclassing PrettyPrinter.format doesn't work anymore

2020-09-06 Thread Irit Katriel


Irit Katriel  added the comment:

This issue only impacts container objects where  the len(repr(o)) is less than 
width. If the length is greater than width, containers are handled by a 
different code path which is covered by a unit test and works correctly.


For this case, indeed it works in Python 2 but not in Python 3. The 
PrettyPrinter._format code has been refactored quite a lot with respect to 
handling of containers.

In both Python 2 and 3 this happens:

PrettyPrinter.pprint([10]) calls
PrettyPrinter._format([10])  which calls
PrettyPrinter._repr([10]) which calls
MyPrettyPrinter.format([10]) which calls
PrettyPrinter.format([10]) which calls
_safe_repr([10])  which calls
_safe_repr(10)
returns 10
returns [10]
returns [10]
returns [10]
returns [10]

But then they diverge - in Python 3 the [10] is returned as the result, but in 
Python 2 there is another piece of code (starting here 
https://github.com/python/cpython/blob/fdda200195f9747e411d3491aae0806bc1fcd919/Lib/pprint.py#L179)
 which overrides this result and recalculates the representation for 
containers. In our case it does:

since issubclass(type([10]), list):
# ignore the [10] calculated above, now call
self._format(10) which calls
PrettyPrinter._repr(10) which calls
MyPrettyPrinter.format(10)
returns 0xa
returns 0xa
returns 0xa
returns [0xa]


This explains the difference between Python 2 and 3. 

As to why the first calculation returns [10] and not [0xa]:
This is because _safe_repr is defined at module scope, so once it is called we 
are no longer on the PrettyPrinter instance, and the format() override is no 
longer accessible.  When _safe_repr needs to recurse on container contents, it 
calls itself.


I think the solution is to make _safe_repr a method of PrettyPrinter, and make 
it call self.format() when it needs to recurse. The default self.format() just 
calls _safe_repr, so when there is no override the result is the same.

The PR's diff looks substantial, but that's mostly due to the indentation of 
_safe_repr code. To make it easier to review, I split it into several commits, 
where the indentation is done in one commit as a noop change. The other commits 
have much smaller diffs.

--
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.5, Python 3.6, Python 
3.7

___
Python tracker 

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



[issue28850] Regression in Python 3: Subclassing PrettyPrinter.format doesn't work anymore

2020-09-06 Thread Irit Katriel


Change by Irit Katriel :


--
keywords: +patch
nosy: +iritkatriel
nosy_count: 7.0 -> 8.0
pull_requests: +21205
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/22120

___
Python tracker 

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



[issue41733] ContextVar get value is unexpected

2020-09-06 Thread Jason Chen


New submission from Jason Chen :

import asyncio
from contextvars import *

var = ContextVar('VarTest', default=None)

def get_var(tag=None):
obj = var.get()
if obj is None:
obj = object()
var.set(obj)
print(f'{tag=}: get_var result is {obj=}')
return obj

async def get_var_object(tag):
return get_var(tag)

async def asyncio_main():
await asyncio.gather(*[get_var_object(id) for id in range(2)])

def test(get_var_before_run=False):
print(f'{get_var_before_run=}')
if get_var_before_run:
get_var()
asyncio.run(asyncio_main())
print()


if __name__ == '__main__':
test(get_var_before_run=False)
test(get_var_before_run=True)


 Output:---

tag=0: get_var result is obj=
tag=1: get_var result is obj=

get_var_before_run=True
tag=None: get_var result is obj=
tag=0: get_var result is obj=
tag=1: get_var result is obj=


--- my question: --
-- all objects in get_var_before_run=True are same.
-- my expected result is all objects should be different, because the code runs 
in different context.

--
components: asyncio
messages: 376464
nosy: asvetlov, chenzep, yselivanov
priority: normal
severity: normal
status: open
title: ContextVar get value is unexpected
versions: Python 3.8

___
Python tracker 

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



[issue41718] test.regrtest has way too many imports

2020-09-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

>
> Yes, but they should be imported after running the test. Note that the
> default value in the example was changed from None to set().

--

___
Python tracker 

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



[issue30646] SQLite: sqlite3_enable_shared_cache() is deprecated

2020-09-06 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue41718] test.regrtest has way too many imports

2020-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

> You could save/restore this data only when corresponded modules was imported, 
> like it was done in clear_caches() in refleak.py.

It was my first idea, but some large modules like multiprocessing and asyncio 
are only imported by tested when the test file is imported, whereas 
save_environment() is called (__enter__) before the import in 
libregrtest.runtest.

--

___
Python tracker 

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



[issue38325] [Windows] test_winconsoleio failures

2020-09-06 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-09-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 63f102fe079ecb5cb7b921a1cf8bce4077a9d7e2 by Mohamed Koubaa in 
branch 'master':
bpo-1635741: Port _sha1, _sha512, _md5 to multiphase init (GH-21818)
https://github.com/python/cpython/commit/63f102fe079ecb5cb7b921a1cf8bce4077a9d7e2


--

___
Python tracker 

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



[issue41732] Custom iterator to memoryview - performance improvement

2020-09-06 Thread Diogo Flores


Change by Diogo Flores :


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

___
Python tracker 

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



[issue41732] Custom iterator to memoryview - performance improvement

2020-09-06 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +skrah

___
Python tracker 

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



[issue41732] Custom iterator to memoryview - performance improvement

2020-09-06 Thread Diogo Flores


New submission from Diogo Flores :

Hi,

Here's a patch that adds an iterator to memoryview, which makes iterating over 
memoryview objs considerably faster.

The following values result from a compilation with debug ON.



Without patch:

cpython: ./python.exe -m timeit -s "a=memoryview(b'x'*100)" "for x in a: 
pass"
5 loops, best of 5: 98 msec per loop

cpython: ./python.exe -m timeit -s "a=b'x'*100" "for x in a: pass"
5 loops, best of 5: 68.6 msec per loop


With patch:

cpython: ./python.exe -m timeit -s "a=memoryview(b'x'*100)" "for x in a: 
pass"
5 loops, best of 5: 68.1 msec per loop

cpython: ./python.exe -m timeit -s "a=b'x'*100" "for x in a: pass"
5 loops, best of 5: 70 msec per loop



Please let me know your thoughts regarding it.

Diogo

--
messages: 376460
nosy: dxflores
priority: normal
severity: normal
status: open
title: Custom iterator to memoryview - performance improvement
versions: Python 3.10

___
Python tracker 

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



[issue41730] Show deprecation warnings for tkinter.tix

2020-09-06 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

The removal was suggested before but not merged in 
https://bugs.python.org/issue31371

--
nosy: +gpolo, serhiy.storchaka, xtreak

___
Python tracker 

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