[issue47059] Mechanism to enable __weakref__ slot on dataclass(slots=True)

2022-03-18 Thread Arie Bovenberg
New submission from Arie Bovenberg : As discussed in bpo-46382, dataclasses may want to support the __weakref__ slot. Currently, automatically slotted dataclasses are not given a __weakref__ slot. This makes auto-slotted dataclasses incompatible with weakref. The attrs library has chosen

[issue46382] dataclass(slots=True) does not account for slots in base classes

2022-03-18 Thread Arie Bovenberg
Change by Arie Bovenberg : -- keywords: +patch pull_requests: +30070 stage: -> patch review pull_request: https://github.com/python/cpython/pull/31980 ___ Python tracker <https://bugs.python.org/issu

[issue46382] dataclass(slots=True) does not account for slots in base classes

2022-03-18 Thread Arie Bovenberg
Arie Bovenberg added the comment: @eric.smith awesome! What would you like to do about the __weakref__ slot? 1. take no action 2. create a separate ticket to discuss further 3. implement as done in attrs, now that we're changing __slots__ dataclass behavior anyway I wouldn't recommend (1

[issue46382] dataclass(slots=True) does not account for slots in base classes

2022-03-17 Thread Arie Bovenberg
Arie Bovenberg added the comment: @eric.smith did you give this some thought? Would we want to imitate the attrs behavior regarding __weafref__? It'd be nice if I can submit a PR to be included in 3.11 -- ___ Python tracker <ht

[issue46200] Discourage logging f-strings due to security considerations

2022-02-19 Thread Arie Bovenberg
Arie Bovenberg added the comment: Thanks @gregory.p.smith! I didn't know about discuss.python.org. I created a new topic there: https://discuss.python.org/t/safer-logging-methods-for-f-strings-and-new-style-formatting/13802 -- ___ Python tracker

[issue46200] Discourage logging f-strings due to security considerations

2022-02-03 Thread Arie Bovenberg
Arie Bovenberg added the comment: @rhettinger @tinchester I definitely see now that f-strings should have a place in logging. But do you agree that f-strings don't mix 100% safely with the current logger API? What are your thoughts on a safer set of logger functions (see my comments above

[issue46382] dataclass(slots=True) does not account for slots in base classes

2022-01-20 Thread Arie Bovenberg
Arie Bovenberg added the comment: @hynek interesting! The discussion in https://github.com/python-attrs/attrs/pull/420 on the weakref slot is very interesting as well. Considering __weakref__ is something we don't want to make impossible in dataclasses, @eric.smith what would be your

[issue46382] dataclass(slots=True) does not account for slots in base classes

2022-01-15 Thread Arie Bovenberg
Arie Bovenberg added the comment: Spencer is correct. The documentation even adds: "This renders the meaning of the program undefined." It's clear it doesn't break anything users would often encounter (we would have heard about it), but it's still undefine

[issue46382] dataclass(slots=True) does not account for slots in base classes

2022-01-14 Thread Arie Bovenberg
Arie Bovenberg added the comment: There are already 2 complexities I can think of: 1. This behavior may break some people's code, if they use __slots__ to iterate over the fields of a dataclass. Solution: explicitly mention in the docs that not every field may get a slot on the new

[issue46382] dataclass(slots=True) does not account for slots in base classes

2022-01-14 Thread Arie Bovenberg
New submission from Arie Bovenberg : @dataclass(slots=True) adds slots to dataclasses. It adds a slot per field. However, it doesn't account for slots already present in base classes: >>> class Base: ... __slots__ = ('a', ) ... >>> @dataclass(slots=True)

[issue46298] Automatically check for __slots__-mistakes in Lib

2022-01-07 Thread Arie Bovenberg
New submission from Arie Bovenberg : Recently, I've identified some __slots__-related mistakes in the stdlib (bpo-46247, bpo-46244, bpo-46246). Looking forward, it'd be wise to automate this check so mistakes don't creep into the code in the future. Implementation-wise, the most

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-01-07 Thread Arie Bovenberg
Change by Arie Bovenberg : -- keywords: +patch pull_requests: +28656 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30452 ___ Python tracker <https://bugs.python.org/issu

[issue46244] typing._TypeVarLike missing __slots__

2022-01-06 Thread Arie Bovenberg
Change by Arie Bovenberg : -- keywords: +patch pull_requests: +28650 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30444 ___ Python tracker <https://bugs.python.org/issu

[issue46244] typing._TypeVarLike missing __slots__

2022-01-04 Thread Arie Bovenberg
Arie Bovenberg added the comment: @kj I would very much like to! Seems like a good place to start contributing :) -- ___ Python tracker <https://bugs.python.org/issue46

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-01-03 Thread Arie Bovenberg
Arie Bovenberg added the comment: @jaraco thanks for your quick response. In short: __slots__ allows class layout to be optimized by replacing the class __dict__ with specific descriptors. This results in a class where only specific attributes can be get/set. However, you only really get

[issue46247] in xml.dom.minidom, Node and DocumentLS appear to be missing __slots__

2022-01-03 Thread Arie Bovenberg
New submission from Arie Bovenberg : (as instructed in bpo-46244, I've created this ticket) The classes Node and DocumentLS don't define __slots__, but a number of subclasses do. This appears to be a mistake. If so, I'd like to create a PR to fix it. -- components: Library (Lib

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-01-03 Thread Arie Bovenberg
New submission from Arie Bovenberg : (as instructed in bpo-46244, I've created this ticket) The subclass `EntryPoints` defines __slots__, but its base `DeprecatedList` does not. This appears to be a mistake. If so, I'd like to create a PR to fix it. -- components: Library (Lib

[issue46244] typing._TypeVarLike missing __slots__

2022-01-03 Thread Arie Bovenberg
Arie Bovenberg added the comment: Thanks! I'll open new issues shortly on xml and importlib -- ___ Python tracker <https://bugs.python.org/issue46244> ___ ___

[issue46244] typing._TypeVarLike missing __slots__

2022-01-03 Thread Arie Bovenberg
Arie Bovenberg added the comment: I've also encountered other classes in the stdlib possibly missing slots: - importlib.metadata.DeprecatedList (subclass EntryPoints has slots) - xml.dom.minidom.Node, xml.dom.xmlbuilder.DocumentLS (5 subclasses have slots) Will investigate

[issue46244] typing._TypeVarLike missing __slots__

2022-01-03 Thread Arie Bovenberg
New submission from Arie Bovenberg : The mixin class "typing._TypeVarLike" has no __slots__. Its subclasses do define __slots__, so it looks like a mistake. Agree? It should be an easy fix, and I'd like to pick this up. -- components: Library (Lib) messages: 4

[issue46200] Discourage logging f-strings due to security considerations

2022-01-02 Thread Arie Bovenberg
Arie Bovenberg added the comment: Indeed the `__format__` style offers a lot more options (see https://pyformat.info/). Regarding performance you make an interesting point. One possible solution is to allow f-strings _only_ if there are no args/kwargs. In that one case formatting would

[issue46200] Discourage logging f-strings due to security considerations

2022-01-02 Thread Arie Bovenberg
Arie Bovenberg added the comment: I've done some more digging, and have read the related issue bpo-30995. There are IMHO two challenges that are worth tackling: 1. A great number[1] of developers do their own string formatting. This is sub-optimal for performance and - in rare cases

[issue46200] Discourage logging f-strings due to security considerations

2021-12-31 Thread Arie Bovenberg
Arie Bovenberg added the comment: Absolutely agree! In practice I find some people are not swayed by this argument -- and prefer the readability of f-strings. My expectation is that a clear recommendation in the official docs will convince more people. Especially if there are security

[issue46200] Discourage logging f-strings due to security considerations

2021-12-29 Thread Arie Bovenberg
New submission from Arie Bovenberg : (I've already submitted this issue to secur...@python.org, who directed me to propose a documentation change here) Logging f-strings is quite popular, because the `%` style of logging is often considered ugly. However, logging preformatted strings comes