[issue46968] Insufficient sigaltstack size used by CPython prevents extensions from using new ISA

2022-03-09 Thread Kumar Aditya


Change by Kumar Aditya :


--
nosy: +vstinner

___
Python tracker 

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



[issue46881] Statically allocate and initialize the latin1 characters.

2022-03-09 Thread Kumar Aditya


Change by Kumar Aditya :


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

___
Python tracker 

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



[issue45319] Possible regression in __annotations__ descr for heap type subclasses

2022-03-09 Thread Larry Hastings


Larry Hastings  added the comment:

Graham: I'm happy to help.  I can write a more elaborate explanation of what's 
happening, or answer questions, whatever you like.  I'm a fan of wrapt so I'd 
certainly like to see this issue resolved.

And, seeing as you're the author and maintainer of wrapt, I assure you you've 
got more battle-won experience with object proxying than most 
developers--myself included.  You're *absolutely* the right person to 
ameliorate this issue!

--

___
Python tracker 

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



[issue45319] Possible regression in __annotations__ descr for heap type subclasses

2022-03-09 Thread Graham Dumpleton


Graham Dumpleton  added the comment:

I don't know about the comment "he has far more experience than I do with this 
sort of object proxying wizardry". I read what you said and my brain melted. I 
am getting too old for this and trying to understand how anything works anymore 
takes me ages. :-)

Anyway, will try and digest what you said a half dozen more times when my brain 
is working again and see if I can make sense of it.

--

___
Python tracker 

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



[issue45319] Possible regression in __annotations__ descr for heap type subclasses

2022-03-09 Thread Larry Hastings


Larry Hastings  added the comment:

(It's also possible your workaround where wrapt explicitly defines an 
"__annotations__" getset on every child of ObjectProxy is the right fix.  I 
don't know; I don't know the fine points of attribute access, like when does it 
access getsets on the type, vs getsets on base types, vs setattro, etc.)

--

___
Python tracker 

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



[issue45319] Possible regression in __annotations__ descr for heap type subclasses

2022-03-09 Thread Larry Hastings


Larry Hastings  added the comment:

This isn't a CPython bug.  It's a change in CPython behavior that wrapt needs 
to accommodate.  In particular, it isn't 'causing a regression for C subclasses 
of heap types when the parent class has an "__annotations__" descriptor', nor 
do child classes have any difficulty inheriting the descriptor of their parent 
classes.  That's unsurprising; after all, if I had broken child classes 
inheriting the descriptors of their parent classes, a lot more would have 
broken than just wrapt.

The problem is in WraptObjectProxy_setattro().  (Which--just to drive my point 
home--*is* getting called when you set __annotations__ on one of wrapt's 
various proxy objects.)  WraptObjectProxy_setattro() proxies setattr calls for 
wrapped objects to the original object--if "o" is a wrapt proxy object wrapping 
"fn", and you run "o.__annotations__ = x", it should actually execute 
"fn.__annotations__ = x" under the covers.

Except WraptObjectProxy_setattro() executes *this* code first, starting at line 
1531 in my copy of _wrapped.c:

if (PyObject_HasAttr((PyObject *)Py_TYPE(self), name))
return PyObject_GenericSetAttr((PyObject *)self, name, value);

If the *type* has the attribute, then it doesn't proxy the setattr to the 
wrapped object.  Instead it does a "generic setattr" on the object itself.

PyObject_HasAttr works by attempting a getattr on the type.  If that getattr 
call succeeds, PyObject_HasAttr returns true.  The type here is FunctionWrapper 
(WraptFunctionWrapper_Type).  Since we're now looking it up on this type 
object, we use the type of the type object, which is "type", to access the 
attribute.  And getting the "__annotations__" attribute from an object of type 
"type" means calling type_get_annotations(), a new descriptor which ensures 
that the annotations dict always exists, which means the HasAttr call succeeds 
and returns true.  In short, this change to the semantics of the 
"__annotations__" attribute means wrapt no longer proxies the setattr to the 
underlying wrapped object when setting the "__annotations__" attribute on *any* 
of its objects.

In my opinion, wrapt needs to accommodate this new behavior.  In my testing I 
changed the above code to this:

if (!annotations_str) {
annotations_str = PyUnicode_InternFromString("__annotations__");
}

if (PyObject_RichCompareBool(name, annotations_str, Py_NE)
&& PyObject_HasAttr((PyObject *)Py_TYPE(self), name))
return PyObject_GenericSetAttr((PyObject *)self, name, value);

I also declared

static PyObject *annotations_str = NULL;

at the top of the function.  With that change in place, the tests now passed.

My hunch is, this approach is more or less what wrapt should do.  It *might* be 
undersophisticated; it's possible that there are classes out there playing 
their own weird descriptor tricks with the "__annotations__" attribute.  
Perhaps the fix needs to be on a case-by-case basis, based on the type of the 
wrapped object.  Anyway this is obviously up to Graham, which is for the best 
anyway--he has far more experience than I do with this sort of object proxying 
wizardry.

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



[issue36709] Asyncio SSL keep-alive connections raise errors after loop close.

2022-03-09 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Thanks!

--
resolution:  -> fixed
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



[issue45033] Calls to PyErr_PrintEx in destructors cause calling async functions to incorrectly return None

2022-03-09 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

'catch (boost::python::error_already_set e)' is equal to `except BaseException 
as e:`
In Python, blind catching base exception is dangerous, the code should re-raise 
it usually.
The same is true for boost::python usage.

> how would it tell the difference between a "real" exception raised from 
> within whatever function is currently returning and the "fake" StopIteration 
> exception that is in the error global while an async function returns?

There is no "fake" exception. async function is a kind of Python generator 
object that uses StopIteration exception for finishing.
The same is true for a regular Python iterator; nothing asyncio specific.

I suggest writing a functional equivalent for `except Exception as e: print(e)` 
instead of catching BaseException error.

--

___
Python tracker 

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



[issue33886] SSL on aiomysql hangs on reconnection

2022-03-09 Thread Andrew Svetlov


Change by Andrew Svetlov :


--
resolution:  -> fixed
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



[issue30740] SSLError when cancelling an SSL connection

2022-03-09 Thread Andrew Svetlov


Change by Andrew Svetlov :


--
resolution:  -> fixed
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



[issue46970] dataclass(slots=True) incompatible with __init_subclass__

2022-03-09 Thread Eric V. Smith


Eric V. Smith  added the comment:

This appears to be due to dataclasses needing to create a new class in order to 
set __slots__. I'll look at it, but I doubt there's anything that can be done.

attrs has the same issue:
  File "x/.local/lib/python3.8/site-packages/attr/_make.py", line 889, in 
_create_slots_class
cls = type(self._cls)(self._cls.__name__, self._cls.__bases__, cd)
TypeError: __init_subclass__() missing 1 required positional argument: 'msg'

--
assignee:  -> eric.smith
type: crash -> behavior

___
Python tracker 

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



[issue46970] dataclass(slots=True) incompatible with __init_subclass__

2022-03-09 Thread Guido Imperiale


Change by Guido Imperiale :


--
type:  -> crash

___
Python tracker 

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



[issue46970] dataclass(slots=True) incompatible with __init_subclass__

2022-03-09 Thread Guido Imperiale


Change by Guido Imperiale :


--
nosy: +eric.smith

___
Python tracker 

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



[issue46970] dataclass(slots=True) incompatible with __init_subclass__

2022-03-09 Thread Guido Imperiale


New submission from Guido Imperiale :

Related to #46382
A class decorated with dataclass(slots=True) can't pass any parameters to the 
__init_subclass__ method of its parent class.


from dataclasses import dataclass

class A:
__slots__ = ()
def __init_subclass__(cls, msg):
print(msg)

@dataclass(slots=True)
class B(A, msg="Hello world!"):
pass


  File "lib/python3.10/dataclasses.py", line 1145, in _add_slots
cls = type(cls)(cls.__name__, cls.__bases__, cls_dict)
TypeError: A.__init_subclass__() missing 1 required positional argument: 'msg'

--
components: Library (Lib)
messages: 414822
nosy: crusaderky
priority: normal
severity: normal
status: open
title: dataclass(slots=True) incompatible with __init_subclass__
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



[issue24132] Direct sub-classing of pathlib.Path

2022-03-09 Thread Barney Gale


Barney Gale  added the comment:

If/when GH-31691 lands, I think this bug can be resolved: the original repro 
case will no longer raise AttributeError, and subclasses will be able to 
customize behaviour without needing to define further "flavour" or "accessor" 
subclasses.

--

___
Python tracker 

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



[issue46785] On Windows, os.stat() can fail if called while another process is creating or deleting the file

2022-03-09 Thread Itai Steinherz


Itai Steinherz  added the comment:

I'd like to work on this, however I'm not sure how this could be unit-tested. 
Any ideas?

--
nosy: +itaisteinherz

___
Python tracker 

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



[issue46881] Statically allocate and initialize the latin1 characters.

2022-03-09 Thread miss-islington


miss-islington  added the comment:


New changeset 8714b6fa27271035dd6dd3514e283f92d669321d by Kumar Aditya in 
branch 'main':
bpo-46881: Statically allocate and initialize the latin1 characters. (GH-31616)
https://github.com/python/cpython/commit/8714b6fa27271035dd6dd3514e283f92d669321d


--
nosy: +miss-islington

___
Python tracker 

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



[issue46967] Type union for except

2022-03-09 Thread Guido van Rossum


Guido van Rossum  added the comment:

I don't think that `except A|B` looks better than `except (A, B)`, so I am 
against this proposal. Exception matching is its own special thing (e.g. it 
doesn't honor virtual subclasses) and we shouldn't hyper-generalize.

--

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-09 Thread Alex Waygood

Alex Waygood  added the comment:

I agree with Jelle — a valid protocol cannot inherit from a concrete type, and 
the whole point of NamedTuple is that it creates a tuple subclass (and tuple is 
obviously a concrete type).

--

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-09 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

A NamedTuple that is also a Protocol doesn't make sense to me, since a 
NamedTuple is a concrete (nominal) type and a Protocol cannot inherit from a 
concrete type. If you want something like that to happen, it's better to open 
an issue on https://github.com/python/typing first, so this issue can stay 
focused on support for Generic + NamedTuple.

--

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-09 Thread Julius Park


Julius Park  added the comment:

What about Protocol? It is possible to create a dataclass that is a protocol, 
so it would be nicer from a symmetry perspective to allow it on both 
dataclasses and NamedTuples.

--

___
Python tracker 

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



[issue46969] `pip install wrapt` fails on ast.py in Python 3.11.0a6

2022-03-09 Thread Dutcho

New submission from Dutcho :

... or perhaps this is caused by *wrapt 1.13.3*?

'''
(venv) >pip install wrapt
Collecting wrapt
  Using cached wrapt-1.13.3.tar.gz (48 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [92 lines of output]
  Traceback (most recent call last):
File "...\venv\Lib\site-packages\setuptools\config.py", line 35, in 
__getattr__
  return next(
 ^
File "...\venv\Lib\site-packages\setuptools\config.py", line 36, in 

  ast.literal_eval(statement.value)
  ^
File "C:\Program Files\Python311\Lib\ast.py", line 108, in literal_eval
  return _convert(node_or_string)
 
File "C:\Program Files\Python311\Lib\ast.py", line 107, in _convert
  return _convert_signed_num(node)
 ^
File "C:\Program Files\Python311\Lib\ast.py", line 81, in 
_convert_signed_num
  return _convert_num(node)
 ^^
File "C:\Program Files\Python311\Lib\ast.py", line 72, in _convert_num
  _raise_malformed_node(node)
  ^^^
File "C:\Program Files\Python311\Lib\ast.py", line 69, in 
_raise_malformed_node
  raise ValueError(msg + f': {node!r}')
  ^
  ValueError: malformed node or string on line 2: 
'''

--
messages: 414814
nosy: Dutcho
priority: normal
severity: normal
status: open
title: `pip install wrapt` fails on ast.py in Python 3.11.0a6
type: behavior
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



[issue46967] Type union for except

2022-03-09 Thread Steven D'Aprano


Change by Steven D'Aprano :


--
nosy: +steven.daprano

___
Python tracker 

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



[issue45924] Incorrect traceback when future's exception is raised multiple times

2022-03-09 Thread Irit Katriel


Irit Katriel  added the comment:

Closed issue46954 as a duplicate of this.

--

___
Python tracker 

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



[issue46954] Awaiting multiple times on same task increases memory usage unboundedly

2022-03-09 Thread Irit Katriel


Irit Katriel  added the comment:

This is a duplicate of bpo-45924.  The traceback accumulates another frame 
every time the exception is raised. To see that, change main in your script to 

async def main():
task = asyncio.create_task(task_that_raise())
while True:
try:
await task
except Exception as e:
print("<<<")
traceback.print_exception(e)
print(">>>")



and notice that in the output, X grows every time in the line like

[Previous line repeated X more times]

--
nosy: +iritkatriel
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Incorrect traceback when future's exception is raised multiple 
times
versions:  -Python 3.7, Python 3.8

___
Python tracker 

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



[issue46943] fix[imaplib]: call Exception with string instance

2022-03-09 Thread Irit Katriel


Change by Irit Katriel :


--
versions:  -Python 3.7, Python 3.8

___
Python tracker 

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



[issue46967] Type union for except

2022-03-09 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

This would be nice but I'm not sure it's worth the hassle in terms of 
documentation, tooling support, etc.

There is an existing issue (that I can't find right now) that makes the 
`except` machinery use `__instancecheck__`, instead of looking only at real 
base classes like it does now. That change would automatically also make `|` 
work.

--

___
Python tracker 

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



[issue46896] add support for watching writes to selected dictionaries

2022-03-09 Thread Carl Meyer


Carl Meyer  added the comment:

> have you considered watching dict keys rather than whole dicts?

Just realized that I misunderstood this suggestion; you don't mean per-key 
watching necessarily, you just mean _not_ notifying on dict values changes. Now 
I understand better how that connects to the second part of your comment! But 
yeah, I don't want this limitation on dict watching use cases.

--

___
Python tracker 

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



[issue46968] Insufficient sigaltstack size used by CPython prevents extensions from using new ISA

2022-03-09 Thread Oleksandr Pavlyk


Change by Oleksandr Pavlyk :


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

___
Python tracker 

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



[issue46967] Type union for except

2022-03-09 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood, Jelle Zijlstra, gvanrossum, iritkatriel

___
Python tracker 

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



[issue46968] Insufficient sigaltstack size used by CPython prevents extensions from using new ISA

2022-03-09 Thread Oleksandr Pavlyk


New submission from Oleksandr Pavlyk :

The following snippet illustrates request by an extension to use AMX registers:

```
// no increase sigaltstack size fix will not wark till we fix python
void enable_amx_no_fix()
{

unsigned long bitmask;
long rc;

rc = syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_PERM, XFEATURE_XTILEDATA);
if (rc) {
printf("The kernel rejects the AMX use.\n");
printf("errno %d\n",errno);
} else {
printf("The kernel allows to use AMX.\n");
}


rc = syscall(SYS_arch_prctl, ARCH_GET_XCOMP_PERM, );

if (rc) {
printf("rc error\n");
} else  {
if (( bitmask & XFEATURE_MASK_XTILEDATA) == 0){
printf("verify AMX permission faild bitmask %ld\n",bitmask);
}

}
}
```

This request fails on the account of too small a size for sigaltstack used by 
CPython allocated in Modules/faulthandler.c

The stack size used is 2*SIGSTKSZ, and does not take hardware capabilities into 
account.

Linux kernel 5.14 adds support to query minimum size of sigaltstack dynamically 
via getauxval(AT_MINSIGSTKSZ).

AMX support is added in Linux kernel 5.16 

CPython should make use of this when built against more recent Linux kernels.

--
components: Extension Modules
messages: 414809
nosy: oleksandr-pavlyk
priority: normal
severity: normal
status: open
title: Insufficient sigaltstack size used by CPython prevents extensions from 
using new ISA
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



[issue46896] add support for watching writes to selected dictionaries

2022-03-09 Thread Carl Meyer


Carl Meyer  added the comment:

Hi Dennis, thanks for the questions!

> A curiosity: have you considered watching dict keys rather than whole dicts?

There's a bit of discussion of this above. A core requirement is to avoid any 
memory overhead and minimize CPU overhead on unwatched dicts. Additional memory 
overhead seems like a nonstarter, given the sheer number of dict objects that 
can exist in a large Python system. The CPU overhead for unwatched dicts in the 
current PR consists of a single added `testb` and `jne` (for checking if the 
dict is watched), in the write path only; I think that's effectively the 
minimum possible.

It's not clear to me how to implement per-key watching under this constraint. 
One option Brandt mentioned above is to steal the low bit of a `PyObject` 
pointer; in theory we could do this on `me_key` to implement per-key watching 
with no memory overhead. But then we are adding bit-masking overhead on every 
dict read and write. I think we really want the implementation here to be 
zero-overhead in the dict read path.

Open to suggestions if I've missed a good option here!

> That way, changing global values would not have to de-optimize, only adding 
> new global keys would.

> Indexing into dict values array wouldn't be as efficient as embedding direct 
> jump targets in JIT-generated machine code, but as long as we're not doing 
> that, maybe watching the keys is a happy medium?

But we are doing that, in the Cinder JIT. Dict watching here is intentionally 
exposed for use by extensions, including hopefully  in future the Cinder JIT as 
an installable extension. We burn exact pointer values for module globals into 
generated JIT code and deopt if they change (we are close to landing a change 
to code-patch instead of deopting.) This is quite a bit more efficient in the 
hot path than having to go through a layer of indirection.

I don't want to assume too much about how dict watching will be used in future, 
or go for an implementation that limits its future usefulness. The current PR 
is quite flexible and can be used to implement a variety of caching strategies. 
The main downside of dict-level watching is that a lot of notifications will be 
fired if code does a lot of globals-rebinding in modules where globals are 
watched, but this doesn't appear to be a problem in practice, either in our 
workloads or in pyperformance. It seems likely that a workable strategy if this 
ever was observed to be a problem would be to notice at runtime that globals 
are being re-bound frequently in a particular module and just stop watching 
that module's globals.

--

___
Python tracker 

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



[issue46965] Enable informing callee it's awaited via vector call flag

2022-03-09 Thread Vladimir Matveev


Change by Vladimir Matveev :


--
nosy: +v2m

___
Python tracker 

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



[issue46967] Type union for except

2022-03-09 Thread Henry Schreiner


New submission from Henry Schreiner :

In 3.10 via PEP 604, there was an attempt to use the new union of types where 
runtime types were previously expected to be a tuple. `isinstance(x, (A, B))` 
can be written `isinstance(x, A | B)`. Unfortunately, there still is a case 
were a tuple of types is required: `except (A, B) as err:` cannot be written 
`except A | B as err:`. I think this should be allowed; it is consistent with 
isinstance and pattern matching's use of |, and nicely avoids confusion with 
`except A, B:` which is disallowed for Python 2 reasons; `except A | B`: would 
be valid.

--
components: Interpreter Core
messages: 414807
nosy: Henry Schreiner
priority: normal
severity: normal
status: open
title: Type union for except
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



[issue45138] [sqlite3] expand bound values in traced statements when possible

2022-03-09 Thread miss-islington


miss-islington  added the comment:


New changeset e801e88744f34508aa338f9f7f3f3baee012f813 by Erlend Egeberg 
Aasland in branch 'main':
bpo-45138: Revert GH-28240: Expand traced SQL statements (GH-31788)
https://github.com/python/cpython/commit/e801e88744f34508aa338f9f7f3f3baee012f813


--
nosy: +miss-islington

___
Python tracker 

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



[issue46896] add support for watching writes to selected dictionaries

2022-03-09 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy: +gvanrossum

___
Python tracker 

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



[issue45138] [sqlite3] expand bound values in traced statements when possible

2022-03-09 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
pull_requests: +29892
pull_request: https://github.com/python/cpython/pull/31788

___
Python tracker 

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



[issue46965] Enable informing callee it's awaited via vector call flag

2022-03-09 Thread Brandt Bucher


Change by Brandt Bucher :


--
nosy: +brandtbucher

___
Python tracker 

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



[issue46966] c_void_p array is a footgun on I32LP64 systems

2022-03-09 Thread JP Sugarbroad


JP Sugarbroad  added the comment:

That matches our expectation. A subclass works - perhaps `c_void_p` could be 
deprecated in favor of a built-in subclass for generic opaque pointers as well?

Glad you agree that a warning would be useful here.

--

___
Python tracker 

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



[issue46896] add support for watching writes to selected dictionaries

2022-03-09 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

A curiosity: have you considered watching dict keys rather than whole dicts?

That way, changing global values would not have to de-optimize, only adding new 
global keys would.

Indexing into dict values array wouldn't be as efficient as embedding direct 
jump targets in JIT-generated machine code, but as long as we're not doing 
that, maybe watching the keys is a happy medium?

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue46896] add support for watching writes to selected dictionaries

2022-03-09 Thread Carl Meyer


Carl Meyer  added the comment:

Draft PR is up for consideration. Perf data in 
https://gist.github.com/carljm/987a7032ed851a5fe145524128bdb67a

Overall it seems like the base implementation is perf neutral -- maybe a slight 
impact on the pickle benchmarks? With all module global dicts (uselessly) 
watched, there are a few more benchmarks with small regressions, but also some 
with small improvements (just noise I guess?) -- overall still pretty close to 
neutral.

Comments welcome!

--

___
Python tracker 

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



[issue46896] add support for watching writes to selected dictionaries

2022-03-09 Thread Carl Meyer


Change by Carl Meyer :


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

___
Python tracker 

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



[issue25927] add dir_fd for mkstemp, and also maybe to all tempfile.*

2022-03-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There are two ways of supporting an open file descriptor to a directory:

1. Accept a file descriptor as the dir argument.
2. Add a new parameter dir_fd; dir will then be a path relative to dir_fd.

The original proposition is option 2. PR 31785 implements option 1. I am going 
to play with the code, implement option 2, and see what is simpler and what is 
more convenient.

Any thoughts or suggestions?

--

___
Python tracker 

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



[issue25927] add dir_fd for mkstemp, and also maybe to all tempfile.*

2022-03-09 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue40059] Provide a toml module in the standard library

2022-03-09 Thread miss-islington


miss-islington  added the comment:


New changeset 23dcea5de736b367c0244042aaca10971538b2b4 by Dominic Davis-Foster 
in branch 'main':
bpo-40059: Fix installation of tomllib (GH-31784)
https://github.com/python/cpython/commit/23dcea5de736b367c0244042aaca10971538b2b4


--
nosy: +miss-islington

___
Python tracker 

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



[issue40059] Provide a toml module in the standard library

2022-03-09 Thread Dominic Davis-Foster


Change by Dominic Davis-Foster :


--
nosy: +domdfcoding
nosy_count: 18.0 -> 19.0
pull_requests: +29889
pull_request: https://github.com/python/cpython/pull/31784

___
Python tracker 

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



[issue40059] Provide a toml module in the standard library

2022-03-09 Thread Dominic Davis-Foster


Dominic Davis-Foster  added the comment:

When building Python from source (as of the latest GitHub commit) the tomllib 
directory doesn't actually get copied over to the install prefix.

It looks like an entry's needed in Makefile.pre.in under LIBSUBDIRS, along the 
lines of https://github.com/python/cpython/pull/13563 and 
https://github.com/python/cpython/pull/30311

--
nosy: +dom1310df

___
Python tracker 

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



[issue46245] Add support for dir_fd in shutil.rmtree()

2022-03-09 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue46245] Add support for dir_fd in shutil.rmtree()

2022-03-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 02fbaf4887deaf0207a5805d3736e0124a694c14 by Serhiy Storchaka in 
branch 'main':
bpo-46245: Add optional parameter dir_fd in shutil.rmtree() (GH-30365)
https://github.com/python/cpython/commit/02fbaf4887deaf0207a5805d3736e0124a694c14


--

___
Python tracker 

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



[issue39951] Ignore specific errors when closing ssl connections

2022-03-09 Thread Christian Heimes


Christian Heimes  added the comment:

The bug should be fixed in 3.9 and 3.10 maintenance branches, too.

--
assignee: christian.heimes -> 
stage:  -> backport needed
versions: +Python 3.10, Python 3.9

___
Python tracker 

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



[issue37658] In some cases asyncio.wait_for can lead to socket leak.

2022-03-09 Thread Kumar Aditya


Kumar Aditya  added the comment:

@asvetlov Anything left to do here or can this be closed ?

--
nosy: +kumaraditya303

___
Python tracker 

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



[issue45138] [sqlite3] expand bound values in traced statements when possible

2022-03-09 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


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

___
Python tracker 

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



[issue30740] SSLError when cancelling an SSL connection

2022-03-09 Thread Kumar Aditya


Kumar Aditya  added the comment:

This is fixed on main branch with bpo-44011 and does not raises exception. This 
can be closed now @asvetlov.

--
nosy: +asvetlov, kumaraditya303
versions: +Python 3.11 -Python 3.6

___
Python tracker 

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



[issue33886] SSL on aiomysql hangs on reconnection

2022-03-09 Thread Kumar Aditya


Kumar Aditya  added the comment:

The main branch has rewritten ssl implementation with bpo-44011. This is 
outdated now and does not has a reproducer. This can be closed @asvetlov.

--
nosy: +kumaraditya303

___
Python tracker 

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



[issue39951] Ignore specific errors when closing ssl connections

2022-03-09 Thread Kumar Aditya


Kumar Aditya  added the comment:

@asvetlov This has been fixed on main branch with bpo-44011. This can be closed 
now.

--
nosy: +kumaraditya303
versions: +Python 3.11 -Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue45138] [sqlite3] expand bound values in traced statements when possible

2022-03-09 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

Ah, one of my very first contributions, bpo-40318, comes back to haunt me:

In bpo-40318, we migrated from the old SQLite trace API (sqlite3_trace) to 
SQLite trace v2 API (sqlite3_trace_v2). GH-19581, which introduced this change, 
introduced a bug: the old trace API _implicitly_ expanded bound parameters; the 
new trace API does not. However, there was no tests for this behaviour, so the 
regression was unnoticed[^1].

So, this bpo is actually a bug fix; not a feature. It should be backported to 
3.10, which contains the regression.

I'm preparing a fix for GH-28240, and I'll prepare a 3.10 backport including 
both GH-2840 and its upcoming fix.


[^1]: There has been no bug reports regarding this change in behaviour, so it 
seems to have gone under most people's radar.

--

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-09 Thread Alex Waygood


Alex Waygood  added the comment:

+1 for the more minimal changeset proposed in PR 31781. I've never felt a need 
for NamedTuple multiple inheritance other than with Generic, so wouldn't be 
opposed to restricting it only to Generic.

--

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 31781 is a simple PR which enables multiple inheritance with NamedTuple. As 
a side effect, it adds support of generic NamedTuple.

I am not sure that all details work as expected. It is easy to limit multiple 
inheritance only for Generic if needed.

--

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-09 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +29887
pull_request: https://github.com/python/cpython/pull/31781

___
Python tracker 

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



[issue46966] c_void_p array is a footgun on I32LP64 systems

2022-03-09 Thread Eryk Sun


Eryk Sun  added the comment:

> I'm not sure what can be done here (maybe a truncation warning?)

For a function pointer, the default argument conversion for Python integers is 
the platform int type. Ideally, Python integer arguments would be converted to 
a type that matches the platform word size, as is the default behavior for 
integer arguments in C. But the behavior can't be changed at this point. 
Ideally, it would behave the same in LP64 (Unix) and LLP64 (Windows) systems, 
but OverflowError is raised in LLP64 because ctypes first converts to a long 
int. OverflowError could be manually raised if `(unsigned long)value > 
UINT_MAX`, but I think it's also too late to make that change. Scripts have 
worked around the current behavior for about two decades. Raising a warning is 
really the best that could be done, if anything is done at all.

The best solution is to not use bare function pointers without setting the 
prototype. If a function pointer is created as an attribute of a CDLL instance, 
the common way to define the prototype is by setting the function's `argtypes` 
and `restype` attributes.

Another ctypes concept to be aware of is that subclasses of simple types do not 
get converted by default when accessed as C fields, array subscripts, or 
function results. For example:

class my_void_p(ctypes.c_void_p):
pass

>>> a = (my_void_p * 1)()
>>> isinstance(a[0], my_void_p)
True

--
nosy: +eryksun
versions:  -Python 3.7, Python 3.8

___
Python tracker 

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



[issue31370] Remove support for threads-less builds

2022-03-09 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue46964] The global config should not be stored on each interpreter

2022-03-09 Thread STINNER Victor


STINNER Victor  added the comment:

> Doing so unnecessarily adds extra complexity (and, when multiple interpreters 
> are used, extra CPU usage and extra memory usage).

Right, PyConfig allocates memory per interpeter. But IMO it's an acceptable 
trade-off. I don't see the benefits of sharing the config between all 
interpreters.

Have per-interpreter config allows to create an interpreter with a different 
config:

* different sys.path
* isolated vs non-isolated
* dev mode
* etc.

While there is currently no easy way to use a custom config, recent changes 
make it easier to implement, like the function to modify a PyConfig from a 
Python dict: _PyInterpreterState_SetConfig().


> there is no public API for getting the config or changing it

Barry Warsaw proposed to add a function to get the config, but I didn't add it.

There are private functions for that:

* _testinternalcapi.get_config()
* _testinternalcapi.set_config()

--

___
Python tracker 

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



[issue46953] use FASTCALL for __import__ builtin

2022-03-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What is the advantage of not touching a stable code?

It was never a performance critical part of the code. This is why it avoided 
multiple previous optimizations. It is still use PyArg_ParseTupleAndKeywords().

Of course now, when optimization is provided by Argument Clinic and its code is 
stable enough, we can do this. But performance was never a concern here.

--

___
Python tracker 

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



[issue45138] [sqlite3] expand bound values in traced statements when possible

2022-03-09 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

Reopening bco. broken buildbots.

--
status: closed -> open

___
Python tracker 

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