[issue41291] Race conditions when opening and deleting a file on Mac OS X

2020-07-15 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

If it is reproducable in C this is likely a bug in macOS, and should be 
reported to them. 

I get the same behaviour as you with the test script, even if I add calls to 
fhandle.flush and os.fsync to force the content to stable storage.

Interestingly enough I sometimes get other behaviour that shouldn't happen:

Traceback (most recent call last):
  File "/Users/ronald/Downloads/concurrency-tests/test-conc-read.py", line 33, 
in 
fhandle.flush()
OSError: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "concurrency-tests/test-conc-read.py", line 34, in 
os.fsync(fhandle.fileno())
OSError: [Errno 22] Invalid argument


This is with the change I wrote about earlier:

except FileNotFoundError:
print(i, ">> DELETED <<")
# Recreate the file
time.sleep(0.001) # Wait a bit
with open(dest_fname, 'wb') as fhandle:
fhandle.write(b'CONTENT')
fhandle.flush()
os.fsync(fhandle.fileno())

This shouldn't happen, "fhandle" is open at this point and hence the low-level 
file descriptor should still be valid.

--

___
Python tracker 

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



[issue41301] Assignment operation of list is not working as expected

2020-07-15 Thread Yashwanth Barad


Change by Yashwanth Barad :


--
components: Windows
files: List_assignment_in_functions.py
nosy: paul.moore, steve.dower, tim.golden, yashwanthba...@gmail.com, zach.ware
priority: normal
severity: normal
status: open
title: Assignment operation of list is not working as expected
type: behavior
versions: Python 3.7, Python 3.8
Added file: https://bugs.python.org/file49317/List_assignment_in_functions.py

___
Python tracker 

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



[issue41291] Race conditions when opening and deleting a file on Mac OS X

2020-07-15 Thread Giovanni Pizzi


Giovanni Pizzi  added the comment:

Thanks for your feedback!

I also just reported the issue to Apple. For reference I got the Feedback ID 
FB8009608.

I will let you know if they answer.

In any case I agree that also your other error is unexpected.
I am writing a library that should provide atomicity guarantees and this issue 
is creating me a lot of headaches :-)

--

___
Python tracker 

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



[issue41301] Assignment operation of list is not working as expected

2020-07-15 Thread Steven D'Aprano


New submission from Steven D'Aprano :

Sorry Yashwanthbarad, this isn't a bug, you expect the wrong result.

Augmented assignment for lists is documented to be the same as calling the 
extend method, which means your AppenedFuncShortHandOperator function modifies 
the argument list in-place.

The AppenedFuncRegularAssignment simply replaces the *local variable* inside 
the function with a new list. Since it doesn't return the new list, the new 
list gets thrown away when the function returns, leaving the original list 
untouched.

This is not a bug, it is the normal behaviour. If you need help understanding 
why it works the way it does, and the difference between mutating an object and 
binding a new object to a local variable, there are many places you can ask for 
help, such as Stackoverflow, the /learnpython sub-reddit on Reddit, the tutor 
mailing list and others.

https://mail.python.org/mailman/listinfo/tutor

Good luck!

--
nosy: +steven.daprano
resolution:  -> not a bug
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



[issue20183] Derby #14: Convert 41 sites to Argument Clinic across 5 files

2020-07-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset bbceef6851895135c80e588a55854c1afab46499 by Zackery Spytz in 
branch 'master':
bpo-20183: Convert _locale to the Argument Clinic (GH-14201)
https://github.com/python/cpython/commit/bbceef6851895135c80e588a55854c1afab46499


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue41278] IDLE: Clarify some completion details in doc

2020-07-15 Thread E. Paine


E. Paine  added the comment:

Terry, can we change the user process to be owned by the filelist rather than 
the shell to avoid this difference in behaviour? (I can't think of any reason 
off the top of my head of why this couldn't happen)

--

___
Python tracker 

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



[issue34624] -W option and PYTHONWARNINGS env variable does not accept module regexes

2020-07-15 Thread Nikolaus Rath


Change by Nikolaus Rath :


--
nosy:  -nikratio

___
Python tracker 

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



[issue41299] Python3 threading.Event().wait time is twice as large as Python27

2020-07-15 Thread Ned Deily


Ned Deily  added the comment:

Please provide the results of running the following with the two pythons you 
are using:

python -m test.pythoninfo

For what it's worth, running on macOS 10.15.5, I see a slight difference with 
more variability in the Python 3 results but nothing as pronounced as what you 
see. Also the Python 3 results were very similar across recent versions of 
3.7.x, 3.8.x, and pre-release 3.9.

$ /usr/local/bin/python2.7 ~/test_41299.py | sort
0.017021894455
0.0170249938965
0.017028093338
0.017028093338
0.0170290470123
0.0170290470123
0.0170290470123
0.017036866
0.017030954361
0.0170311927795
[...]
0.0190448760986
0.0190479755402
0.019049882
0.0190510749817
0.0190589427948
0.019061088562
0.0190629959106
0.019079208374
0.0190861225128
0.0190970897675
End reached.0.0158078670502

$ /usr/local/bin/python3.8 ~/test_41299.py | sort
0.009722232818603516
0.017028093338012695
0.017033100128173828
0.017034053802490234
0.017034053802490234
0.017035961151123047
0.017037153244018555
0.017037153244018555
0.01703786849975586
0.017038822174072266
[...]
0.021351099014282227
0.021355152130126953
0.021355152130126953
0.02135610580444336
0.021361112594604492
0.021363258361816406
0.02136397361755371
0.021379947662353516
0.02138543128967285
0.021442890167236328
End reached.

--
nosy: +ned.deily

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Felix Yan

New submission from Felix Yan :

In bpo-40874, mpdecimal.h in the vendored libmpdec has defines of UNUSED while 
the standalone released version of mpdecimal 2.5.0 doesn't. This breaks 
_decimal module build with system libmpdec due to UNUSED is undefined.

Errors are like:

cpython/Modules/_decimal/_decimal.c:277:36: error: expected ‘;’, ‘,’ or ‘)’ 
before ‘UNUSED’
  277 | dec_traphandler(mpd_context_t *ctx UNUSED) /* GCOV_NOT_REACHED */
  |^~

Reproducible in both 3.8 branch and master (didn't test 3.9, but should be 
affected too).

--
components: Extension Modules
messages: 373676
nosy: felixonmars, skrah
priority: normal
severity: normal
status: open
title: _decimal failed to build with system libmpdec 2.5
type: compile error
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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Stefan Krah


Stefan Krah  added the comment:

Thank you for the report, I'll add the define or remove UNUSED in 3.9
and 3.10.


3.8 is still supposed to use libmpdec-2.4.2, though it would be
harmless to use libmpdec-2.5.0.

Are you planning to use libmpdec-2.5.0 with 3.8?

--
assignee:  -> skrah
stage:  -> needs patch
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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Felix Yan


Change by Felix Yan :


--
keywords: +patch
pull_requests: +20624
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/21481

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Felix Yan


Felix Yan  added the comment:

Yes, I am currently defining it manually as a workaround for building 3.8.4 in 
Arch.

Also opened GH-21481 for this :)

--

___
Python tracker 

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



[issue41299] Python3 threading.Event().wait time is twice as large as Python27

2020-07-15 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

I reproduced something similar on Python 3.9.0b1, Windows 64-bit version:

py -m pyperf timeit -s "import threading; E = threading.Event()" 
"E.wait()"

NUMBERMean +- std dev
---
0.0   5.79 us +- 0.13 us
0.000115.6 ms +- 0.1 ms
0.001 15.6 ms +- 0.1 ms
0.01  15.6 ms +- 0.6 ms
0.013 15.5 ms +- 0.6 ms
0.015 15.9 ms +- 0.9 ms
0.016 25.2 ms +- 0.5 ms
0.017 31.2 ms +- 0.2 ms
0.018 31.2 ms +- 0.4 ms
0.025 31.2 ms +- 1.0 ms
0.05  62.2 ms +- 0.8 ms
0.1   109 ms +- 2 ms
0.2   201 ms +- 3 ms
0.5   500 ms +- 0 ms
1.0   1.00 sec +- 0.00 sec

On the smaller scale, it looks quantized to multiples of ~15ms (?), but then it 
gets more accurate as the times get larger. I don't think it's a measurement 
error since the first measurement manages microseconds.

Perhaps this is just an OS-level thread-scheduling issue?

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20627
pull_request: https://github.com/python/cpython/pull/21483

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread Petr Viktorin


Petr Viktorin  added the comment:


New changeset 5a8d121a1f3ef5ad7c105ee378cc79a3eac0c7d4 by Rishi in branch 
'master':
bpo-39017: Avoid infinite loop in the tarfile module (GH-21454)
https://github.com/python/cpython/commit/5a8d121a1f3ef5ad7c105ee378cc79a3eac0c7d4


--
nosy: +petr.viktorin

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 7.0 -> 8.0
pull_requests: +20626
pull_request: https://github.com/python/cpython/pull/21482

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20628
pull_request: https://github.com/python/cpython/pull/21484

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20629
pull_request: https://github.com/python/cpython/pull/21485

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Stefan Krah


Stefan Krah  added the comment:


New changeset 015efdbef7454a522e88cd79ba2b4cd77a5fb2a2 by Felix Yan in branch 
'master':
bpo-41302: Fix build with system libmpdec (GH-21481)
https://github.com/python/cpython/commit/015efdbef7454a522e88cd79ba2b4cd77a5fb2a2


--

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +20630
pull_request: https://github.com/python/cpython/pull/21486

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread Petr Viktorin


Petr Viktorin  added the comment:

Larry and Ned, do you want this fix in the security-only releases you manage?

PRs for 3.6 ad 3.7 are ready, should you wish to merge them.

--
nosy: +larry, ned.deily -miss-islington

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread miss-islington


miss-islington  added the comment:


New changeset c55479556db015f48fc8bbca17f64d3e65598559 by Miss Islington (bot) 
in branch '3.8':
[3.8] bpo-39017: Avoid infinite loop in the tarfile module (GH-21454) (GH-21483)
https://github.com/python/cpython/commit/c55479556db015f48fc8bbca17f64d3e65598559


--

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread miss-islington


miss-islington  added the comment:


New changeset f3232294ee695492f43d424cc6969d018d49861d by Miss Islington (bot) 
in branch '3.9':
[3.9] bpo-39017: Avoid infinite loop in the tarfile module (GH-21454) (GH-21482)
https://github.com/python/cpython/commit/f3232294ee695492f43d424cc6969d018d49861d


--
nosy: +miss-islington

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread Larry Hastings


Larry Hastings  added the comment:

Yes, please.  It's a simple low-risk fix.  And 3.5.10rc1 is stuck waiting for a 
fix anyway.  Thanks!

--

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread Ned Deily


Ned Deily  added the comment:


New changeset 79c6b602efc9a906c8496f3d5f4d54c54b48fa06 by Miss Islington (bot) 
in branch '3.7':
bpo-39017: Avoid infinite loop in the tarfile module (GH-21454) (GH-21484)
https://github.com/python/cpython/commit/79c6b602efc9a906c8496f3d5f4d54c54b48fa06


--

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread Ned Deily


Ned Deily  added the comment:


New changeset 47a2955589bdb1a114d271496ff803ad73f954b8 by Miss Islington (bot) 
in branch '3.6':
bpo-39017: Avoid infinite loop in the tarfile module (GH-21454) (#21485)
https://github.com/python/cpython/commit/47a2955589bdb1a114d271496ff803ad73f954b8


--

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread Ned Deily


Ned Deily  added the comment:

Thanks, the PRs for 3.7 and 3.6 are now merged.

--
versions: +Python 3.10, Python 3.5, Python 3.6, 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



[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-07-15 Thread nooB


New submission from nooB :

Documentation for time.perf_counter says "does include time elapsed during 
sleep".

https://docs.python.org/3.8/library/time.html#time.perf_counter

But it does not work as expected in Mac OS. I learnt that perf_counter uses the 
underlying c function: "mach_absolute_time".

-

import time
time.get_clock_info('perf_counter')
namespace(adjustable=False, implementation='mach_absolute_time()', 
monotonic=True, resolution=1e-09)

-

The documentation for "mach_absolute_time" clearly states that "this clock does 
not increment while the system is asleep"

https://developer.apple.com/documentation/kernel/1462446-mach_absolute_time


FWIW, Mac kernel does offer another function which returns monotonic ticks 
"including while the system is asleep"

https://developer.apple.com/documentation/kernel/1646199-mach_continuous_time

But it seems to be available only on Mac 10.12+.

--
components: macOS
messages: 373690
nosy: ned.deily, nooB, ronaldoussoren
priority: normal
severity: normal
status: open
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-07-15 Thread Ned Deily


Change by Ned Deily :


--
nosy: +belopolsky, p-ganssle, vstinner

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread miss-islington


miss-islington  added the comment:


New changeset 8ca63f95f769c31f65a996fe065ff6dcfb490bbe by Miss Islington (bot) 
in branch '3.9':
bpo-41302: Fix build with system libmpdec (GH-21481)
https://github.com/python/cpython/commit/8ca63f95f769c31f65a996fe065ff6dcfb490bbe


--

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Stefan Krah


Stefan Krah  added the comment:

Thanks for the patch!

The integrated libmpdec-2.4.2 in Python 3.8 still has a couple of
UNUSED, so the simple approach of moving the define would not work.
It would be easy to replace the few instances of UNUSED with void
casts like in 2.5.0.


Strictly speaking though, this would be a feature for 3.8 and not
a build fix.


On the other hand, if Debian also plans to use 2.5.0 with 3.8,
there would be a stronger case for this build feature.

--
nosy: +doko

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Stefan Krah


Change by Stefan Krah :


--
resolution:  -> fixed
stage: patch review -> 
status: open -> pending

___
Python tracker 

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



[issue41285] memoryview does not support subclassing

2020-07-15 Thread Stefan Krah


Stefan Krah  added the comment:

If I understand this correctly, I think this may be a duplicate of #13797.


Something like a __getbuffer__ protocol would be needed. I'm not
saying we *should* go that route, just stating the requirements
from my perspective.

--

___
Python tracker 

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



[issue41299] Python3 threading.Event().wait time is twice as large as Python27

2020-07-15 Thread SD


SD  added the comment:

I have tested this both on vs code terminal and cygwin for windows.

3.8.2 : 

python -m test.pythoninfo
Python debug information


Py_DEBUG: No (sys.gettotalrefcount() missing)
_decimal.__libmpdec_version__: 2.4.2
builtins.float.double_format: IEEE, little-endian
builtins.float.float_format: IEEE, little-endian
datetime.datetime.now: 2020-07-15 09:09:34.936153
expat.EXPAT_VERSION: expat_2.2.8
locale.encoding: cp1252
os.cpu_count: 12
os.environ[APPDATA]: C:\Users\\AppData\Roaming
os.environ[COMPUTERNAME]: 
os.environ[COMSPEC]: C:\Windows\system32\cmd.exe
os.environ[HOMEDRIVE]: C:
os.environ[HOMEPATH]: \Users\
os.environ[LANG]: en_GB.UTF-8
os.environ[PATHEXT]: 
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW;.CPL
os.environ[PATH]: C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v9.2\bin;C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v9.2\libnvvp;C:\Program 
Files\SlikSvn\bin;C:\Python\Python38\Scripts\;C:\Python\Python38\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program
 Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program 
Files\dotnet\;C:\Program Files\TortoiseSVN\bin;C:\Program 
Files\CMake\bin;C:\Program Files (x86)\IncrediBuild;C:\Program Files\NVIDIA 
Corporation\NVIDIA 
NvDLISR;C:\Users\\AppData\Local\Microsoft\WindowsApps;;C:\Users\\AppData\Local\Programs\Microsoft
 VS Code\bin
os.environ[SYSTEMROOT]: C:\Windows
os.environ[TEMP]: C:\Users\\AppData\Local\Temp
os.environ[TMP]: C:\Users\\AppData\Local\Temp
os.environ[USERPROFILE]: C:\Users\
os.environ[WINDIR]: C:\Windows
os.getcwd: 
os.login: 
os.name: nt
os.supports_bytes_environ: False
os.supports_effective_ids: []
os.supports_fd: ['stat', 'truncate']
os.supports_follow_symlinks: ['stat']
os.umask: 000
platform.architecture: 64bit WindowsPE
platform.platform: Windows-10-10.0.18362-SP0
platform.python_implementation: CPython
pymem.allocator: pymalloc
pymem.with_pymalloc: True
socket.hostname: 
sqlite3.sqlite_version: 3.28.0
sqlite3.version: 2.6.0
ssl.HAS_SNI: True
ssl.OPENSSL_VERSION: OpenSSL 1.1.1d  10 Sep 2019
ssl.OPENSSL_VERSION_INFO: (1, 1, 1, 4, 15)
ssl.OP_ALL: -0x7fac
ssl.OP_NO_TLSv1_1: 0x1000
ssl.SSLContext.maximum_version: TLSVersion.MAXIMUM_SUPPORTED
ssl.SSLContext.minimum_version: TLSVersion.MINIMUM_SUPPORTED
ssl.SSLContext.options: 
Options.OP_NO_SSLv3|OP_CIPHER_SERVER_PREFERENCE|OP_ENABLE_MIDDLEBOX_COMPAT|OP_NO_COMPRESSION|OP_ALL
ssl.SSLContext.protocol: _SSLMethod.PROTOCOL_TLS
ssl.SSLContext.verify_mode: VerifyMode.CERT_NONE
ssl.default_https_context.maximum_version: TLSVersion.MAXIMUM_SUPPORTED
ssl.default_https_context.minimum_version: TLSVersion.MINIMUM_SUPPORTED
ssl.default_https_context.options: 
Options.OP_NO_SSLv3|OP_CIPHER_SERVER_PREFERENCE|OP_ENABLE_MIDDLEBOX_COMPAT|OP_NO_COMPRESSION|OP_ALL
ssl.default_https_context.protocol: _SSLMethod.PROTOCOL_TLS
ssl.default_https_context.verify_mode: VerifyMode.CERT_REQUIRED
ssl.stdlib_context.maximum_version: TLSVersion.MAXIMUM_SUPPORTED
ssl.stdlib_context.minimum_version: TLSVersion.MINIMUM_SUPPORTED
ssl.stdlib_context.options: 
Options.OP_NO_SSLv3|OP_CIPHER_SERVER_PREFERENCE|OP_ENABLE_MIDDLEBOX_COMPAT|OP_NO_COMPRESSION|OP_ALL
ssl.stdlib_context.protocol: _SSLMethod.PROTOCOL_TLS
ssl.stdlib_context.verify_mode: VerifyMode.CERT_NONE
subprocess._USE_POSIX_SPAWN: False
sys.api_version: 1013
sys.builtin_module_names: ('_abc', '_ast', '_bisect', '_blake2', '_codecs', 
'_codecs_cn', '_codecs_hk', '_codecs_iso2022', '_codecs_jp', '_codecs_kr', 
'_codecs_tw', '_collections', '_contextvars', '_csv', '_datetime', 
'_functools', '_heapq', '_imp', '_io', '_json', '_locale', '_lsprof', '_md5', 
'_multibytecodec', '_opcode', '_operator', '_pickle', '_random', '_sha1', 
'_sha256', '_sha3', '_sha512', '_signal', '_sre', '_stat', '_statistics', 
'_string', '_struct', '_symtable', '_thread', '_tracemalloc', '_warnings', 
'_weakref', '_winapi', '_xxsubinterpreters', 'array', 'atexit', 'audioop', 
'binascii', 'builtins', 'cmath', 'errno', 'faulthandler', 'gc', 'itertools', 
'marshal', 'math', 'mmap', 'msvcrt', 'nt', 'parser', 'sys', 'time', 'winreg', 
'xxsubtype', 'zlib')
sys.byteorder: little
sys.dont_write_bytecode: False
sys.executable: C:\Python\Python38\python.exe
sys.filesystem_encoding: utf-8/surrogatepass
sys.flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, 
dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, 
verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0, 
dev_mode=False, utf8_mode=0)
sys.float_info: sys.float_info(max=1.7976931348623157e+308, max_exp=1024, 
max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, 
dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
sys.float_repr_style: short
sys.hash_info: sys.hash_info(width=64, modulus=2305843009213693951, inf=314159, 
nan=0, imag=103, algor

[issue41299] Python3 threading.Event().wait time is twice as large as Python27

2020-07-15 Thread Ned Deily


Ned Deily  added the comment:

Thanks for the version info.

Windows and/or threading experts: any ideas?

--
components: +Library (Lib), Windows
nosy: +paul.moore, pitrou, steve.dower, tim.golden, zach.ware

___
Python tracker 

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-15 Thread Jonas Schäfer

Change by Jonas Schäfer :


--
nosy: +jssfr

___
Python tracker 

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



[issue41291] Race conditions when opening and deleting a file on Mac OS X

2020-07-15 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

I've attached a variation on test-conc-read.py that uses os.open and low-level 
APIs instead of the Python IO stack (open/io.open).  This fails in the same way.

os.open/os.read/os.write/os.close are very thin wrappers around the 
corresponding C APIs. That clearly indicates that there is a bug in the OS.

--
Added file: https://bugs.python.org/file49318/test-conc-read2.py

___
Python tracker 

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



[issue41285] memoryview does not support subclassing

2020-07-15 Thread Michiel de Hoon


Michiel de Hoon  added the comment:

You are correct, this is indeed a duplicate of #13797. My apologies for not 
finding this issue before opening a new one. If there are no objections, I will 
close this issue as a duplicate.

--

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file

2020-07-15 Thread Jimmy Girardet


New submission from Jimmy Girardet :

Hi,
With python embed unziped in `38` directory(python 3.8.4):

```
# python38._pth
python38.zip
.
..\\app
# Uncomment to run site.main() automatically
#import site
```

```
PS C:\Users\jimmy\rien\embed> .\38\python.exe -c "import 
sys;print(sys.path);import hello"
['', 'C:\\Users\\jimmy\\rien\\embed\\38\\python38.zip', 
'C:\\Users\\jimmy\\rien\\embed\\38\\DLLs', 'C:\\Users\\jimmy\\ri
en\\embed\\38\\lib', 'C:\\Users\\jimmy\\rien\\embed\\38']
Traceback (most recent call last):
  File "", line 1, in 
ModuleNotFoundError: No module named 'hello'


'\\app' is not added to sys.path. it is under python 3.
```

Note It's working under python 3.7.8

--
components: Interpreter Core
messages: 373698
nosy: jgirardet
priority: normal
severity: normal
status: open
title: python 38 embed ignore python38._pth file
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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread Jimmy Girardet


Change by Jimmy Girardet :


--
title: python 38 embed ignore python38._pth file -> python 38 embed ignore 
python38._pth file on windows

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Felix Yan


Change by Felix Yan :


--
pull_requests: +20631
status: pending -> open
pull_request: https://github.com/python/cpython/pull/21488

___
Python tracker 

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



[issue41271] Add support for io_uring to cpython

2020-07-15 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

How stable is the io_uring API?

The stdlib evolves slowly, I'm not sure if the io_uring interface has matured 
enough to make it acceptable that updates to the stdlib bindings for that API 
are only done in new major releases of CPython (about every 18 months). 

It is probably better to create a PyPI package for this API. This package can 
then also provide an asyncio eventloop implementation.

--
nosy: +ronaldoussoren

___
Python tracker 

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



[issue41291] Race conditions when opening and deleting a file on Mac OS X

2020-07-15 Thread Ned Deily

Ned Deily  added the comment:

I was able to easily reproduce it as well. I suppose we all tested on very fast 
SSD-based APFS file systems.  I wonder if the problem might be file system 
related. I wasn’t able to reproduce it using a HDD-based HFS+ file system but 
it might just be due to the speed difference. In any case, I agree it’s up to 
Apple to resolve. Let us know when you hear something back from Apple.

--
resolution:  -> third party
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



[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread Petr Viktorin


Change by Petr Viktorin :


--
pull_requests: +20632
pull_request: https://github.com/python/cpython/pull/21489

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread Jimmy Girardet


Jimmy Girardet  added the comment:

replacing python38._pth by python._pth does fix it.

--

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-15 Thread Tony


New submission from Tony :

Add a StreamReader.readinto(buf) function.

Exactly like StreamReader.read() with *n* being equal to the length of buf.

Instead of allocating a new buffer, copy the read buffer into buf.

--
messages: 373702
nosy: tontinton
priority: normal
severity: normal
status: open
title: Add StreamReader.readinto()

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-15 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
components: +asyncio
nosy: +asvetlov, yselivanov
type:  -> enhancement
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



[issue23860] Windows: Failure to check return value from lseek() in Modules/mmapmodule.c

2020-07-15 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
versions: +Python 3.10 -Python 3.8

___
Python tracker 

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



[issue41271] Add support for io_uring to cpython

2020-07-15 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

I agree that adding stdlib support is premature. io_uring has a large and 
growing API surface. It will take some experimentation to see what the best way 
to expose its power to Python is.

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue41285] memoryview does not support subclassing

2020-07-15 Thread Stefan Krah


Stefan Krah  added the comment:

Yes, let's make #13797 a superseder.

--

___
Python tracker 

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



[issue41271] Add support for io_uring to cpython

2020-07-15 Thread Cooper Lees


Cooper Lees  added the comment:

Totally agree with a separate module first to POC. I should have stated that. 
Main goal was to open this issue to start discussions :)

--

___
Python tracker 

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



[issue41285] memoryview does not support subclassing

2020-07-15 Thread Stefan Krah


Change by Stefan Krah :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Allow objects implemented in pure Python to export PEP 3118 
buffers

___
Python tracker 

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



[issue41279] Convert StreamReaderProtocol to a BufferedProtocol

2020-07-15 Thread Tony


Change by Tony :


--
pull_requests: +20633
pull_request: https://github.com/python/cpython/pull/21491

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-15 Thread Tony


Change by Tony :


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

___
Python tracker 

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



[issue33007] Objects referencing private-mangled names do not roundtrip properly under pickling.

2020-07-15 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +serhiy.storchaka
versions: +Python 3.10 -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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread Steve Dower


Steve Dower  added the comment:

Thanks, this is a regression.

https://github.com/python/cpython/blob/master/PC/getpathp.c#L672 should be 
inverted, as a zero return value indicates success.

--
keywords: +3.8regression
versions: +Python 3.10, Python 3.7, Python 3.9

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread Steve Dower


Change by Steve Dower :


--
stage:  -> test needed
type:  -> security

___
Python tracker 

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



[issue41299] Python3 threading.Event().wait time is twice as large as Python27

2020-07-15 Thread Steve Dower


Steve Dower  added the comment:

At a guess, it's probably the signal emulation (a.k.a. Ctrl+C support). We 
could save some time by checking the requested handle first without blocking, 
and only beginning the blocking call if it's not available.

--

___
Python tracker 

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



[issue40150] (minor) mismatched argument in overlapped_RegisterWaitWithQueue call to RegisterWaitForSingleObject

2020-07-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset af4eda46d1538b1da700a86588bdb94b0a4d1ff2 by Zackery Spytz in 
branch 'master':
bpo-40150: Fix mismatched argument in RegisterWaitForSingleObject() call 
(GH-19686)
https://github.com/python/cpython/commit/af4eda46d1538b1da700a86588bdb94b0a4d1ff2


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue40150] (minor) mismatched argument in overlapped_RegisterWaitWithQueue call to RegisterWaitForSingleObject

2020-07-15 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +20635
pull_request: https://github.com/python/cpython/pull/21493

___
Python tracker 

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



[issue40150] (minor) mismatched argument in overlapped_RegisterWaitWithQueue call to RegisterWaitForSingleObject

2020-07-15 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20636
pull_request: https://github.com/python/cpython/pull/21494

___
Python tracker 

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



[issue41291] Race conditions when opening and deleting a file on Mac OS X

2020-07-15 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

This appears to be a bug in the APFS filesystem implementation.

On my machine:
- main disk (SSD, APFS): race condition happens
- r/w disk image with APFS: race condition happens
- r/w disk image with HFS+: no race condition

--

___
Python tracker 

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



[issue41306] test_tk failure on Arch Linux

2020-07-15 Thread Felix Yan


New submission from Felix Yan :

test_from (tkinter.test.test_tkinter.test_widgets.ScaleTest) is currently 
failing on Arch Linux, and at least another place: 
https://python-build-standalone.readthedocs.io/en/latest/status.html

The error looks like:

==
FAIL: test_from (tkinter.test.test_tkinter.test_widgets.ScaleTest)
--
Traceback (most recent call last):
  File "/usr/lib/python3.8/tkinter/test/test_tkinter/test_widgets.py", line 
939, in test_from
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=float_round)
  File "/usr/lib/python3.8/tkinter/test/widget_tests.py", line 106, in 
checkFloatParam
self.checkParam(widget, name, value, conv=conv, **kwargs)
  File "/usr/lib/python3.8/tkinter/test/widget_tests.py", line 64, in checkParam
self.assertEqual2(widget.cget(name), expected, eq=eq)
  File "/usr/lib/python3.8/tkinter/test/widget_tests.py", line 47, in 
assertEqual2
self.assertEqual(actual, expected, msg)
AssertionError: 14.9 != 15.0

It's the only failure in the current Python 3.8.4 release's test suite here. 
Also adding Python 3.9 and 3.10 as I am able to reproduce it on master too.

--
components: Tests
messages: 373710
nosy: felixonmars
priority: normal
severity: normal
status: open
title: test_tk failure on Arch Linux
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



[issue41307] "email.message.Message.as_bytes": fails to correctly handle "charset"

2020-07-15 Thread Dieter Maurer

New submission from Dieter Maurer :

In the transscript below, "ms" and "mb" should be equivalent:

>>> from email import message_from_string, message_from_bytes
>>> mt = """\
... Mime-Version: 1.0
... Content-Type: text/plain; charset=UTF-8
... Content-Transfer-Encoding: 8bit
... 
... ä
... """
>>> ms = message_from_string(mt)
>>> mb = message_from_bytes(mt.encode("UTF-8"))

But "mb.as_bytes" succeeds while "ms.as_bytes" raises a "UnicodeEncodeError":

>>> mb.as_bytes()
b'Mime-Version: 1.0\nContent-Type: text/plain; 
charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\n\xc3\xa4\n'
>>> ms.as_bytes()
Traceback (most recent call last):
...
  File "/usr/local/lib/python3.9/email/generator.py", line 155, in _write_lines
self.write(line)
  File "/usr/local/lib/python3.9/email/generator.py", line 406, in write
self._fp.write(s.encode('ascii', 'surrogateescape'))
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 0: 
ordinal not in range(128)

Apparently, the "as_bytes" ignores the "charset" parameter from the 
"Content-Type" header (it should use "utf-8", not "ascii" for the encoding).

--
components: email
messages: 373711
nosy: barry, dmaurer, r.david.murray
priority: normal
severity: normal
status: open
title: "email.message.Message.as_bytes":  fails to correctly handle "charset"
type: behavior
versions: Python 3.9

___
Python tracker 

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



[issue40150] (minor) mismatched argument in overlapped_RegisterWaitWithQueue call to RegisterWaitForSingleObject

2020-07-15 Thread miss-islington


miss-islington  added the comment:


New changeset f8055fb0f1054fce6a21047da39b92ae32416b80 by Miss Islington (bot) 
in branch '3.8':
bpo-40150: Fix mismatched argument in RegisterWaitForSingleObject() call 
(GH-19686)
https://github.com/python/cpython/commit/f8055fb0f1054fce6a21047da39b92ae32416b80


--

___
Python tracker 

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



[issue40150] (minor) mismatched argument in overlapped_RegisterWaitWithQueue call to RegisterWaitForSingleObject

2020-07-15 Thread miss-islington


miss-islington  added the comment:


New changeset 4a02da4f95cfff679e38a13ca0f44d660c5669b5 by Miss Islington (bot) 
in branch '3.9':
bpo-40150: Fix mismatched argument in RegisterWaitForSingleObject() call 
(GH-19686)
https://github.com/python/cpython/commit/4a02da4f95cfff679e38a13ca0f44d660c5669b5


--

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread Steve Dower


Change by Steve Dower :


--
keywords: +patch
pull_requests: +20637
stage: test needed -> patch review
pull_request: https://github.com/python/cpython/pull/21495

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-15 Thread Yury Selivanov


Yury Selivanov  added the comment:

We don't want to extend StreamReader with new APIs as ultimately we plan to 
deprecate it. A new streams API is needed, perhaps inspired by Trio. Sadly, I'm 
-1 on this one.

--

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-15 Thread Richard Sheridan


Richard Sheridan  added the comment:

I stumbled into this in another project and I want to +1 the uncommenting 
solution. The problem occurs on __del__ rather than specifically in the gc 
somewhere (it happens when refs drop to zero too), so I wouldn't worry too much 
about killing the garbage collector.

It also looks like fixing the python part would be about 3 lines of 
non-user-facing code with weakrefs. Are you sure that's no-go?

Would it be any help to roll this fix into https://bugs.python.org/issue41176 
and https://github.com/python/cpython/pull/21299 since we fixed the quit() docs 
there?

--
nosy: +Richard Sheridan

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-15 Thread Richard Sheridan


Richard Sheridan  added the comment:

I stumbled into this in another project and I want to +1 the uncommenting 
solution. The problem occurs on __del__ rather than specifically in the gc 
somewhere (it happens when refs drop to zero too), so I wouldn't worry too much 
about killing the garbage collector.

It also looks like fixing the python part would be about 3 lines of 
non-user-facing code with weakrefs. Are you sure that's no-go?

Would it be any help to roll this fix into https://bugs.python.org/issue41176 
and https://github.com/python/cpython/pull/21299 since we fixed the quit() docs 
there?

--
nosy: +Richard Sheridan

___
Python tracker 

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



[issue40150] (minor) mismatched argument in overlapped_RegisterWaitWithQueue call to RegisterWaitForSingleObject

2020-07-15 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.7, Python 3.8

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-15 Thread Richard Sheridan


Richard Sheridan  added the comment:

I stumbled into this in another project and I want to +1 the uncommenting 
solution. The problem occurs on __del__ rather than specifically in the gc 
somewhere (it happens when refs drop to zero too), so I wouldn't worry too much 
about killing the garbage collector.

It also looks like fixing the python part would be about 3 lines of 
non-user-facing code with weakrefs. Are you sure that's no-go?

Would it be any help to roll this fix into https://bugs.python.org/issue41176 
and https://github.com/python/cpython/pull/21299 since we fixed the quit() docs 
there?

--
nosy: +Richard Sheridan

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-15 Thread Richard Sheridan


Richard Sheridan  added the comment:

I stumbled into this in another project and I want to +1 the uncommenting 
solution. The problem occurs on __del__ rather than specifically in the gc 
somewhere (it happens when refs drop to zero too), so I wouldn't worry too much 
about killing the garbage collector.

It also looks like fixing the python part would be about 3 lines of 
non-user-facing code with weakrefs. Are you sure that's no-go?

Would it be any help to roll this fix into https://bugs.python.org/issue41176 
and https://github.com/python/cpython/pull/21299 since we fixed the quit() docs 
there?

--
nosy: +Richard Sheridan

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-15 Thread Tony


Tony  added the comment:

ok.

Im interested in learning about the new api.
Is it documented somewhere?

--

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-15 Thread Tony


Tony  added the comment:

Ah it's trio...

--

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Stefan Krah


Stefan Krah  added the comment:

I'm going to reclassify this as a build fix for 3.8. 3.8 promises:

#if !defined(MPD_VERSION_HEX) || MPD_VERSION_HEX < 0x02040100
  #error "libmpdec version >= 2.4.1 required"
#endif

So it seems reasonable to support at least two or three consecutive
system libmpdec versions, otherwise the >= is pointless.

--

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Stefan Krah


Stefan Krah  added the comment:


New changeset 16eea45fbd3b7c3d1b222b7eb7a5d7ee427f70bd by Felix Yan in branch 
'3.8':
[3.8] bpo-41302: Support system libmpdec 2.5 for Python 3.8 (GH-21488)
https://github.com/python/cpython/commit/16eea45fbd3b7c3d1b222b7eb7a5d7ee427f70bd


--

___
Python tracker 

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Stefan Krah


Stefan Krah  added the comment:

Closing, thanks for all the patches!

--
stage:  -> resolved
status: open -> closed
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



[issue41307] "email.message.Message.as_bytes": fails to correctly handle "charset"

2020-07-15 Thread Dieter Maurer


Dieter Maurer  added the comment:

The following fixes the example:
from copy import copy
from io import BytesIO
from email.message import Message
from email.generator import BytesGenerator, _has_surrogates
from email._policybase import Compat32


class FixedBytesGenerator(BytesGenerator):
def _handle_text(self, msg):
payload = msg._payload
if payload is None:
return
charset = msg.get_param("charset")
if charset is not None \
   and not self.policy.cte_type=='7bit' \
   and not _has_surrogates(payload):
msg = copy(msg)
msg._payload = payload.encode(charset).decode(
"ascii", "surrogateescape")
super()._handle_text(msg)

_writeBody = _handle_text


class FixedMessage(Message):
def as_bytes(self, unixfrom=False, policy=None):
policy = self.policy if policy is None else policy
fp = BytesIO()
g = FixedBytesGenerator(fp, mangle_from_=False, policy=policy)
g.flatten(self, unixfrom=unixfrom)
return fp.getvalue()


fixed_policy = Compat32(message_factory=FixedMessage)

ms = message_from_string(mt, policy=fixed_policy)
ms.as_bytes()

--

___
Python tracker 

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



[issue41308] socket.connect() slow to time out on Windows

2020-07-15 Thread Steve Dower


New submission from Steve Dower :

When connecting to localhost, socket.connect() takes two seconds on Windows 
(the default) to time out, but on Linux (including WSL) it times out 
immediately.

Test code (assuming port  has no listener):
>>> import socket
>>> socket.socket().connect(('localhost', ))

For a remote host, the timeout is approx 10s on Windows and 20s on WSL (I 
didn't test on a native Linux box).

I'm told the correct fix is to specify TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS 
[1] when connecting to localhost.

--
components: Windows
messages: 373725
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
stage: test needed
status: open
title: socket.connect() slow to time out on Windows
type: performance
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



[issue41309] test_subprocess timing out randomly on Windows

2020-07-15 Thread Steve Dower


New submission from Steve Dower :

Spotted at 
https://dev.azure.com/Python/cpython/_build/results?buildId=66387&view=logs&j=d554cd63-f8f4-5b2d-871b-33e4ea76e915&t=5a14d0eb-dbd4-5b80-f5d0-7909f950a1cc&l=1859

test_empty_input (test.test_asyncio.test_subprocess.SubprocessProactorTests) 
... ok
test_exec_loop_deprecated 
(test.test_asyncio.test_subprocess.SubprocessProactorTests) ... ok
test_kill (test.test_asyncio.test_subprocess.SubprocessProactorTests) ... ok
Warning -- Unraisable exception
Warning -- Unraisable exception
Timeout (0:20:00)!
Thread 0x1eac (most recent call first):
  File "D:\a\1\s\lib\asyncio\windows_events.py", line 779 in _poll
  File "D:\a\1\s\lib\asyncio\windows_events.py", line 430 in select
  File "D:\a\1\s\lib\asyncio\base_events.py", line 1854 in _run_once
  File "D:\a\1\s\lib\asyncio\base_events.py", line 596 in run_forever
  File "D:\a\1\s\lib\asyncio\windows_events.py", line 316 in run_forever
  File "D:\a\1\s\lib\asyncio\base_events.py", line 629 in run_until_complete
  File "D:\a\1\s\lib\test\test_asyncio\test_subprocess.py", line 302 in 
test_pause_reading
  File "D:\a\1\s\lib\unittest\case.py", line 549 in _callTestMethod
  File "D:\a\1\s\lib\unittest\case.py", line 592 in run
  File "D:\a\1\s\lib\unittest\case.py", line 652 in __call__
  File "D:\a\1\s\lib\unittest\suite.py", line 122 in run
  File "D:\a\1\s\lib\unittest\suite.py", line 84 in __call__
  File "D:\a\1\s\lib\unittest\suite.py", line 122 in run
  File "D:\a\1\s\lib\unittest\suite.py", line 84 in __call__
  File "D:\a\1\s\lib\unittest\suite.py", line 122 in run
  File "D:\a\1\s\lib\unittest\suite.py", line 84 in __call__
  File "D:\a\1\s\lib\unittest\suite.py", line 122 in run
  File "D:\a\1\s\lib\unittest\suite.py", line 84 in __call__
  File "D:\a\1\s\lib\unittest\suite.py", line 122 in run
  File "D:\a\1\s\lib\unittest\suite.py", line 84 in __call__
  File "D:\a\1\s\lib\unittest\runner.py", line 176 in run
  File "D:\a\1\s\lib\test\support\__init__.py", line 975 in _run_suite
  File "D:\a\1\s\lib\test\support\__init__.py", line 1098 in run_unittest
  File "D:\a\1\s\lib\test\libregrtest\runtest.py", line 211 in _test_module
  File "D:\a\1\s\lib\test\libregrtest\runtest.py", line 236 in _runtest_inner2
  File "D:\a\1\s\lib\test\libregrtest\runtest.py", line 272 in _runtest_inner
  File "D:\a\1\s\lib\test\libregrtest\runtest.py", line 155 in _runtest
  File "D:\a\1\s\lib\test\libregrtest\runtest.py", line 195 in runtest
  File "D:\a\1\s\lib\test\libregrtest\main.py", line 319 in rerun_failed_tests
  File "D:\a\1\s\lib\test\libregrtest\main.py", line 696 in _main
  File "D:\a\1\s\lib\test\libregrtest\main.py", line 639 in main
  File "D:\a\1\s\lib\test\libregrtest\main.py", line 717 in main
  File "D:\a\1\s\lib\test\__main__.py", line 2 in 
  File "D:\a\1\s\lib\runpy.py", line 87 in _run_code
  File "D:\a\1\s\lib\runpy.py", line 197 in _run_module_as_main
##[error]Cmd.exe exited with code '1'.

--
components: Tests, Windows
messages: 373726
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: test_subprocess timing out randomly on Windows
type: crash
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



[issue41309] test_subprocess timing out randomly on Windows

2020-07-15 Thread Steve Dower


Change by Steve Dower :


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

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread Steve Dower


Steve Dower  added the comment:


New changeset 936a66094591dc0e67d4a60c170148bb700ec016 by Steve Dower in branch 
'master':
bpo-41304: Ensure python3x._pth is loaded on Windows (GH-21495)
https://github.com/python/cpython/commit/936a66094591dc0e67d4a60c170148bb700ec016


--

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +20639
pull_request: https://github.com/python/cpython/pull/21497

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20640
pull_request: https://github.com/python/cpython/pull/21498

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread Steve Dower


Change by Steve Dower :


--
pull_requests: +20641
pull_request: https://github.com/python/cpython/pull/21499

___
Python tracker 

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



[issue41309] test_subprocess.test_pause_reading timing out randomly on Windows

2020-07-15 Thread Steve Dower


Change by Steve Dower :


--
title: test_subprocess timing out randomly on Windows -> 
test_subprocess.test_pause_reading timing out randomly on Windows

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread miss-islington


miss-islington  added the comment:


New changeset 28e93dd2b26c460424acbebd00d8b943abbbea17 by Miss Islington (bot) 
in branch '3.9':
bpo-41304: Ensure python3x._pth is loaded on Windows (GH-21495)
https://github.com/python/cpython/commit/28e93dd2b26c460424acbebd00d8b943abbbea17


--

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread miss-islington


miss-islington  added the comment:


New changeset 3b6a8d2455c6897085f4277737b0f9b9a3847c24 by Miss Islington (bot) 
in branch '3.8':
bpo-41304: Ensure python3x._pth is loaded on Windows (GH-21495)
https://github.com/python/cpython/commit/3b6a8d2455c6897085f4277737b0f9b9a3847c24


--

___
Python tracker 

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



[issue41310] micro-optimization: increase our float parsing speed by Nx

2020-07-15 Thread Gregory P. Smith


New submission from Gregory P. Smith :

See https://lemire.me/blog/2020/03/10/fast-float-parsing-in-practice/ for 
inspiration and a reference (possibly a library to use, but if not the 
techniques still apply).

Primarily usable when creating the float objects from the string data as is 
common in python code and particularly common in JSON serialized data.

--
components: Interpreter Core
messages: 373730
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: micro-optimization: increase our float parsing speed by Nx
type: enhancement
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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-15 Thread Ned Deily


Ned Deily  added the comment:


New changeset 4bfcffe16e9742c154f54ae96b5b36903500abaa by Steve Dower in branch 
'3.7':
bpo-41304: Ensure python3x._pth is loaded on Windows (GH-21495) (#21499)
https://github.com/python/cpython/commit/4bfcffe16e9742c154f54ae96b5b36903500abaa


--
nosy: +ned.deily

___
Python tracker 

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



[issue41310] micro-optimization: increase our float parsing speed by Nx

2020-07-15 Thread Eric V. Smith


Change by Eric V. Smith :


--
nosy: +eric.smith, mark.dickinson

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-15 Thread Yury Selivanov


Yury Selivanov  added the comment:

> Im interested in learning about the new api.

There are two problems with the current API:

1. Reader and writer are separate objects, while they should be one.
2. Writer.write is not a coroutine, although it should be one.

There are other minor nits, but that's the crux of the problem. So we need a 
new streams design + a new set of APIs to work with it (and streams are in many 
places, like in the subprocess APIs).

Trio was going to stabilize their own streaming API and we thought it would be 
great if our new API was compatible with it (not sure if they did stabilize it 
or not).

I was going to lead the project myself (and still am) but dropped the ball and 
we missed 3.9 to do this. If you want to start working on this I'd be glad to 
assist with discussions & reviews.

--

___
Python tracker 

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



[issue41311] Add a function to get a random sample from an iterable (reservoir sampling)

2020-07-15 Thread Oscar Benjamin

New submission from Oscar Benjamin :

The random.choice/random.sample functions will only accept a sequence to select 
from. Can there be a function in the random module for selecting from an 
arbitrary iterable?

It is possible to make an efficient function that can make random selections 
from an arbitrary iterable e.g.:


from math import exp, log, floor
from random import random, randrange
from itertools import islice

def sample_iter(iterable, k=1):
"""Select k items uniformly from iterable.

Returns the whole population if there are k or fewer items
"""
iterator = iter(iterable)
values = list(islice(iterator, k))

W = exp(log(random())/k)
while True:
# skip is geometrically distributed
skip = floor( log(random())/log(1-W) )
selection = list(islice(iterator, skip, skip+1))
if selection:
values[randrange(k)] = selection[0]
W *= exp(log(random())/k)
else:
return values


https://en.wikipedia.org/wiki/Reservoir_sampling#An_optimal_algorithm


This could be used for random sampling from sets/dicts or also to choose 
something like a random line from a text file. The algorithm needs to fully 
consume the iterable but does so efficiently using islice. In the case of a 
dict this is faster than converting to a list and using random.choice:


In [2]: n = 6

In [3]: d = dict(zip(range(10**n), range(10**n)))

In [4]: %timeit sample_iter(d)
15.5 ms ± 326 µs per loop (mean ± std. dev. of 7 runs, 100 loops each

In [5]: %timeit list(d)
26.1 ms ± 1.72 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [6]: %timeit sample_iter(d, 2)
15.8 ms ± 427 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

In [7]: %timeit sample_iter(d, 20)
17.6 ms ± 2.17 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [8]: %timeit sample_iter(d, 100)
19.9 ms ± 297 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)


This was already discussed on python-ideas:
https://mail.python.org/archives/list/python-id...@python.org/thread/4OZTRD7FLXXZ6R6RU4BME6DYR3AXHOBD/

--
components: Library (Lib)
messages: 373733
nosy: oscarbenjamin
priority: normal
severity: normal
status: open
title: Add a function to get a random sample from an iterable (reservoir 
sampling)

___
Python tracker 

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



[issue41271] Add support for io_uring to cpython

2020-07-15 Thread Ammar Askar


Ammar Askar  added the comment:

See also: https://github.com/python-trio/trio/issues/932 which contains a link 
to a library with cffi bindings to io_uring

--
nosy: +ammar2

___
Python tracker 

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



[issue41286] Built-in platform module does not offer to check for processor instructions

2020-07-15 Thread Ammar Askar


Ammar Askar  added the comment:

Your best bet then is probably using a library built for this purpose like 
https://github.com/workhorsy/py-cpuinfo

Like Christian said, exposing this information in the standard library would be 
a fairly large maintenance burden for a feature that can't really be actioned 
upon from pure Python code.

--
nosy: +ammar2

___
Python tracker 

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



[issue41283] The parameter name for imghdr.what in the documentation is wrong

2020-07-15 Thread Ammar Askar


Change by Ammar Askar :


--
keywords: +patch
nosy: +ammar2
nosy_count: 2.0 -> 3.0
pull_requests: +20642
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21501

___
Python tracker 

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



[issue41271] Add support for io_uring to cpython

2020-07-15 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue41299] Python3 threading.Event().wait time is twice as large as Python27

2020-07-15 Thread Eryk Sun


Eryk Sun  added the comment:

> On the smaller scale, it looks quantized to multiples of ~15ms (?), 
> but then it gets more accurate as the times get larger. I don't 
> think it's a measurement error since the first measurement manages
> microseconds.

NT's default system timer resolution for thread dispatching is 15.625 ms. If a 
wait is for 17 ms, expect to see actual wait times mostly in the range 17 ms up 
to 31.25 ms. A few outliers may wait longer because the due time on the kernel 
wait is when the thread is ready to be dispatched, but other threads may 
preempt it.

The system timer resolution can be increased to about 1 ms (or 500 us with the 
undocumented NtSetSystemTime system call). But stricter timing still requires 
combining a dispatcher wait for long course-grained waits with a 
performance-counter busy wait for short precise waits.

---

But something else is also involved here. I lowered the system timer resolution 
to 1 ms, and this allowed time.sleep(0.017) to wait for 17-18 ms in about 95% 
of cases. But the wait for acquiring a _thread.lock stubbornly refused to 
cooperate. Ultimately it's just calling WaitForSingleObjectEx on a semaphore, 
so I used ctypes to make a simple alternative lock via CreateSemaphoreW, 
ReleaseSemaphore, and WaitForSingleObject. This simple implementation performed 
exactly like the time.sleep wait with regard to the system timer resolution, so 
the difference is in the _thread.lock wait. I traced it to the following code 
in EnterNonRecursiveMutex in Python/thread_nt.h:

/* wait at least until the target */
ULONGLONG now, target = GetTickCount64() + milliseconds;
while (mutex->locked) {
if (PyCOND_TIMEDWAIT(&mutex->cv, &mutex->cs, (long 
long)milliseconds*1000) < 0) {
result = WAIT_FAILED;
break;
}
now = GetTickCount64();
if (target <= now)
break;
milliseconds = (DWORD)(target-now);
}

GetTickCount64 is documented to be "limited to the resolution of the system 
timer", but what they don't say is that changing the resolution of the system 
timer has no effect on the minimum increment of the tick count. It still 
increments by 15-16 ms even if the system timer resolution is set to 1 ms. 

OTOH, the value of QueryInterruptTime [1] and QueryUnbiasedInterruptTime [2] is 
incremented with the timer interrupt. The biased version [1] is preferred for 
long waits that may straddle a system sleep or hibernate, but it's only 
available in Windows 10. I patched EnterNonRecursiveMutex to call 
QueryInterruptTime instead of GetTickCount64, and this did enable increased 
precision when waiting on a lock. For example (patched behavior):

>>> lock = _thread.allocate_lock()
>>> lock.acquire()
True
>>> setup = 'from __main__ import lock'
>>> stmt = 'lock.acquire(True, 0.017)'

15.625 ms system timer:

>>> timeit.timeit(stmt, setup, number=1000)
30.17371359985

1 ms system timer:

>>> with set_timer_resolution(0.001):
... timeit.timeit(stmt, setup, number=1000)
...
17.6682804998

That said, increasing the timer resolution is discouraged in most cases, so  we 
may simply document that lock waits are limited to the default system timer 
resolution of 15.625 ms, and increasing the system timer resolution has no 
effect on this limit.

[1]: 
https://docs.microsoft.com/en-us/windows/win32/api/realtimeapiset/nf-realtimeapiset-queryinterrupttime
[2]: 
https://docs.microsoft.com/en-us/windows/win32/api/realtimeapiset/nf-realtimeapiset-queryunbiasedinterrupttime

---

Note that this is unrelated to cancel support via Ctrl+C. Windows Python has no 
support for canceling a wait on a _thread.lock. It's just a single-object wait 
in _PyCOND_WAIT_MS, not a multiple-object wait that we set up to include the 
SIGINT event when called on the main thread (or a variant that I like, which 
queues a user APC to the main thread for SIGINT instead of using an event, and 
switches to using alertable waits with SleepEx, WaitForSingleObjectEx, and 
without needing a wait slot in WaitForMultipleObjectsEx). It's possible to 
implement a Ctrl+C cancel as long as the lock implementation waits on a kernel 
semaphore object. However, some effort has gone into developing a different 
implementation based on condition variables and SRW locks. I don't know whether 
there's a way to cancel SleepConditionVariableSRW, or whether maybe a different 
implementation could be used for _thread.lock instead of sharing an 
implementation with the GIL.

--
nosy: +eryksun

___
Python tracker 

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



  1   2   >