[issue46752] Introduce task groups to asyncio and change task cancellation semantics

2022-02-17 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset d85121660ea50bbe8fbd31797aa6e4afe0850388 by Guido van Rossum in 
branch 'main':
bpo-46752: Slight improvements to TaskGroup API (GH-31398)
https://github.com/python/cpython/commit/d85121660ea50bbe8fbd31797aa6e4afe0850388


--

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Yury Selivanov


Yury Selivanov  added the comment:

Couple thoughts:

I'm +1 for adding TaskGroup.cancel() method.

I'd be -1 on abusing `Task.cancel()` to signal something with a nonce. Whatever 
problem we are trying to solve here, it should be solvable without resorting to 
hacks like this. It should be trivial to implement simple tracking of whether a 
child task was cancelled by the group or not to decide on how to handle a rogue 
CancelledError.

--

___
Python tracker 

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



[issue46784] Duplicated symbols when linking embedded Python with libexpat

2022-02-17 Thread Ned Deily


Change by Ned Deily :


--
nosy: +corona10

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Guido van Rossum


Guido van Rossum  added the comment:

+1 on both aspects of the plan.

--

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Guido van Rossum


Change by Guido van Rossum :


--
pull_requests: +29542
pull_request: https://github.com/python/cpython/pull/31398

___
Python tracker 

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



[issue46752] Introduce task groups to asyncio and change task cancellation semantics

2022-02-17 Thread Guido van Rossum


Change by Guido van Rossum :


--
pull_requests: +29541
pull_request: https://github.com/python/cpython/pull/31398

___
Python tracker 

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



[issue46784] Duplicated symbols when linking embedded Python with libexpat

2022-02-17 Thread Yilei Yang


Change by Yilei Yang :


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

___
Python tracker 

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



[issue46784] Duplicated symbols when linking embedded Python with libexpat

2022-02-17 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue46784] Duplicated symbols when linking embedded Python with libexpat

2022-02-17 Thread Yilei Yang


New submission from Yilei Yang :

The libexpat 2.4.1 upgrade from https://bugs.python.org/issue44394 introduced 
the following new exported symbols:

testingAccountingGetCountBytesDirect
testingAccountingGetCountBytesIndirect
unsignedCharToPrintable
XML_SetBillionLaughsAttackProtectionActivationThreshold
XML_SetBillionLaughsAttackProtectionMaximumAmplification

We need to adjust Modules/expat/pyexpatns.h

(The newer libexpat upgrade https://bugs.python.org/issue46400 has no new 
symbols).

I'll send a PR.

--
components: XML
messages: 413464
nosy: yilei
priority: normal
severity: normal
status: open
title: Duplicated symbols when linking embedded Python with libexpat
versions: Python 3.10, Python 3.11, Python 3.7, 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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

>  Nor will it achieve world peace.

Please watch the tone. It is borderline abusive and dismissive.

> we can invoke the attached as best_fraction(Fraction("0.001"),
> Fraction("0.0005"), Fraction("0.0015")) to get the output
> Fraction(1, 1000).

-1 I am solidly against this.  The other inputs to Fraction() are exact 
conversions.  The proposal works against a core concept behind the fraction 
module. 

Also, my expectation for Fraction("0.0015") would be to give Fraction(3, 2000), 
the same as would be given by Fraction(Decimal("0.0015")).

> But if it solves enough use cases then it is worth discussing, yes?

Perhaps this tracker issue should be closed and moved to python-ideas.  The 
notions are currently too immature to warrant more core developer time.

Also, it would be nice to have research into what other languages and libraries 
do for fractional approximations of decimal strings.

--

___
Python tracker 

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



[issue45099] asyncio.Task's documentation says that loop arg is removed when it's not

2022-02-17 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

I have a feeling that we need a low-level API section that describes 
*supported* API that is intended to task extenders only (guys who want to 
provide an alternative task factory for example).

I love to contribute but not sure when I can find time for this docs change. 
Please feel free to provide a pull request.

--

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

The PR is pretty empty, it has a scaffolding for `asyncio.timeouts` module and 
its test only. I'll try to add something real tomorrow.

My plan is:
- solve 'easy' questions with Tin during PR's discussion/reviews
- make something that we are both agree on if it is possible at this stage. I'm 
optimistic, seems like we both are able to compromise (and have the experience 
to work together on pytest-asyncio project).
- raise a hard question loudly if discussion on GitHub will need more people 
(participation in early stages are welcome, sure).

> I think Andrew missed one case: in his second diagram, what if the explicit 
> cancel() happened *after* the timeout (but still in the same iteration)? 
> That's the case that makes me want to delete those two lines from 
> Task.cancel() (see my earlier message).

Please let me write a comprehensive answer (with a third diagram, I've found 
these simple pictures useful) tomorrow.

--

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

https://github.com/python/cpython/pull/31394 is created for collaboration , Tin 
Tvrtković is invited.
Core devs should have the write access already.
Non-core devs, please ask for github invite if you want to collaborate.

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


Lee Newberg  added the comment:

> The 12 semitones in an octave are separated ...

Right, this functionality would not solve the semitones / cents problem.  Nor 
will it achieve world peace.  But if it solves enough use cases then it is 
worth discussing, yes?

I haven't written the string parsing, but once we know that "0.001" means to 
look in [0.0005, 0.0015) then we can invoke the attached as 
best_fraction(Fraction("0.001"), Fraction("0.0005"), Fraction("0.0015")) to get 
the output Fraction(1, 1000).

--
Added file: https://bugs.python.org/file50627/best_fraction.py

___
Python tracker 

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



[issue46400] Please update bundled libexpat to 2.4.4 with security fixes (CVE-2021-45960)

2022-02-17 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset e7828904f39588dad438c5d341a31e72e9cb1775 by Miss Islington (bot) 
in branch '3.9':
bpo-46400: Update libexpat from 2.4.1 to 2.4.4 (GH-31022) (GH-31295)
https://github.com/python/cpython/commit/e7828904f39588dad438c5d341a31e72e9cb1775


--

___
Python tracker 

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



[issue46400] Please update bundled libexpat to 2.4.4 with security fixes (CVE-2021-45960)

2022-02-17 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset cb7551d5663f35c6993f3c6d8e361bc73f1c43d4 by Dong-hee Na in branch 
'3.10':
bpo-46400: Update libexpat from 2.4.1 to 2.4.4 (GH-31022) (GH-31296)
https://github.com/python/cpython/commit/cb7551d5663f35c6993f3c6d8e361bc73f1c43d4


--

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Andrew Svetlov


Change by Andrew Svetlov :


--
pull_requests: +29539
pull_request: https://github.com/python/cpython/pull/31394

___
Python tracker 

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



[issue46770] ConfigParser(dict_type=) not behaving as expected

2022-02-17 Thread Mark Lonnemann


Mark Lonnemann  added the comment:

I know, thanks though.  I just thought there was a way to do it via dict_type=. 
 I've read it can be done, but is complex.  I've yet to see any examples of how.

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Also note for the music example that the notion of "near enough" isn't 
equidistant about the "simple fraction".  The sense of nearness is logarithmic 
and is measured in "cents" which are hundredths of an equal-tempered semitone 
(i.e a one octave consists of 1200 cents).

--

___
Python tracker 

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



[issue46781] Tracing: c_return doesn't report the result

2022-02-17 Thread Matthias Urlichs


Matthias Urlichs  added the comment:

Added a github PR. Unfortunately it breaks the cprofile testcase, which 
apparently relies on the old argument value (for no good reason IMHO).

I don't know how the profiler works internally. If somebody who does could have 
a look at it and/or its testcase I'd be grateful.

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I don't think the standard library should go down this path.  

Mark's disinclinations all make sense to me, but I'm also concerned that the 
API would be almost unusable in practical situations.  Users would tend to know 
their input fraction and that they have a desire for "simplification", but it 
would be challenging for them to come with a surrounding interval that made 
sense.  We could attempt to infer an interval from the input, but a user is 
likely to have a poorly specified idea of what they actually want.  The 
operating principle here is, "refuse the temptation to guess".

Here's a little exercise for the API.  The 12 semitones in an octave are 
separated by a frequency ratio of 2**(1/12).  For example, if A is 440 Hz, then 
A# is 440*2**(1/12) = 466.16 Hz.  Note pairs sound the most harmonious when the 
ratio of their frequencies is a "near" a small fraction.  Determine the small 
fraction for each of the twelve notes.  For example, a perfect fifth has the 
frequency ratio of 2**(7/12) -> 1.498307 — it it "perfect" because it 
"close-enough" to the small integer ratio of 3 : 2.  Notice the vague 
requirements of "near", "close-enough" and "small integer ratio".

--

___
Python tracker 

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



[issue46781] Tracing: c_return doesn't report the result

2022-02-17 Thread Matthias Urlichs


Change by Matthias Urlichs :


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

___
Python tracker 

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



[issue45356] Calling `help` executes @classmethod @property decorated methods

2022-02-17 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

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

--

___
Python tracker 

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



[issue46764] Wrapping a bound method with a @classmethod no longer works

2022-02-17 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

This seems like a reasonable fix.  I'll wait a bit so that others can comment 
as well.

FWIW, we looking a potentially reverting the whole line of development starting 
with that commit.  It has caused a number of problems and no longer looks 
tenable.  See https://bugs.python.org/issue45356

--
assignee:  -> rhettinger

___
Python tracker 

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



[issue46770] ConfigParser(dict_type=) not behaving as expected

2022-02-17 Thread Cyril Jouve


Cyril Jouve  added the comment:

you need to pass `strict=False` to ConfigParser :


When `strict` is True, the parser won't allow for any section or option
duplicates while reading from a single source (file, string or
dictionary). Default is True.

--
nosy: +Cyril Jouve

___
Python tracker 

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



[issue46783] Add a new feature to enumerate(iterable, start=0) built-in function

2022-02-17 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thank you for the suggestion, but we will decline.  We looked at this before 
and decided not to go down this path, preferring instead to the keep the 
builtin function simple and focused on its core task of enumeration.

To cover the rarer cases, it is a simple matter to fulfill the need with fast, 
clear code using itertools:

>>> from itertools import count
>>> names = ['eddard', 'catelyn', 'robb', 'sansa', 'arya', 'bram', 'rickon']
>>> for i, name in zip(count(start=7, step=-1), names):
print(i, name)

7 eddard
6 catelyn
5 robb
4 sansa
3 arya
2 bram
1 rickon

--
assignee:  -> rhettinger
nosy: +rhettinger
resolution:  -> rejected
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



[issue29418] inspect.isroutine does not return True for some bound builtin methods

2022-02-17 Thread Batuhan Taskaya

Batuhan Taskaya  added the comment:


New changeset 02815d939362d4093a95da650e7fbddabf147eb0 by Hakan Çelik in branch 
'main':
bpo-29418: Add inspect.ismethodwrapper to whatsnew (GH-31377)
https://github.com/python/cpython/commit/02815d939362d4093a95da650e7fbddabf147eb0


--
nosy: +BTaskaya

___
Python tracker 

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



[issue46730] Please consider mentioning property without setter when an attribute can't be set

2022-02-17 Thread Dennis Sweeney


Dennis Sweeney  added the comment:


New changeset 9e06d03672547041239812efe4901c06da6cbd2f by Christian Heimes in 
branch 'main':
bpo-46730: Fix refleak and tighten NULL checks (GH-31389)
https://github.com/python/cpython/commit/9e06d03672547041239812efe4901c06da6cbd2f


--

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Guido van Rossum


Guido van Rossum  added the comment:

Lots of food for thought! There seem to be mostly two discussions: API design 
for the new asyncio cancel scopes (do we make it more like Trio or more like 
async-timeout?); and cancel semantics in edge cases.

I'll pass on the API design for now: I recommend that Tin and Andrew agree on 
some middle ground first. (Personally I could do without move_on(), I'd just 
add a try/except TimeoutError.)

On the cancel edge case, I am beginning to warm up to (ab)using the existing 
cancel message hack, rather than a separate nonce. I think the message argument 
could be the cancel scope or its id().

I think Andrew missed one case: in his second diagram, what if the explicit 
cancel() happened *after* the timeout (but still in the same iteration)? That's 
the case that makes me want to delete those two lines from Task.cancel() (see 
my earlier message).

(Sorry, I've gotta go play now.)

--

___
Python tracker 

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



[issue46781] Tracing: c_return doesn't report the result

2022-02-17 Thread Matthias Urlichs


Matthias Urlichs  added the comment:

Likewise for c_exception, which should report the exception thruple -- and even 
has an XXX comment reminding us to fix that (ceval.c 4542).

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


Lee Newberg  added the comment:

> What about for an input of "0.001"? Your current specification would give 
> 1/667, but I'm betting that you'd actually prefer 1/1000.

You would win that bet.

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Mark Dickinson


Mark Dickinson  added the comment:

> I'd modify the optimization to be that we continue to seek the smallest 
> denominator, but in the case that multiple numerators would give ratios 
> within the computed interval then we choose the numerator among these that 
> gives the ratio closest to the input value.

Hmm. This is getting more DWIM-like (Do What I Mean) by the minute. :-)

What about for an input of "0.001"? Your current specification would give 
1/667, but I'm betting that you'd actually prefer 1/1000.

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


Lee Newberg  added the comment:

>It would return 1/7 for "0.1" and 1/4 for "0.2". Is it what you expected?

I answered "yes" before, but I am now thinking "no".  In the case of "0.1", the 
smallest numerator achievable is 1, but there are multiple denominators that 
would give a value within [0.05, 0.15).  So, I'd choose the denominator that 
gives the ratio that is closet to the input value.

This is similar to the "16e2" example but with the roles of numerator and 
denominator reversed.

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


Lee Newberg  added the comment:

The example of "16e2" would yield the interval [1550, 1650).  The smallest 
denominator possible is 1.  The smallest numerator that works with that 
denominator is 1550, but I don't like 1550/1 as the answer.

To cover these edge cases, I'd modify the optimization to be that we continue 
to seek the smallest denominator, but in the case that multiple numerators 
would give ratios within the computed interval then we choose the numerator 
among these that gives the ratio closest to the input value.

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


Lee Newberg  added the comment:

> One more example: what interval is implied by an input string of "1600"? Is 
> it (1550, 1650)? Or (1595, 1605)? Or even (1599.5, 1600.5).

The rule would be to look at the last digit supplied and assume that the 
rounding is there.  So "1600" gives [1599.5, 1600.5) and "16e2" gives [1550, 
1650).

--

___
Python tracker 

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



[issue41028] Move docs.python.org language and version switcher out of cpython

2022-02-17 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 4c48cac1c44fbbfe3f5fd0c623b7768e2a709da8 by Miss Islington (bot) 
in branch '3.8':
bpo-41028: Doc: Move switchers to docsbuild-scripts. (GH-20969) (GH-30344)
https://github.com/python/cpython/commit/4c48cac1c44fbbfe3f5fd0c623b7768e2a709da8


--
status: pending -> open

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


Lee Newberg  added the comment:

> You may be interested in the "simplefractions" module on PyPI, which solves 
> the exact task "find the simplest fraction in a given interval".

I haven't seen that code and I am interested; I will take a look.  Perhaps code 
from there can be imported / incorporated in our implementation here.

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Mark Dickinson


Mark Dickinson  added the comment:

One more example: what interval is implied by an input string of "1600"? Is it 
(1550, 1650)? Or (1595, 1605)? Or even (1599.5, 1600.5).

Sorry, I just don't see this working - there are two many arbitrary choices 
involved in guessing what interval the user intended. Much better to require 
the user to give that interval directly.

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


Lee Newberg  added the comment:

> For another problematic example, suppose the string supplied is "0.10"

We would treat "0.1", "0.10", "0.100", etc. all differently.  In all cases we 
would assume rounding to compute the last digit.  Similarly for "3e-10", 
"3.0e-10" == "30e-11", "3.00e-11", etc.

--

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


Lee Newberg  added the comment:

> depending on which rounding mode was used (round-ties-to-even, 
> round-ties-to-away), the interval may be half-open, open or closed.

I think we will get the majority of the use cases if we pick one rounding 
strategy and stick with it.  In later version we could support more if we found 
the demand: in addition to assume_rounded=True we could allow 
assume_rounded="round_towards_zero", etc.

--

___
Python tracker 

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



[issue46783] Add a new feature to enumerate(iterable, start=0) built-in function

2022-02-17 Thread Zachary Ware


Change by Zachary Ware :


--
assignee: docs@python -> 
components: +Library (Lib) -Build, Demos and Tools, Documentation, Interpreter 
Core
nosy:  -docs@python, lys.nikolaou
versions:  -Python 3.10, Python 3.7, 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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


Lee Newberg  added the comment:

>It would return 1/7 for "0.1" and 1/4 for "0.2". Is it what you expected?

Yes.  Or putting it another way, if that's not the right answer then whoever 
rounded the number should have retained more digits.

--

___
Python tracker 

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



[issue46778] Enable parallel compilation on Windows builds

2022-02-17 Thread Steve Dower


Steve Dower  added the comment:


New changeset 98dd0aec2d0cb8971fb5363532c25041a5ba6fdc by Jeremy Kloth in 
branch 'main':
bpo-46778: Enable multiprocess compilation for source files when building on 
Windows (GH-31390)
https://github.com/python/cpython/commit/98dd0aec2d0cb8971fb5363532c25041a5ba6fdc


--

___
Python tracker 

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



[issue46778] Enable parallel compilation on Windows builds

2022-02-17 Thread Steve Dower


Steve Dower  added the comment:

Easy, and thanks for the PR!

--
resolution:  -> fixed
stage: patch review -> 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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


Lee Newberg  added the comment:

>This sounds interesting, but also rather similar to what the 
>`limit_denominator` method can get you. 

`Fractions("0.17").limit_denominator()` and 
`Fractions("0.17").limit_denominator(n)`
for n > 28 do not give 1/6.  So, I'd have to guess at n until I get 1/6.  
Instead, I'd like to have the digits actually presented "0.17" determine the 
interval [0.165, 0.175) which then determines the fraction.

In particular, "0.170" would give a different answer ... a fraction within 
[0.1695, 0.1705).

--

___
Python tracker 

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



[issue46783] Add a new feature to enumerate(iterable, start=0) built-in function

2022-02-17 Thread Larry Hastings


Change by Larry Hastings :


--
components:  -Argument Clinic
nosy:  -larry

___
Python tracker 

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



[issue46783] Add a new feature to enumerate(iterable, start=0) built-in function

2022-02-17 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

This has nothing to do with the parser so I'm removing the label. Please, next 
time make sure you select the appropriate categories when opening an issue

--
components:  -Parser

___
Python tracker 

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



[issue46783] Add a new feature to enumerate(iterable, start=0) built-in function

2022-02-17 Thread Hossein


New submission from Hossein :

Hi everyone. I have an idea which is add a new feature to enumerate(iterable, 
start=0) built-in function. I mean, "start" is ascending by default, we can add 
a feature to this function to change start in descending order.
for example:
enumerate(iterable, start=100, reverse=True)
reverse: If True, the start is reversed.
(100, iterable[0]), (99, iterable[1],), and so on.

--
assignee: docs@python
components: Argument Clinic, Build, Demos and Tools, Documentation, Interpreter 
Core, Parser
messages: 413428
nosy: HosseinRanjbari, docs@python, larry, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Add a new feature to enumerate(iterable, start=0) built-in function
type: enhancement
versions: Python 3.10, Python 3.11, Python 3.7, 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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Mark Dickinson


Mark Dickinson  added the comment:

Sigh:

> the next representable value up from 0.01 is 0.011

should say:

> the next representable value up from 0.10 is 0.11

I think I'll duck out and give my brain a rest before commenting further.

--

___
Python tracker 

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



[issue46782] Docs error for 3.10

2022-02-17 Thread sjndlnv brjkbn


New submission from sjndlnv brjkbn :

Document for 3.10 version seems auto convert 0o777 to 511. And it's correct for 
3.9

(May be due to new version of Sphinx? Seems source code for docs are correct.)

[img]https://i.imgur.com/ByWSJ6A.png[/img]
[img]https://i.imgur.com/rK0romC.png[/img]
[img]https://i.imgur.com/WXYMcrT.png[/img]
[img]https://i.imgur.com/W5YskgQ.png[/img]

It may misleading user. If we use os.mkdir(mode=511), it's not equal to use 
os.mkdir(mode=0o777)

--
assignee: docs@python
components: Documentation
messages: 413425
nosy: docs@python, usetohandletrush
priority: normal
severity: normal
status: open
title: Docs error for 3.10
type: behavior
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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Mark Dickinson


Mark Dickinson  added the comment:

> in which case the interval we need is [0.095, 0.15]

Whoops, sorry; brain fail. If we're rounding to two sig figs, the next 
representable value up from 0.01 is 0.011, while the next one down is 0.099, so 
the interval we'd be interested in would be [0.0995, 0.105].

--

___
Python tracker 

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



[issue31242] Add SSLContext.set_verify_callback()

2022-02-17 Thread Christian Heimes


Christian Heimes  added the comment:

bpo-28747 was an older ticket for implementing a callback.

--
assignee: christian.heimes -> 

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Mark Dickinson


Mark Dickinson  added the comment:

> the constructed Fraction first computes the range of the values that the 
> input string could have been rounded from

There's too much magic and guesswork here for my liking; I don't really see 
this as feasible. Moreover, depending on which rounding mode was used 
(round-ties-to-even, round-ties-to-away), the interval may be half-open, open 
or closed.

For another problematic example, suppose the string supplied is "0.10". How are 
we to guess whether this was the result of rounding to two decimal places after 
the point (in which case the interval we need is [0.095, 0.105]), or whether 
it's the result of rounding to two significant figures (in which case the 
interval we need is [0.095, 0.15])?

> and then computes the fraction in that half-open interval with the lowest 
> numerator and denominator

This part, however, is well-defined and can be done efficiently. You may be 
interested in the "simplefractions" module on PyPI, which solves the exact task 
"find the simplest fraction in a given interval".

--

___
Python tracker 

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



[issue31242] Add SSLContext.set_verify_callback()

2022-02-17 Thread Christian Heimes


Christian Heimes  added the comment:

Unfortunately a generic and future-proof verify callback is much more work. We 
need to expose and wrap X509_STORE_CTX, X509_STORE, X509 (include 
STACK_OF(X509)), and probably several other OpenSSL structures. We also need to 
expose error codes.

--
superseder:  -> Expose SSL_CTX_set_cert_verify_callback

___
Python tracker 

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



[issue46781] Tracing: c_return doesn't report the result

2022-02-17 Thread Matthias Urlichs


New submission from Matthias Urlichs :

When tracing/profiling, the "return" event reports the value returned by the 
exiting function.

However, this does not work for C functions. The profiler's "c_return" hook is 
called with the same C function object as "c_call". This unnecessarily 
complicates debugging and should be fixed.

https://stackoverflow.com/questions/61067303/get-return-value-of-python-builtin-functions-while-tracing

--
components: C API
messages: 413421
nosy: smurfix
priority: normal
severity: normal
status: open
title: Tracing: c_return doesn't report the result
type: enhancement
versions: Python 3.10, Python 3.11

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It would return 1/7 for "0.1" and 1/4 for "0.2". Is it what you expected?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Zachary Ware


Zachary Ware  added the comment:

This sounds interesting, but also rather similar to what the 
`limit_denominator` method can get you.  Can you provide examples that can't be 
handled nicely by `limit_denominator` to strengthen your case?

--
nosy: +mark.dickinson, rhettinger, zach.ware
versions: +Python 3.11

___
Python tracker 

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



[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Lee Newberg


New submission from Lee Newberg :

For example, a string such as "0.167" could be rounded from anything in 
[0.1665, 0.1675).  Within that interval, the fraction with the lowest numerator 
and denominator is 1/6.

Here it is proposed that we add a new flag to the Fractions constructor, 
perhaps called `_assume_rounded`, which defaults to False and then yields no 
change from current behavior.  However, when it is True, the constructed 
Fraction first computes the range of the values that the input string could 
have been rounded from, and then computes the fraction in that half-open 
interval with the lowest numerator and denominator.  This is described at 
https://en.wikipedia.org/wiki/Continued_fraction#Best_rational_within_an_interval,
 which uses continued fractions to arrive at the answer.

For extra bells and whistles, we'd support strings like "0x0.2AAB" which is 
hexadecimal for 1/6 rounded to that many places.  In this case, we'd find 1/6 
as the fraction with lowest numerator and denominator in the interval 
[0x0.2AAA8, 0x0.2AAB8).  Likewise for binary, octal, and any other formats 
supported by Python.

--
components: Library (Lib)
messages: 413418
nosy: Leengit
priority: normal
severity: normal
status: open
title: Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.
type: enhancement

___
Python tracker 

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



[issue31242] Add SSLContext.set_verify_callback()

2022-02-17 Thread Adrian Freund


Adrian Freund  added the comment:

I also need this feature for something I'm working on, so I looked into it a 
bit and pushed a small proof of concept implementation to GitHub (See PR 31391).

I'm not sure if I'll have enough time to finish and clean up this 
implementation, but at least there is a starting point.

I also opened bpo-46779 as a simpler method to solve most of the usecases  that 
would be solved by this api.

--
versions: +Python 3.11 -Python 3.8

___
Python tracker 

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



[issue46779] Add ssl.CERT_REQUIRED_NO_VERIFY as possible value for ssl.SSLContext.verify_mode

2022-02-17 Thread Adrian Freund


New submission from Adrian Freund :

Some networked applications might require connecting to client with invalid 
certificates but still requiring the client to send a certificate.

ssl.SSLContext.verify_mode currently supports the following options:
ssl.CERT_NONE: Don't require the client to send a certificate and don't 
validate it if they send one anyways.
ssl.CERT_OPTIONAL: Don't require the client to send a certificate but validate 
it if they send one.
ssl.CERT_REQUIRED: Require the client to send a certificate and validate it.

There is currently no option for servers that want to require the client to 
send a certificate but don't validate it.

This would for example be needed it a server should accept clients with 
self-signed certificates and then store their certificates to recognize them 
again later.

A concrete example is the KDEConnect protocol.

An alternative solution would be bpo-31242. That would also solve this problem 
is a more general, but also more complicated way.

I think that the solution proposed here this issue is better for it's 
simplicity and also solves most usecases for bpo-31242.


Note that a ssl.CERT_REQUIRED_NO_VERIFY was already proposed in bpo-18293, but 
that issue was closed because it was specifically in relation to a deprecated 
api. The mentioned values are however also used in modern asyncio apis.

--
assignee: christian.heimes
components: SSL
messages: 413416
nosy: christian.heimes, freundTech
priority: normal
severity: normal
status: open
title: Add ssl.CERT_REQUIRED_NO_VERIFY as possible value for 
ssl.SSLContext.verify_mode
type: enhancement
versions: Python 3.11

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Alex Grönholm

Alex Grönholm  added the comment:

@Guido you asked for the AnyIO implementation of Happy Eyeballs; here it is: 
https://github.com/agronholm/anyio/blob/ac3e7c619913bd0ddf9c36b6e633b278d07405b7/src/anyio/_core/_sockets.py#L85

(I didn't paste the actual code here because it's way too long)

--

___
Python tracker 

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



[issue39298] add BLAKE3 to hashlib

2022-02-17 Thread Larry Hastings


Larry Hastings  added the comment:

I thought someone volunteered to do it--if that's not happening, I could take a 
look at it next week.  Shouldn't be too hard... unless I have to touch 
autoconf, which I only barely understand.

--

___
Python tracker 

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



[issue42752] multiprocessing Queue leaks a file descriptor associated with the pipe writer (#33081 still a problem)

2022-02-17 Thread Thomas Grainger


Change by Thomas Grainger :


--
nosy: +graingert, vstinner

___
Python tracker 

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



[issue31242] Add SSLContext.set_verify_callback()

2022-02-17 Thread Adrian Freund


Change by Adrian Freund :


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

___
Python tracker 

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



[issue39298] add BLAKE3 to hashlib

2022-02-17 Thread Jack O'Connor


Jack O'Connor  added the comment:

What's the best way for me to help with the next steps of this?

--

___
Python tracker 

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



[issue46778] Enable parallel compilation on Windows builds

2022-02-17 Thread Jeremy Kloth


Change by Jeremy Kloth :


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

___
Python tracker 

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



[issue46778] Enable parallel compilation on Windows builds

2022-02-17 Thread Jeremy Kloth


New submission from Jeremy Kloth :

While the current build does enable building of projects in parallel 
(msbuild -m), the compilation of each project's source files is done 
sequentially.  For large projects like pythoncore or _freeze_module this can 
take quite some time.

This simple PR speeds things up significantly, ~2x on machines that I have 
access.

--
components: Build, Windows
messages: 413412
nosy: jkloth, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Enable parallel compilation on Windows builds
versions: Python 3.11

___
Python tracker 

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



[issue41111] [C API] Convert a few stdlib extensions to the limited C API (PEP 384)

2022-02-17 Thread Eric Snow


Change by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

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



[issue43974] Define Py_BUILD_CORE_MODULE in extensions instead of setup.py and Modules/Setup

2022-02-17 Thread Eric Snow


Change by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Tin Tvrtković

Tin Tvrtković  added the comment:

Hello Andrew, here's some followup.

About the names: the move_on_after and fail_after names are from Trio. I don't 
have strong feeling about them at all, whatever most people like.

About move_on_after vs loop.call_at and loop.call_later: move_on_after is much 
more usable in practice, since it doesn't require splitting your coroutine in 
several. And it's very useful in production code; when dealing with 3rd party 
APIs you want to wait a reasonable time and continue on your way if the 3rd 
party API stalls.

About `async with` vs `with`: I have strong feelings for `with`. It's not a 
performance issue; I don't care about that. `async with` to me says there are 
suspension points involved; this coroutine might or might not be suspended 
either entering or existing. With a bare `with` I *know* there is no 
suspension. This is important to keep my concurrent code more correct, which is 
hard enough.

About overriding the task factory: the default Task implementation is 
implemented in C, correct? I would be way too scared of putting my (Python) 
implementation in there because of performance. Spending years shaving 
microseconds off in my other libraries to risk losing it all because I want 
better cancellation in asyncio would feel really bad. Ideally we can get a 
good-enough solution in the stdlib so users don't have to do this.

About your point 3, first graph: you are right if both context managers 
propagate exceptions. If the inner one is set to swallow (`move_on_after`) OR 
the user plans on swallowing the inner one, the problem is *not* solved  (or at 
least I don't understand the solution). This is the code sample from 
https://bugs.python.org/issue46771#msg413368. And I think swallowing is an 
important use case, as I've already mentioned.

About the special field for nonce: I'm OK with smuggling the nonce in the 
message. But I stand by my proposal for making the nonce a monotonic number, 
and that would require a special field to be clean.

--

___
Python tracker 

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



[issue46730] Please consider mentioning property without setter when an attribute can't be set

2022-02-17 Thread Christian Heimes


Change by Christian Heimes :


--
nosy: +christian.heimes
nosy_count: 4.0 -> 5.0
pull_requests: +29534
pull_request: https://github.com/python/cpython/pull/31389

___
Python tracker 

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



[issue44834] contextvars.Context.run w/ coroutines gives inconsistent behavior

2022-02-17 Thread Sebastián Ramírez

Change by Sebastián Ramírez :


--
nosy: +tiangolo

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

I support Alex Grönholm: TaskGroup is not affected by cancellation races 
because it doesn't convert the exception or swallows it.
The code is safe from my understanding.

--

___
Python tracker 

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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

The discussion is hot, I see several interleaved threads.

Let me put my answers on all of them in order of appearance.

1. quattro cancellation scopes are implemented after async-timeout.
As the author of async-timeout I am happy to know it.
The module is pretty small (as async-timeout itself).
I'd like to concentrate on the differences between async-timeout and quattro.

  a) quattro has `fail_after()` / `fail_at()` context managers,
  that are similar to async-timeout's `timeout()` / `timeout_at()`
  The first function schedules timeout as a *relative* delay,
  the second uses *absolut monotonic* time. So far so good.

  `timeout()` better points on 'what happens' I believe (TimeoutError is 
raised).
  `fail_after` is not that bad at all but `timeout()` is easier I think.
  `timeout_at()` and `fail_at()` are minic to `loop.call_at()`, the prefix is 
perfect.
  Regarding `loop.call_later()` I found that `timeout_later()` is too long name
  (plus `timeout()` context manager appeared in 2015 as a part of aiohttp).

  My opinion is biased, sure.

  b) quattro has `move_on_after()` and `move_on_at()` context managers that 
doesn't
  raise TimeoutError but set a flag after certain period.
  asyncio has lower level primitives than trio (`loop.call_later()` and 
`loop.call_at()`).
  Not sure that `move_on_*` should be added, they are low-level building blocks.
  On the other hand, `move_on_after()` requires less code lines than 
`call_later()`.
  If we decide 'yes' I suggest changing naming: I have no idea what is *moved* 
without
  reading the documentation.

  c) `with fail_after()` vs `async with timeout()`.
  The first async-timeout version used `with timeout()` notation.
  I've changed it to async counterpart after many questions from newbies:
  "Why is sync context manages used in async code?". Questions arose when 
asyncio was not
  wide-spread as today.
  People made their first baby steps those days, I provided a dozen of asyncio 
offline courses
  and many conference talks.
  Thus, please consider `async with ...` design as a user feedback reaction.
  As a side effect, it prohibits `timeout()` usage in non-async functions 
(which is
  awkward at least).
  Regarding async context manager performance, I think it is good enough
  for timeout-related things. I didn't experience any problem with it.
  Moreover, async fast-path (async function is called and it returns a value 
without
  suspension on awaiting) can be optimized on Python level to make it as fast 
as a regular
  python function call, sure. It is not trivial and might require adding a new 
opcode
  (combine CALL + GET_AWAITABLE) but this optimization is out of the issue 
scope.

  d) `cm.deadline += 0.5` vs `cm.shift(0.5)` is a question of taste.  
asyncio-timeout
  design motivation was "don't do complex things in property setter" but I can 
live with
  mutable `cm.deadline` attribute, sure

  e) cancellation stack and `current_effective_deadline` -- I'm with Guido, 
let's not
  add yet another stack.  It can be an interesting debug feature but I doubt
  if it is useful in production code.
  Also, the performance cost is not zero. Merging and slicing stack tuple on any
  timeout context enter/exit is not free. The implementation can be switched
  to a linked list but still, do we really need it?

2. Alex Grönholm, asyncio supports custom task instances without overriding the 
entire
task factory. You should provide a custom method for custom task creatuon, 
that's it.
`asyncio.all_tasks()` / `asyncio.current_task()` support is provided by
'_register_task()', '_unregister_task()', '_enter_task()', and '_leave_task()' 
calls.
These methods are part of non-user-faced public API, they are intentionally 
enumerated
by `asyncio.__all__`.
These methods are mentioned by changelog only, sorry. A pull request for 
documenting them
in asyncio low-level section is welcome!

3. The race condition between two `.cancel()` calls performed by the same loop 
iteration.
Sure, the race exists.
Before TaskGroup landing, the last `.cancel()` wins. After the change, the 
first `.cancel()`
wins and all subsequent `.cancel()` calls made on the same event loop iteration 
are rejected
with returning `False`.  I believe, the changed behavior is more consistent 
(and close to
`Future.cancel()` design).

Assume, we have two scheduled close but different timeouts for the same tasks.
Both are reached at the next event loop iteration (see the timeline below):

prev-iteration   timeout-a   timeout-b  current-iteration
 |  |   |  |
 >---+--+---+--+--> future

I prepared https://github.com/aio-libs/async-timeout/pull/295 to handle it (not 
merged
yet because the next Python alpha release it required; I've tested it against 
the latest
CPython main branch manually). Sorry for polluting source code by 
`sys.version_info` checks,
the library is supposed to work 

[issue46774] Importlib.metadata.version picks first distribution not latest

2022-02-17 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +jaraco

___
Python tracker 

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



[issue46777] Fix incorrect use of directives in asyncio documentation

2022-02-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

6. The loop parameter of Task() was documented as both removed and required (if 
there is no current event loop) in 3.10.

--

___
Python tracker 

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



[issue46776] RecursionError when using property() inside classes

2022-02-17 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Maybe you expected to do this:

class C:
def __init__(self):
self._value = 999

@property
def bar(self):
return self._value

obj = C()
obj.bar  # returns 999

--

___
Python tracker 

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



[issue46777] Fix incorrect use of directives in asyncio documentation

2022-02-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue46776] RecursionError when using property() inside classes

2022-02-17 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

This is not a bug, Python is working correctly here. The interpreter is doing 
exactly what you told it to do, and then raising a RecursionError before you 
can crash the system.


You have a property instance.bar which returns instance.bar, which returns 
instance.bar, which returns instance.bar... forever, or until RecursionError is 
triggered.

Your class is the same as:

class Foo:
@property
def bar(self):
return self.bar

So when you call instance.bar, it looks up bar, which is the property, which 
looks up bar, which is the property, which looks up bar, and so on.

What did you expect to happen?

--
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



[issue45413] Add install scheme for virtual environments

2022-02-17 Thread Miro Hrončok

Miro Hrončok  added the comment:

I've adapted the PR. See the latest commit (Instead of *venv* scheme, have 
*posix_venv* and *nt_venv*).

--

___
Python tracker 

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



[issue46777] Fix incorrect use of directives in asyncio documentation

2022-02-17 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There are some issues with formatting added or removed parameters in the 
asyncio module.

1. "deprecated-removed" directives were used for already removed directives. It 
should be used for deprecated features with known term of removal. For removed 
features "versionchanged" is more appropriate.

2. Text for removed parameters was too verbose. "Removed the XXX parameter" 
would be enough.

3. "versionadded" directives were used for new parameters. "versionchanged" 
directive is more appropriate. It is a date of the change in existing function, 
not the date of adding the function itself.

4. Some directives were written not in order of increasing version number.

5. In some places parameters were marked up as ``name``. *name* is commonly 
used for parameters.

--
assignee: docs@python
components: Documentation, asyncio
messages: 413404
nosy: asvetlov, docs@python, kj, serhiy.storchaka, yselivanov
priority: normal
severity: normal
status: open
title: Fix incorrect use of directives in asyncio documentation
type: enhancement
versions: Python 3.10, Python 3.11

___
Python tracker 

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



[issue46776] RecursionError when using property() inside classes

2022-02-17 Thread chen-y0y0


New submission from chen-y0y0 :

A simple class definition:
class Foo: bar = property(lambda self: self.bar)
And get the value of Foo.bar, it returns correctly, .
And get the value of Foo().bar, it raises RecursionError:
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in 
  File "", line 1, in 
  File "", line 1, in 
  [Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded

--
components: Interpreter Core
messages: 413403
nosy: prasechen
priority: normal
severity: normal
status: open
title: RecursionError when using property() inside classes
type: behavior
versions: Python 3.10, Python 3.11, Python 3.7, 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



[issue41086] Exception for uninstantiated interpolation (configparser)

2022-02-17 Thread Łukasz Langa

Change by Łukasz Langa :


--
resolution:  -> fixed
stage: patch review -> 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



[issue46771] Add some form of cancel scopes

2022-02-17 Thread Tin Tvrtković

Tin Tvrtković  added the comment:

@Guido @Chris

Instead of using the message for the nonce we could have a dedicated field for 
it.

I have a proposal though. It's about putting a little logic into the 
cancellation nonce handling.

Let's define the nonce as a float. If you just call Task.cancel(), the nonce 
defaults to 0.0. We add an argument to Task.cancel, so you can give it a nonce: 
task.cancel(nonce=nonce). The cancel() method has logic to keep track of the 
nonce with the smallest value.

When it's time for the CancelledError to be thrown into the task, this nonce 
(default 0.0 if not set by anthing) is attached to the error.

Then we change `move_on_after` (and all siblings) to do the following:

* in `__enter__`, use time.monotonic() to generate it's own nonce and remember 
it
* in `__exit__`, if the CancelledError has a nonce that is less than its own 
nonce, it propagates it, otherwise it handles it.

How this fixes the sad path in my example:

Both the web server and `move_on_after` cancel the task. The web server just 
calls `task.cancel()`, `move_on_after` calls `task.cancel(nonce=self.nonce)`. 
No matter the cancellation ordering, the nonce will end up set to 0.0. 
`move_on_after` will see the 0.0 nonce and propagate the error correctly to 
kill the task completely.

This also handles nested cancel scopes. I'm not sure how it works with the task 
catching the cancel to do a little cleanup.

--

___
Python tracker 

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



[issue41086] Exception for uninstantiated interpolation (configparser)

2022-02-17 Thread Łukasz Langa

Łukasz Langa  added the comment:

It's a behavioral change that tightens acceptable objects passed to 
`interpolation=`. In the past any object that provided the same interface as 
`Interpolation` instances would be accepted. No longer.

I think this is an acceptable compromise but it's definitely outside of the 
realm of backporting.

Thanks for your contribution, Brian! ✨  ✨

--

___
Python tracker 

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



[issue26469] Bug in ConfigParser when setting new values in extended interpolation

2022-02-17 Thread Łukasz Langa

Łukasz Langa  added the comment:

Note: the problem here was due to passing `ExtendedInterpolation` (the class) 
instead of `ExtendedInterpolation()` (the object). This is now fixed through 
BPO-41086.

--
nosy: +lukasz.langa

___
Python tracker 

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



[issue26831] ConfigParser parsing failures with default_section and ExtendedInterpolation options

2022-02-17 Thread Łukasz Langa

Łukasz Langa  added the comment:

Note: the problem here was due to passing `ExtendedInterpolation` (the class) 
instead of `ExtendedInterpolation()` (the object). This is now fixed through 
BPO-41086.

--

___
Python tracker 

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



[issue41086] Exception for uninstantiated interpolation (configparser)

2022-02-17 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset fc115c9bde52a58b4fb9be2b80c3d6be8a4d2454 by Brian Faherty in 
branch 'main':
bpo-41086: Add exception for uninstantiated interpolation (configparser) 
(GH-21062)
https://github.com/python/cpython/commit/fc115c9bde52a58b4fb9be2b80c3d6be8a4d2454


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue46745] Typo in new PositionsIterator

2022-02-17 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
resolution:  -> fixed
stage: patch review -> 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



[issue9338] argparse optionals with nargs='?', '*' or '+' can't be followed by positionals

2022-02-17 Thread Walter Doekes


Change by Walter Doekes :


--
nosy: +wdoekes

___
Python tracker 

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



[issue39327] shutil.rmtree using vagrant synched folder fails

2022-02-17 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 2.0 -> 3.0
pull_requests: +29532
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31384

___
Python tracker 

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



[issue45390] asyncio.Task doesn't propagate CancelledError() exception correctly.

2022-02-17 Thread Chris Jerdonek


Chris Jerdonek  added the comment:

Andrew, the approach I described would I feel be much better. It would result 
in more concise, less verbose tracebacks, as opposed to more verbose -- not 
just because the message won't be repeated, but also because it eliminates the 
unneeded creation of intermediate exceptions. It would also cause is checks to 
work, which is what we want since behaviorally it should be the same exception.

--

___
Python tracker 

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



[issue45099] asyncio.Task's documentation says that loop arg is removed when it's not

2022-02-17 Thread jack1142


jack1142  added the comment:

I'm aware, I'm reporting this because as long as the instantiation of a Task is 
documented, the documentation should still contain accurate up-to-date 
information.

--

___
Python tracker 

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



[issue45390] asyncio.Task doesn't propagate CancelledError() exception correctly.

2022-02-17 Thread Marco Pagliaricci


Marco Pagliaricci  added the comment:

Andrew,
many thanks for your time, solving this issue.
I think your solution is the best to fix this little problem and I agree
with you on backporting.

My Best Regards,
and thanks again.

Marco

On Thu, Feb 17, 2022 at 10:29 AM Andrew Svetlov 
wrote:

>
> Andrew Svetlov  added the comment:
>
> I have a pull request for the issue.
> It doesn't use `Future.set_exception()` but creates a new CancelledError()
> with propagated message.
> The result is the same, except raised exceptions are not comparable by
> `is` check.
> As a benefit, `_cancelled_exc` works with the patch, exc.__context__ is
> correctly set.
>
> The patch is not backported because it changes existing behavior a little.
> I'd like to avoid a situation when third-party code works with Python
> 3.11+, 3.10.3+, and 3.9.11+ only.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue45098] asyncio.CancelledError should contain more information on cancellations

2022-02-17 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

After TaskGroup merging, the second `cancel()` call returns `False` and doesn't 
initiate the actual cancellation if it was scheduled by the first `cancel()` 
call.

I believe it "fixes" async-timeout: the first canceller wins.

--

___
Python tracker 

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



[issue45099] asyncio.Task's documentation says that loop arg is removed when it's not

2022-02-17 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

User code should not create Task objects explicitly.
Please use `asyncio.create_task()` (or shiny new TaskGroup.create_task()) 
instead. They doesn't have 'loop' argument.

--

___
Python tracker 

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



[issue45390] asyncio.Task doesn't propagate CancelledError() exception correctly.

2022-02-17 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

I have a pull request for the issue.
It doesn't use `Future.set_exception()` but creates a new CancelledError() with 
propagated message.
The result is the same, except raised exceptions are not comparable by `is` 
check.
As a benefit, `_cancelled_exc` works with the patch, exc.__context__ is 
correctly set.

The patch is not backported because it changes existing behavior a little. I'd 
like to avoid a situation when third-party code works with Python 3.11+, 
3.10.3+, and 3.9.11+ only.

--

___
Python tracker 

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



[issue45390] asyncio.Task doesn't propagate CancelledError() exception correctly.

2022-02-17 Thread Andrew Svetlov


Change by Andrew Svetlov :


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

___
Python tracker 

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



[issue45390] asyncio.Task doesn't propagate CancelledError() exception correctly.

2022-02-17 Thread Andrew Svetlov


Change by Andrew Svetlov :


--
versions: +Python 3.11 -Python 3.9

___
Python tracker 

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



[issue31242] Add SSLContext.set_verify_callback()

2022-02-17 Thread Adrian Freund


Change by Adrian Freund :


--
nosy: +freundTech

___
Python tracker 

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



  1   2   >