[issue46643] typing.Annotated cannot wrap typing.ParamSpec args/kwargs

2022-02-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Should it? Annotated wraps types, and P.args/P.kwargs are not types.

If make Annotated accepting P.args/P.kwargs (and possible other non-types, e.g. 
P), it is a new feature which should be publicly discussed first and 
documented. I do not thing it requires a PEP.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue46676] ParamSpec args and kwargs are not equal to themselves.

2022-02-07 Thread Gregory Beauregard


Change by Gregory Beauregard :


--
pull_requests: +29380
pull_request: https://github.com/python/cpython/pull/31210

___
Python tracker 

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



[issue46676] ParamSpec args and kwargs are not equal to themselves.

2022-02-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset c8b62bbe46e20d4b6dd556f2fa85960d1269aa45 by Gregory Beauregard in 
branch 'main':
bpo-46676: Make ParamSpec args and kwargs equal to themselves (GH-31203)
https://github.com/python/cpython/commit/c8b62bbe46e20d4b6dd556f2fa85960d1269aa45


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue45948] Unexpected instantiation behavior for xml.etree.ElementTree.XMLParser(target=None)

2022-02-07 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
components: +Extension Modules
nosy: +serhiy.storchaka
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.8

___
Python tracker 

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



[issue46639] Ceil division with math.ceildiv

2022-02-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Round division would be useful not less than ceil division, if not more. In the 
stdlib it would be used in:

1. The datetime module.
2. Fraction.__round__.

--

___
Python tracker 

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



[issue46639] Ceil division with math.ceildiv

2022-02-07 Thread Tim Peters


Tim Peters  added the comment:

The `decimal` module intends to be a faithful implementation of external 
standards. The identity

x == (x // y) * y + x % y

isn't a minor detail, it's the dog on which all else is but a tail ;-)

It's why Guido picked -7 // 4 = -2 in Python[1]. That's really not all that 
useful on its own, and does surprise people. But it's necessary so that the 
identity implies -7 % 4 = 1, and _that's_ what drove it all, the desire that 
doing mod wrt a positive int always give a non-negative result.

The identity also implies that, under truncating division, mod returns a result 
with the sign of the dividend rather than of the divisor.

`decimal` implements what the external standards demand integer division do, 
and also integer modulus. The decimal context `divmod()` method returns both at 
once.

The behavior of int div and mod are linked by all standards I'm aware of, 
including by C89 (which didn't define what integer division did in all cases, 
but did demand that - whatever it did - % had to work in a way consistent with 
the named identity).

[1] 
http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html

--

___
Python tracker 

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



[issue46669] Add types.Self

2022-02-07 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> Your suggested signature looks like it's trying to support
> the second invariant, but it doesn't quite: if the types 
> don't match, the type checker will just set T to the 
> common base type of the two arguments.

Is there a way to write the second invariant correctly?

--

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset e959dd9f5c1d8865d4e10c49eb30ee0a4fe2735d by Dong-hee Na in branch 
'main':
bpo-46323 Fix ref leak if ctypes.CFuncPtr raises an error. (GH-31209)
https://github.com/python/cpython/commit/e959dd9f5c1d8865d4e10c49eb30ee0a4fe2735d


--

___
Python tracker 

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



[issue46282] return value of builtins is not clearly indicated

2022-02-07 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> New learners coming to Python don't know the same things
> as people with experience.

IMO, new learners will be worse off by adding "returns None" to all of the 
builtins.  At best it a distractor.

I work with new learners almost every day.  The issue never arises.  No one 
writes "x = print('hello world')" and they would be worse off if shown such a 
possibility.

One other consideration is that MyPy and the tools that use it (such as 
PyCharm) reject the idea of None as return value.  Their view is that no value 
is returned all.  We don't want the docs to contradict that world view.

  $ cat hello.py
  x = print('hello world')
  $ mypy hello.py
  hello.py:1: error: "print" does not return a value
  Found 1 error in 1 file (checked 1 source file)

--
nosy: +rhettinger

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread Dong-hee Na


Dong-hee Na  added the comment:

@vstinner

PR 31209 is for fixing the leak.

--

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread Dong-hee Na


Change by Dong-hee Na :


--
pull_requests: +29379
pull_request: https://github.com/python/cpython/pull/31209

___
Python tracker 

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



[issue46647] `test_functools` unexpected failures when C `_functoolsmodule` is missing

2022-02-07 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

> Or maybe you have other cases to show the functools module will missing 
> unexpectly?

No, I can't think of any :)

Your argument about code churn also makes sense.
But, if we ever are going to refactor this test module, this is something to 
remember of.

Thanks everyone!

--
resolution:  -> wont fix
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



[issue46159] Segfault when using trace functions in 3.11a3

2022-02-07 Thread Alex Gaynor


Alex Gaynor  added the comment:

It seems to no longer be crashing with alpha5. Hopefully it's actually fixed 
and not merely having a more subtle failure mode.

--

___
Python tracker 

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



[issue46662] Lib/sqlite3/dbapi2.py: convert_timestamp function failed to correctly parse timestamp

2022-02-07 Thread Ned Deily


Change by Ned Deily :


--
nosy: +erlendaasland

___
Python tracker 

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



[issue34191] argparse: Missing subparser error message should be more clear

2022-02-07 Thread Ned Deily


Change by Ned Deily :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> argparse fails with required subparsers, un-named dest, and 
empty argv

___
Python tracker 

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



[issue45948] Unexpected instantiation behavior for xml.etree.ElementTree.XMLParser(target=None)

2022-02-07 Thread Ned Deily


Change by Ned Deily :


--
nosy: +eli.bendersky, scoder

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread Dong-hee Na


Dong-hee Na  added the comment:

No leak after if I revert PR 31188 on my local

--

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread Dong-hee Na


Dong-hee Na  added the comment:

@vstinner

PR 31188 cause reference leak, please check

Raised RLIMIT_NOFILE: 256 -> 1024
0:00:00 load avg: 5.38 Run tests sequentially
0:00:00 load avg: 5.38 [1/1] test_ctypes
beginning 6 repetitions
123456
..
test_ctypes leaked [1028, 1026, 1028] references, sum=3082
test_ctypes leaked [2, 1, 3] memory blocks, sum=6
test_ctypes failed (reference leak)

== Tests result: FAILURE ==

1 test failed:
test_ctypes

Total duration: 3.2 sec
Tests result: FAILURE

--

___
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-07 Thread Filipe Laíns

Filipe Laíns  added the comment:

I agree.

--

___
Python tracker 

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



[issue46543] Add sys._getfunc

2022-02-07 Thread Barry A. Warsaw


Barry A. Warsaw  added the comment:

> Usually the calling function object should be enough.

I want to at least provide some historical context on why sys._getframe() 
exists.  I originally wrote that to support PEP 292 and internationalization in 
Mailman.  This has since been extracted into the flufl.i18n package.  Here is 
the use of sys._getframe() in that library:

https://gitlab.com/warsaw/flufl.i18n/-/blob/main/src/flufl/i18n/_translator.py#L65

You can see that the reason this exists is to dig out the local and globals of 
the context in which the _() function is invoked.  This greatly reduces the 
need to repeat yourself in i18n call sites.

https://flufli18n.readthedocs.io/en/stable/using.html#substitutions-and-placeholders

I'm not saying sys._getfunc() is or isn't useful, but it won't change original 
need for sys._getframe().

--
nosy: +barry

___
Python tracker 

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



[issue46639] Ceil division with math.ceildiv

2022-02-07 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Decimal is a good question.

Why does floor division not do floor division on Decimal? The 
documentation says

The integer division operator // behaves analogously, returning the 
integer part of the true quotient (truncating towards zero) rather 
than its floor, so as to preserve the usual identity 
x == (x // y) * y + x % y

but it's not clear why that identity is more important than floor 
division returning the floor.

I guess we could just document the difference and maybe add a 
Decimal ceildiv method, although that makes me sad :-(

Could we "fix" Decimal?

--

___
Python tracker 

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



[issue46678] Invalid cross device link in Lib/test/support/import_helper.py

2022-02-07 Thread miss-islington


miss-islington  added the comment:


New changeset da576e08296490e94924421af71001bcfbccb317 by Jason Wilkes in 
branch 'main':
bpo-46678: Fix Invalid cross device link in Lib/test/support/import_helper.py 
(GH-31204)
https://github.com/python/cpython/commit/da576e08296490e94924421af71001bcfbccb317


--

___
Python tracker 

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



[issue46678] Invalid cross device link in Lib/test/support/import_helper.py

2022-02-07 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 1.0 -> 2.0
pull_requests: +29378
pull_request: https://github.com/python/cpython/pull/31207

___
Python tracker 

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



[issue46659] Deprecate locale.getdefaultlocale() function

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29377
pull_request: https://github.com/python/cpython/pull/31206

___
Python tracker 

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



[issue12029] Allow catching virtual subclasses in except clauses

2022-02-07 Thread Guido van Rossum


Guido van Rossum  added the comment:

Thanks you. I think it's reasonable to reject the feature request and instead 
update the docs, so let's do that.

--

___
Python tracker 

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



[issue43557] Deprecate getdefaultlocale(), getlocale() and normalize() functions

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue46659] Deprecate locale.getdefaultlocale() function

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 7a0486eaa98083e0407ff491872db6d7a0da2635 by Victor Stinner in 
branch 'main':
bpo-46659: calendar uses locale.getlocale() (GH-31166)
https://github.com/python/cpython/commit/7a0486eaa98083e0407ff491872db6d7a0da2635


--

___
Python tracker 

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



[issue12029] Allow catching virtual subclasses in except clauses

2022-02-07 Thread Irit Katriel


Irit Katriel  added the comment:

To summarise the discussion so far:

The arguments in favour of changing exception matching to match on virtual base 
classes are:

1. It is confusing that it doesn't follow issubclass semantics.
2. Two use cases were presented as practical motivation.
   - one in msg135521, which can be solved with the pattern in msg200418
   - one in msg200829, which is typically done with
 except:
 if condition:
  handle
 raise

The arguments against the change are
1. safety - calling python code from the exception propagation code
2. possible performance impact


I am not too worried about the performance of exception handling. I am also not 
impressed by the use cases.

For me it's mostly between the safety issue and the aesthetic language 
consistency issue. 

The code path from when a RAISE opcode executes and until control passes to an 
except clause, is a very sensitive one and I have a lot of sympathy to the 
position that we should just change the documentation to say that matching is 
on non-virtual base classes.  It is much easier to implement this feature than 
to predict how it would behave in all cases.

If we do decide to implement this, then I don't think the patch is the way we 
should do it. If the IsSubclass call fails, this should result in a "goto 
error", like when the match type is invalid: 
https://github.com/python/cpython/blob/7ba1cc8049fbcb94ac039ab02522f78177130588/Python/ceval.c#L3831

This means that the failure to determine whether the exception is a match is 
the dominant error, rather than something we print to the ether via the 
unraisablehook and interpret as non-match.

--

___
Python tracker 

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



[issue12029] Allow catching virtual subclasses in except clauses

2022-02-07 Thread Michael McCoy


Michael McCoy  added the comment:

Checking my comment history here, a past me was terribly bad at linking the
correct PR on github.This is the correct link:
https://github.com/python/cpython/pull/6461

On Mon, Feb 7, 2022 at 10:12 AM Guido van Rossum 
wrote:

>
> Guido van Rossum  added the comment:
>
> Fixing the version field. Since it's a feature, this could not go into any
> version before 3.11.
>
> Maybe Irit can look through the discussion and patch and see if there's
> value to doing this? (Feel free to decline!)
>
> --
> nosy: +iritkatriel
> versions: +Python 3.11 -Python 3.4, Python 3.5, Python 3.6, Python 3.7,
> Python 3.8, Python 3.9
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue46282] return value of builtins is not clearly indicated

2022-02-07 Thread Ned Batchelder


Ned Batchelder  added the comment:

> When you state the obvious...

Obvious to who? New learners coming to Python don't know the same things as 
people with experience.

--
nosy: +nedbat

___
Python tracker 

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



[issue46657] Add mimalloc memory allocator

2022-02-07 Thread Neil Schemenauer


Neil Schemenauer  added the comment:

My preference would be for --with-mimalloc=yes in an upcoming release. For 
platforms without the required stdatomic.h stuff, they can manually specify 
--with-mimalloc=no.  That will make them aware that a future release of Python 
might no longer build (if mimalloc is no longer optional).

A soft-landing for merging nogil is not a good enough reason to merge mimalloc, 
IMHO.  nogil may never be merged.  There should be some concrete and immediate 
advantage to switch to mimalloc.  The idea of using the "heap walking" to 
improve is cyclic GC is not concrete enough.  It's just an idea at this point.

I think the (small) performance win could be enough of a reason to merge.  This 
seems to be the most recent benchmark:

https://gist.github.com/pablogsal/8027937b71cd30f175ef7c885d3e

There is also the long-term maintenance issue.  So far, mimalloc upstream has 
been responsive.  The mimalloc code is not so huge or complicated that we 
couldn't maintain it (if for some reason it gets abandoned upstream).  However, 
I think we would prefer to maintain obmalloc rather than mimalloc, all else 
being equal.  Abandonment by the upstream seems fairly unlikely.  So, I'm not 
too concerned about maintenance.

--

___
Python tracker 

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



[issue46648] `test.test_urllib2.MiscTests.test_issue16464` flaky due to external connection

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

I close again the issue. The 3.8 backport is waiting for the Python 3.8 Release 
Manager approval.

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



[issue45413] Add install scheme for virtual environments

2022-02-07 Thread Steve Dower


Steve Dower  added the comment:

I think we want the scheme to be static and accessible on all platforms, like 
the others. So it probably should be 'nt_venv' and 'posix_venv' with 
additional/improved logic to help apps determine when they need each.

--
nosy: +steve.dower

___
Python tracker 

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



[issue46679] test.support.wait_process ignores timeout argument

2022-02-07 Thread Jason Wilkes


Change by Jason Wilkes :


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

___
Python tracker 

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



[issue46679] test.support.wait_process ignores timeout argument

2022-02-07 Thread Jason Wilkes


New submission from Jason Wilkes :

The function wait_process in Lib/test/support/__init__.py ignores its timeout 
argument. This argument is useful, for example, in tests that need to determine 
whether a deadlock has been fixed (e.g., in PR-30310). Will submit a pull 
request to fix this.

--
components: Tests
messages: 412793
nosy: notarealdeveloper
priority: normal
severity: normal
status: open
title: test.support.wait_process ignores timeout argument
type: behavior
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



[issue46678] Invalid cross device link in Lib/test/support/import_helper.py

2022-02-07 Thread Jason Wilkes


Change by Jason Wilkes :


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

___
Python tracker 

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



[issue46534] Implementing PEP 673 (Self type)

2022-02-07 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 7ba1cc8049fbcb94ac039ab02522f78177130588 by James Hilton-Balfe in 
branch 'main':
bpo-46534: Implement PEP 673 Self in typing.py (GH-30924)
https://github.com/python/cpython/commit/7ba1cc8049fbcb94ac039ab02522f78177130588


--

___
Python tracker 

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



[issue46678] Invalid cross device link in Lib/test/support/import_helper.py

2022-02-07 Thread Jason Wilkes


New submission from Jason Wilkes :

In Lib/test/support/import_helper.py, the function make_legacy_pyc makes a call 
to os.rename which can fail when the source and target live on different 
devices. This happens (for example) when PYTHONPYCACHEPREFIX is set to a 
directory on a different device from where temporary files are stored. 
Replacing os.rename with shutil.move fixes it. Will submit a PR.

--
components: Tests
messages: 412791
nosy: notarealdeveloper
priority: normal
severity: normal
status: open
title: Invalid cross device link in Lib/test/support/import_helper.py
type: behavior
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



[issue46648] `test.test_urllib2.MiscTests.test_issue16464` flaky due to external connection

2022-02-07 Thread miss-islington


miss-islington  added the comment:


New changeset 9539400390494f4930c245b3f98453592f4a1a8c by Miss Islington (bot) 
in branch '3.10':
[3.10] bpo-46648: Rewrite test_urllib2.test_issue16464() with a local HTTP 
server (GH-31186) (GH-31189)
https://github.com/python/cpython/commit/9539400390494f4930c245b3f98453592f4a1a8c


--

___
Python tracker 

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



[issue46586] In documentation contents enum.property erroneously links to built-in property

2022-02-07 Thread Éric Araujo

Éric Araujo  added the comment:

Using a substitution is necessary when we need code markup and a link.

For this bug, the simple ~ markup will be enough.

--

___
Python tracker 

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



[issue42548] debugger stops at breakpoint of `pass` that is not actually reached

2022-02-07 Thread Irit Katriel

Irit Katriel  added the comment:

Fine, I’ll reopen it for 3.9. However, realistically the release managers are 
unlikely to investigate how this bug got fixed between 3.9 and 3.11 so if you 
think this is important you might want to do that work.

--
resolution: out of date -> 
status: closed -> open
versions: +Python 3.9 -Python 3.7

___
Python tracker 

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



[issue46669] Add types.Self

2022-02-07 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

The conventional way is to write

def __exit__(
self,
__typ: type[BaseException] | None,
__exc: BaseException | None,
__tb: types.TracebackType | None,
) -> None: ...

But there are two invariants about how __exit__ works in practice that this 
doesn't capture:
1. The arguments are either all None, or none of them are
2. If they are not None, then the typ argument is the type of the exception 
passed to the exc argument

I believe these invariants are always true in 3.11 thanks to Irit's work, but 
previously there could be rare circumstances where they didn't hold. You 
probably know the details better than I do.

We could support the first invariant by using two overloads, one where the 
arguments are all None and one where they aren't. I don't think that's 
generally worth doing though: it's a lot of verbose code and doesn't fix many 
real problems.

Your suggested signature looks like it's trying to support the second 
invariant, but it doesn't quite: if the types don't match, the type checker 
will just set T to the common base type of the two arguments.

--

___
Python tracker 

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



[issue20779] Add pathlib.chown method

2022-02-07 Thread Jaspar S.


Jaspar S.  added the comment:

I would love to use chown for a pathlib Path, too.

It may not be used often, but if anyone want's to change all the os references 
from a file, it would be cool to have it on pathlib!

--
nosy: +y0urself

___
Python tracker 

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



[issue42548] debugger stops at breakpoint of `pass` that is not actually reached

2022-02-07 Thread Andy S


Andy S  added the comment:

Then maybe those RMs (for 3.9 and 3.10) should decide on their own? That should 
mean the bug should be reopened for them to get assigned to.

--

___
Python tracker 

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



[issue46677] TypedDict docs are incomplete

2022-02-07 Thread Jelle Zijlstra


New submission from Jelle Zijlstra :

https://docs.python.org/3.10/library/typing.html#typing.TypedDict

It says:

> To allow using this feature with older versions of Python that do not support 
> PEP 526, TypedDict supports two additional equivalent syntactic forms

But there is another reason to use the equivalent forms: if your keys aren't 
valid Python names. There's an example in typeshed that uses "in" (a keyword) 
as a TypedDict key, and I've seen others with keys that have hyphens in them.

Also:

- The docs mention attributes like `__required_keys__`, but don't clearly say 
what is in these attributes. We should document them explicitly with the 
standard syntax for attributes.
- There is no mention of one TypedDict inheriting from another.

--
assignee: docs@python
components: Documentation
messages: 412784
nosy: 97littleleaf11, AlexWaygood, Jelle Zijlstra, docs@python, sobolevn
priority: normal
severity: normal
status: open
title: TypedDict docs are incomplete
versions: Python 3.10, 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



[issue42548] debugger stops at breakpoint of `pass` that is not actually reached

2022-02-07 Thread Irit Katriel


Irit Katriel  added the comment:

It depends how risky the 3.9 release manager would consider the fix to be. The 
first step would be to find out which commit(s) fixed it.

--

___
Python tracker 

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



[issue42548] debugger stops at breakpoint of `pass` that is not actually reached

2022-02-07 Thread Andy S


Andy S  added the comment:

Can reproduce this on 3.9. Is the fact 3.9 is in `bugfix` status enough to 
backport any fixing changes from 3.11 (if that's true and the bug was fixed)?

--

___
Python tracker 

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



[issue46676] ParamSpec args and kwargs are not equal to themselves.

2022-02-07 Thread Gregory Beauregard


Change by Gregory Beauregard :


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

___
Python tracker 

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



[issue46676] ParamSpec args and kwargs are not equal to themselves.

2022-02-07 Thread Gregory Beauregard


New submission from Gregory Beauregard :

from typing import ParamSpec
P = ParamSpec("P")
print(P.args == P.args)  # False
print(P.kwargs == P.kwargs)  # False

ParamSpec args and kwargs are not equal to themselves; this can cause problems 
for unit tests and type introspection w/ e.g. `get_type_hints`.

I will fix this by adding an __eq__ method like other places in typing.py

--
components: Library (Lib)
messages: 412781
nosy: GBeauregard, Jelle Zijlstra
priority: normal
severity: normal
status: open
title: ParamSpec args and kwargs are not equal to themselves.
type: behavior
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



[issue46639] Ceil division with math.ceildiv

2022-02-07 Thread Mark Dickinson


Mark Dickinson  added the comment:

> Couldn't math.ceildiv(x, y) be implemented as -(-x//y) in a type-agnostic 
> fashion?

Ah, good point. Yes, that could work.

We'd have to decide what to do about Decimal if we took this approach, since 
the -(-x//y) trick doesn't work there. (Document the issue? Try to make things 
work for Decimal?)

--

___
Python tracker 

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



[issue46667] SequenceMatcher & autojunk - false negative

2022-02-07 Thread Tim Peters


Tim Peters  added the comment:

We can't change defaults without superb reason - Python has millions of users, 
and changing the output of code "that works" is almost always a non-starter.

Improvements to the docs are welcome.

In your example, try running this code after using autojunk=True:

pending = ""
for ch in first:
if ch in sm.bpopular:
if pending:
print(repr(pending))
pending = ""
else:
pending += ch
print(repr(pending))

That shows how `first` is effectively broken into tiny pieces given that the 
"popular" chaaracters act like walls. Here's the start of the output:

'\nUN'
'QUESTR'
'NG\nL'
'x'
'f'
'.'
'L'
'b'
"'"
'x'
'v'
'1500'
','

and on & on. `QUESTER' is the longest common contiguous substring remaining.

--

___
Python tracker 

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



[issue12029] Allow catching virtual subclasses in except clauses

2022-02-07 Thread Guido van Rossum


Guido van Rossum  added the comment:

Fixing the version field. Since it's a feature, this could not go into any 
version before 3.11.

Maybe Irit can look through the discussion and patch and see if there's value 
to doing this? (Feel free to decline!)

--
nosy: +iritkatriel
versions: +Python 3.11 -Python 3.4, Python 3.5, Python 3.6, 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



[issue46669] Add types.Self

2022-02-07 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Implementing PEP 673 (Self type)

___
Python tracker 

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



[issue46668] encodings: the "mbcs" alias doesn't work

2022-02-07 Thread Eryk Sun


Eryk Sun  added the comment:

> I don't think that this fallback is needed anymore. Which Windows
> code page can be used as ANSI code page which is not already 
> implemented as a Python codec?

Python has full coverage of the ANSI and OEM code pages in the standard Windows 
locales, but I don't have any experience with custom (i.e. supplemental or 
replacement) locales.

https://docs.microsoft.com/en-us/windows/win32/intl/custom-locales 

Here's a simple script to check the standard locales.

import codecs
import ctypes
kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)

LOCALE_ALL = 0
LOCALE_WINDOWS = 1
LOCALE_IDEFAULTANSICODEPAGE = 0x1004
LOCALE_IDEFAULTCODEPAGE = 0x000B # OEM

EnumSystemLocalesEx = kernel32.EnumSystemLocalesEx
GetLocaleInfoEx = kernel32.GetLocaleInfoEx
GetCPInfoExW = kernel32.GetCPInfoExW

EnumLocalesProcEx = ctypes.WINFUNCTYPE(ctypes.c_int,
ctypes.c_wchar_p, ctypes.c_ulong, ctypes.c_void_p)

class CPINFOEXW(ctypes.Structure):
 _fields_ = (('MaxCharSize', ctypes.c_uint),
 ('DefaultChar', ctypes.c_ubyte * 2),
 ('LeadByte', ctypes.c_ubyte * 12),
 ('UnicodeDefaultChar', ctypes.c_wchar),
 ('CodePage', ctypes.c_uint),
 ('CodePageName', ctypes.c_wchar * 260))

def get_all_locale_code_pages():
result = []
seen = set()
info = (ctypes.c_wchar * 100)()

@EnumLocalesProcEx
def callback(locale, flags, param):
for lctype in (LOCALE_IDEFAULTANSICODEPAGE, 
LOCALE_IDEFAULTCODEPAGE):
if (GetLocaleInfoEx(locale, lctype, info, len(info)) and
  info.value not in ('0', '1')):
cp = int(info.value)
if cp in seen:
continue
seen.add(cp)
cp_info = CPINFOEXW()
if not GetCPInfoExW(cp, 0, ctypes.byref(cp_info)):
cp_info.CodePage = cp
cp_info.CodePageName = str(cp)
result.append(cp_info)
return True

if not EnumSystemLocalesEx(callback, LOCALE_WINDOWS, None, None):
raise ctypes.WinError(ctypes.get_last_error())

result.sort(key=lambda x: x.CodePage)
return result

supported = []
unsupported = []
for cp_info in get_all_locale_code_pages():
cp = cp_info.CodePage
try:
codecs.lookup(f'cp{cp}')
except LookupError:
unsupported.append(cp_info)
else:
supported.append(cp_info)

if unsupported:
print('Unsupported:\n')
for cp_info in unsupported:
print(cp_info.CodePageName)
print('\nSupported:\n')
else:
print('All Supported:\n')
for cp_info in supported:
print(cp_info.CodePageName)


Output:

All Supported:

437   (OEM - United States)
720   (Arabic - Transparent ASMO)
737   (OEM - Greek 437G)
775   (OEM - Baltic)
850   (OEM - Multilingual Latin I)
852   (OEM - Latin II)
855   (OEM - Cyrillic)
857   (OEM - Turkish)
862   (OEM - Hebrew)
866   (OEM - Russian)
874   (ANSI/OEM - Thai)
932   (ANSI/OEM - Japanese Shift-JIS)
936   (ANSI/OEM - Simplified Chinese GBK)
949   (ANSI/OEM - Korean)
950   (ANSI/OEM - Traditional Chinese Big5)
1250  (ANSI - Central Europe)
1251  (ANSI - Cyrillic)
1252  (ANSI - Latin I)
1253  (ANSI - Greek)
1254  (ANSI - Turkish)
1255  (ANSI - Hebrew)
1256  (ANSI - Arabic)
1257  (ANSI - Baltic)
1258  (ANSI/OEM - Viet Nam)

Some locales are Unicode only (e.g. Hindi-India) or have no OEM code page, 
which the above code skips by checking for "0" or "1" as the code page value. 
Windows 10+ allows setting the system locale to a Unicode-only locale, for 
which it uses UTF-8 (65001) for ANSI and OEM.

The OEM code page matters because the console input and output code pages 
default to OEM, e.g. for os.device_encoding(). The console's I/O code pages are 
used in Python by low-level os.read() and os.write(). Note that the console 
doesn't properly implement using UTF-8 (65001) as the input code page. In this 
case, input read from the console via ReadFile() or ReadConsoleA() has a null 
byte in place of each non-ASCII character.

--

___
Python tracker 

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



[issue45459] Limited API support for Py_buffer

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29372
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/31201

___
Python tracker 

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



[issue45459] Limited API support for Py_buffer

2022-02-07 Thread rdb


Change by rdb :


--
nosy: +rdb

___
Python tracker 

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



[issue12029] Allow catching virtual subclasses in except clauses

2022-02-07 Thread Václav Dvořák

Change by Václav Dvořák :


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



[issue45459] Limited API support for Py_buffer

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

> There's some side effects with "buffer.h" inclusion in Panda3D when building 
> againt 3.11a5, project manager concerns are here 
> https://github.com/python/cpython/pull/29991#issuecomment-1031731100

Copy of rdb's message:
"""
This change broke our project build because when cpython/object.h is including 
buffer.h it is forcing it to resolve along the search path, and the compiler is 
hitting the buffer.h in our project rather than the one in the Python include 
directory.

Should it not be using a relative include, ie. #include "../buffer.h" ? I think 
otherwise this change will cause breakage for many projects given how common 
the header name "buffer.h" may be.
"""

In Python.h, buffer.h is included before object.h. But object.h includes 
buffer.h. I suggest to include buffer.h before object.h and remove #include 
"buffer.h" from Include/cpython/buffer.h.

Also, I agree that renaming buffer.h to pybuffer.h would reduce issues like 
that. Moreover, this header file exposes the "Py_buffer" API, so "pybuffer.h" 
sounds like a better name ;-)

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue46638] Inconsistent registry virtualization in Windows Store package

2022-02-07 Thread Steve Dower


Steve Dower  added the comment:


New changeset 76b072717a160c44cb8d54be3d5e878bc31f2c38 by Miss Islington (bot) 
in branch '3.9':
bpo-46638: Makes registry virtualisation setting stable when building MSIX 
packages (GH-31130)
https://github.com/python/cpython/commit/76b072717a160c44cb8d54be3d5e878bc31f2c38


--

___
Python tracker 

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



[issue45459] Limited API support for Py_buffer

2022-02-07 Thread pmp-p


pmp-p  added the comment:

There's some side effects with "buffer.h" inclusion in Panda3D when building 
againt 3.11a5, project manager concerns are here 
https://github.com/python/cpython/pull/29991#issuecomment-1031731100

--

___
Python tracker 

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



[issue46638] Inconsistent registry virtualization in Windows Store package

2022-02-07 Thread miss-islington


miss-islington  added the comment:


New changeset 9c45390208df712126c59f7c2b6f8d2b4e19ccf7 by Miss Islington (bot) 
in branch '3.10':
bpo-46638: Makes registry virtualisation setting stable when building MSIX 
packages (GH-31130)
https://github.com/python/cpython/commit/9c45390208df712126c59f7c2b6f8d2b4e19ccf7


--

___
Python tracker 

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



[issue12029] Allow catching virtual subclasses in except clauses

2022-02-07 Thread Václav Dvořák

Change by Václav Dvořák :


--
nosy: +Václav Dvořák

___
Python tracker 

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



[issue46669] Add types.Self

2022-02-07 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

On a related note, is this the correct way to annotate __exit__?


Exc = TypeVar('Exc', bound=Exception)

def __exit__(self, exctype: Optional[Type[Exc]], excinst: Optional[Exc], exctb: 
Any) -> None:

--

___
Python tracker 

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



[issue41021] ctypes callback with structure crashes in Python 3.8 on Windows x86

2022-02-07 Thread Steve Dower


Steve Dower  added the comment:

Only by following the link I posted and searching for issues that sound like 
this one.

Which I just did for you: https://github.com/libffi/libffi/issues/367

There may be more, though. I just grabbed the first one that looked like a 
match.

--

___
Python tracker 

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



[issue46638] Inconsistent registry virtualization in Windows Store package

2022-02-07 Thread Steve Dower


Steve Dower  added the comment:


New changeset 3a5afc14e16370c1f4f72d43cb553298ad9a1fa4 by Steve Dower in branch 
'main':
bpo-46638: Makes registry virtualisation setting stable when building MSIX 
packages (GH-31130)
https://github.com/python/cpython/commit/3a5afc14e16370c1f4f72d43cb553298ad9a1fa4


--

___
Python tracker 

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



[issue46638] Inconsistent registry virtualization in Windows Store package

2022-02-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29371
pull_request: https://github.com/python/cpython/pull/31200

___
Python tracker 

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



[issue46638] Inconsistent registry virtualization in Windows Store package

2022-02-07 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +29370
pull_request: https://github.com/python/cpython/pull/31199

___
Python tracker 

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



[issue46072] Unify handling of stats in the CPython VM

2022-02-07 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 9c979d7afd839abbb080028bdfeb73727e5cf633 by Mark Shannon in 
branch 'main':
bpo-46072: Merge dxpairs into py_stats. (GH-31197)
https://github.com/python/cpython/commit/9c979d7afd839abbb080028bdfeb73727e5cf633


--

___
Python tracker 

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



[issue46166] [C API] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a89772c79183e3e62bf61b92077a04f6ebcc4a2b by Victor Stinner in 
branch 'main':
bpo-46166: Fix compiler warnings in What's New in Python 3.11 (GH-31198)
https://github.com/python/cpython/commit/a89772c79183e3e62bf61b92077a04f6ebcc4a2b


--

___
Python tracker 

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



[issue46647] `test_functools` unexpected failures when C `_functoolsmodule` is missing

2022-02-07 Thread Hai Shi


Hai Shi  added the comment:

> _functoolsmodule is a core bootstrap module and defined in 
> Modules/Setup.bootstrap. It has no external dependencies. There is no reason 
> and no point to disable the module.

+1. 

> Cristian, in this case - is there a reason to keep `skipUnless(c_functools)` 
> around? 
> If we are sure that it is always available - then it should be always tested. 

Hm. Personally, I suggest to keep the `skipUnless` to aovid the code churn.
Or maybe you have other cases to show the functools module will missing 
unexpectly?

--

___
Python tracker 

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



[issue45459] Limited API support for Py_buffer

2022-02-07 Thread pmp-p


Change by pmp-p :


--
nosy: +pmpp

___
Python tracker 

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



[issue46655] typing.TypeAlias is not in the list of allowed plain _SpecialForm typeforms

2022-02-07 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset e2eeffefed32bb8c47c09bdd94e27a4e949894ef by Gregory Beauregard in 
branch '3.10':
[3.10] bpo-46655: allow stringized TypeAlias with get_type_hints (GH-31156). 
(#31175)
https://github.com/python/cpython/commit/e2eeffefed32bb8c47c09bdd94e27a4e949894ef


--

___
Python tracker 

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



[issue46166] [C API] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
title: Get "self" args or non-null co_varnames from frame object with C-API -> 
[C API] Get "self" args or non-null co_varnames from frame object with C-API

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread hydroflask


hydroflask  added the comment:

Just to clarify further, the original benchmark by corona10 did indeed lead to 
`_CallPythonObject` being invoked but it was not quite the normal use-case. In 
the original benchmark it invoked the generated ctypes thunk via Python so as 
vstinner said it was doing this:

Python -> converters -> thunk-> _CallPythonObject -> converters-> Python

Namely using `PyCFuncPtr_call` to invoke the thunk generated by 
`_ctypes_alloc_callback`. Normally when invoking C functions via 
`PyCFuncPtr_call` it looks like this:

Python -> converters -> C_function

In the original benchmark setup no significant reduction in runtime was 
observed by this patch.  I noticed that it was not a typical use of 
`_CallPythonObject`, where instead it would be a top-level C function calling 
back into Python. Something like this:

C -> thunk -> _CallPythonObject() -> Python

The benchmark I provided exercises that use case and the >=10% reduction in 
runtime was observed. Thanks to both corona10 and vstinner, I appreciate their 
effort in this issue.

--

___
Python tracker 

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



[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

I proposed GH-31198 to fix the compiler warnings in the doc.

--

___
Python tracker 

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



[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

> Is there anyway to get the PyObject* associated with a PyFrameObject*?

Ah. I see. If you pass a PyFrameObject* frame to PyObject_GetAttrString(), you 
get a compiler warning.

You should cast it explicitly: PyObject_GetAttrString((PyObject*)frame, 
"f_locals").

--

___
Python tracker 

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



[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

Example of C code that I added to _testcapi:
---
static PyObject *
get_caller_locals(PyObject *self, PyObject *Py_UNUSED(args))
{
PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get());
if (frame == NULL) {
Py_RETURN_NONE;
}
return PyObject_GetAttrString(frame, "f_locals");
}
---

Python example:
---
import _testcapi

def f():
x = 1
y = 2
print(_testcapi.get_caller_locals())

f()
---

Output on Python 3.11:
---
{'x': 1, 'y': 2}
---

=> it just works.

A PyFrameObject is a regular Python object, you can use functions like 
PyObject_GetAttrString().

Maybe I missed something, correct me if I'm wrong.

--

___
Python tracker 

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



[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread Aaron Gokaslan


Aaron Gokaslan  added the comment:

The frame object I am referring to was:

PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get());

This frame can not be used with PyObject_GetAttrString. Is there anyway to get 
the PyObject* associated with a PyFrameObject*? It seems weird that some 
functionality is just not accessible using the Stable ABI of 
PyThreadState_GetFrame . 

To elabroate: I was referring to the migration guide in the changelog btw:

f_code: removed, use PyFrame_GetCode() instead. Warning: the function 
returns a strong reference, need to call Py_DECREF().

f_back: changed (see below), use PyFrame_GetBack().

f_builtins: removed, use PyObject_GetAttrString(frame, "f_builtins").
  
// this frame object actually has to be a PyObject*, the old one was a  
PyFrameObject* . Dropping this in does not work. 
f_globals: removed, use PyObject_GetAttrString(frame, "f_globals").

f_locals: removed, use PyObject_GetAttrString(frame, "f_locals").

f_lasti: removed, use PyObject_GetAttrString(frame, "f_lasti").


I tried importing sys._getframe(), but that gave an attribute error 
interestingly enough. Run a full code snippit here works: 
https://github.com/pybind/pybind11/blob/96b943be1d39958661047eadac506745ba92b2bc/include/pybind11/pybind11.h#L2429,
 but is really slow and we would like avoid having to rely on it. Not to 
mention relying on a function that is an starts with an underscore seems like 
it really should be avoided.

--

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

Oh ok, thanks for the clarification :-)

--

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread hydroflask


hydroflask  added the comment:

> A benchmark on calling C functions using ctypes sounds better than a 
> benchmark calling Python functions.

Calling C functions from Python is not the code path handled by 
_CallPythonObject() so no difference in run-time would theoretically be 
observed by that benchmark for this patch. This bug report pertains to code 
paths where a C function calls back into a Python function. A practical example 
is using Python with an event loop library written in C.

--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f20ca766fe404a20daea29230f161a0eb71bb489 by Victor Stinner in 
branch 'main':
bpo-46670: Fix #ifdef in sha3module.c (GH-31180)
https://github.com/python/cpython/commit/f20ca766fe404a20daea29230f161a0eb71bb489


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 7d8b69e1d1f125454d8cec81ff0dee72f2bef957 by Victor Stinner in 
branch 'main':
bpo-46670: Remove unused macros in the Python directory (GH-31192)
https://github.com/python/cpython/commit/7d8b69e1d1f125454d8cec81ff0dee72f2bef957


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 760349198dbd8771629753e096a885c1aa28a1ca by Victor Stinner in 
branch 'main':
bpo-46670: Remove unused macros in the Objects directory (GH-31193)
https://github.com/python/cpython/commit/760349198dbd8771629753e096a885c1aa28a1ca


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 4f1d3f33dd8b37a151b73533f18b08b0500223e5 by Victor Stinner in 
branch 'main':
 bpo-46670: Remove unused macros in the Modules directory (GH-31194)
https://github.com/python/cpython/commit/4f1d3f33dd8b37a151b73533f18b08b0500223e5


--

___
Python tracker 

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



[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d3e53bc5321a9f08c7ed5b9383eefb2e03dfa6e2 by Victor Stinner in 
branch 'main':
bpo-39277: Fix PY_TIMEOUT_MAX cast in _threadmodule.c (GH-31195)
https://github.com/python/cpython/commit/d3e53bc5321a9f08c7ed5b9383eefb2e03dfa6e2


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 4b603f628207b380a8a2f22d7ff5d2dbb0853e2e by Victor Stinner in 
branch 'main':
bpo-46670: Remove unused macros in ceval.c (GH-31196)
https://github.com/python/cpython/commit/4b603f628207b380a8a2f22d7ff5d2dbb0853e2e


--
nosy: +Mark.Shannon

___
Python tracker 

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



[issue46667] SequenceMatcher & autojunk - false negative

2022-02-07 Thread Jonathan


Jonathan  added the comment:

I still don't get how UNIQUESTRING is the longest even with autojunk=True, but 
that's an implementation detail and I'll trust you that it's working as 
expected.

Given this, I'd suggest the following then:

* `Autojunk=False` should be the default unless there's some reason to believe 
SequenceMatcher is mostly used for code comparisons.

* If - for whatever reason - the default can't be changed, I'd suggest a nice 
big docs "Warning" (at a minimum a "Note") saying something like "The default 
autojunk=True is not suitable for normal string comparison. See autojunk for 
more information".

* Human-friendly doc explanation for autojunk. The current explanation is only 
going to be helpful to the tiny fraction of users who understand the algorithm. 
Your explanation is a good start:
"Autojunk was introduced as a way to greatly speed comparing files of 
code, viewing them as sequences of lines. But it more often backfires when 
comparing strings (viewed as sequences of characters)"

Put simply: The current docs aren't helpful to users who don't have text 
matching expertise, nor do they emphasise the huge caveat that autojunk=True 
raises.

--

___
Python tracker 

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



[issue46639] Ceil division with math.ceildiv

2022-02-07 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I don't understand why math.ceildiv couldn't ducktype. There's no rule that 
says it *must* convert arguments to float first, that's just a convention, and 
we've broken it before.

>>> math.prod([Fraction(1, 3), 7])
Fraction(7, 3)

Couldn't math.ceildiv(x, y) be implemented as -(-x//y) in a type-agnostic 
fashion?


Perhaps it is too late in the night for me, but I have no idea what ceilrem(x, 
y) would do or why anyone might want it.

I agree with Vladimir that the import thing is not an issue. If we can require 
an import for much more important functions as sin, cos, tan, log, etc, then 
requiring an import is not excessive for a function of secondary importance.

Feature-bloat: its taken 30 years for somebody to request ceildiv. At that 
rate, it will take another 500 years for us to catch up to mpz in terms of 
features/bloat. I'm not losing sleep over that :-)

--
nosy: +steven.daprano

___
Python tracker 

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



[issue46072] Unify handling of stats in the CPython VM

2022-02-07 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +29368
pull_request: https://github.com/python/cpython/pull/31197

___
Python tracker 

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



[issue46072] Unify handling of stats in the CPython VM

2022-02-07 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 062460e8fd54e53c9a1a6f175ef49c9d730851b8 by Mark Shannon in 
branch 'main':
bpo-46072: Improve LOAD_METHOD stats (GH-31104)
https://github.com/python/cpython/commit/062460e8fd54e53c9a1a6f175ef49c9d730851b8


--

___
Python tracker 

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



[issue46675] Allow more than 16 items in split-keys dicts and "virtual" object dicts.

2022-02-07 Thread Mark Shannon


Change by Mark Shannon :


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

___
Python tracker 

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



[issue46657] Add mimalloc memory allocator

2022-02-07 Thread Christian Heimes


Christian Heimes  added the comment:

References:

- C11 stdatomic.h https://en.cppreference.com/w/c/atomic
- mimalloc-atomic.h 
https://github.com/microsoft/mimalloc/blob/master/include/mimalloc-atomic.h
- MSVC Interlocked Variable Access 
https://docs.microsoft.com/de-de/windows/win32/sync/interlocked-variable-access

--

___
Python tracker 

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



[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-07 Thread Petr Viktorin


Petr Viktorin  added the comment:

> IMO this PEP is outdated for a long time.

It is not. Even if it is, it should be marked as such, and that is not a 
decision that should be done in this issue.

Please, don't break the rules because you think they're outdated.

> Well, if you ask me, I would simply require a C99 compiler. That's all :-)

Please propose that change. Perhaps it would be a good change to make, but I 
don't even know how to determine that.
Nor can I list the places where the change should be made -- at least there 
should be a What's New entry like 
https://docs.python.org/3.10/whatsnew/3.6.html#build-and-c-api-changes

> Note: Python uses C11 , but it remains an optional requirement.

That's fine. You can still build with an older compiler.

--

___
Python tracker 

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



[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

> Well, if you ask me, I would simply require a C99 compiler. That's all :-)

Done in https://github.com/python/peps/pull/2309

--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29366
pull_request: https://github.com/python/cpython/pull/31196

___
Python tracker 

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



[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29365
pull_request: https://github.com/python/cpython/pull/31195

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

-Wexpansion-to-defined and -Wunused-macros options are also interesting.

--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29364
pull_request: https://github.com/python/cpython/pull/31194

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29363
pull_request: https://github.com/python/cpython/pull/31193

___
Python tracker 

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



  1   2   >