[issue46431] Trouble subclassing ExceptionGroup

2022-01-25 Thread Irit Katriel
Irit Katriel added the comment: New changeset 072f4a473e861c6c987650f08990c0ed1f76715f by Irit Katriel in branch 'main': bpo-46431: use raw string for regex in test (GH-30901) https://github.com/python/cpython/commit/072f4a473e861c6c987650f08990c0ed1f76715f --

[issue46431] Trouble subclassing ExceptionGroup

2022-01-25 Thread Irit Katriel
Change by Irit Katriel : -- pull_requests: +29080 pull_request: https://github.com/python/cpython/pull/30901 ___ Python tracker ___

[issue46431] Trouble subclassing ExceptionGroup

2022-01-24 Thread Irit Katriel
Irit Katriel added the comment: Thank you Petr. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue46431] Trouble subclassing ExceptionGroup

2022-01-24 Thread Irit Katriel
Irit Katriel added the comment: New changeset b18fd54f8c27e4b2aac222e75ac58aa85e5a7988 by Irit Katriel in branch 'main': bpo-46431: Add example of subclassing ExceptionGroup. Document the message and exceptions attributes (GH-30852)

[issue46431] Trouble subclassing ExceptionGroup

2022-01-24 Thread Irit Katriel
Irit Katriel added the comment: New changeset 573b54515740ce51dcf2402038a9d953aa6c317f by Irit Katriel in branch 'main': bpo-46431: improve error message on invalid calls to BaseExceptionGroup.__new__ (GH-30854)

[issue46431] Trouble subclassing ExceptionGroup

2022-01-24 Thread Irit Katriel
Change by Irit Katriel : -- pull_requests: +29035 pull_request: https://github.com/python/cpython/pull/30854 ___ Python tracker ___

[issue46431] Trouble subclassing ExceptionGroup

2022-01-24 Thread Guido van Rossum
Guido van Rossum added the comment: So, a PR with that fix would be nice? -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue46431] Trouble subclassing ExceptionGroup

2022-01-24 Thread Irit Katriel
Irit Katriel added the comment: This is the fix: -if (!PyArg_ParseTuple(args, "UO", , )) { +if (!PyArg_ParseTuple(args, + "UO:BaseExceptionGroup.__new__", + , + )) { Then we get TypeError:

[issue46431] Trouble subclassing ExceptionGroup

2022-01-24 Thread Irit Katriel
Irit Katriel added the comment: The error message isn't always this bad: >>> class Base: ... def __new__(cls, a, b, c): ...cls.newargs = (a,b,c) ... ... >>> class Derived(Base): ... def __init__(self, x): ... super().__init__(x) ... self.initargs = (x,)

[issue46431] Trouble subclassing ExceptionGroup

2022-01-24 Thread Irit Katriel
Change by Irit Katriel : -- keywords: +patch pull_requests: +29033 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30852 ___ Python tracker ___

[issue46431] Trouble subclassing ExceptionGroup

2022-01-22 Thread Guido van Rossum
Guido van Rossum added the comment: Is this a matter of adding some documentation showing how it should be done? Even if we don't want to encourage such subclassing, we do have APIs to support it, and I think we ought to show how to do it, given that you have to coordinate a bunch of

[issue46431] Trouble subclassing ExceptionGroup

2022-01-19 Thread Irit Katriel
Change by Irit Katriel : -- nosy: +gvanrossum, yselivanov ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46431] Trouble subclassing ExceptionGroup

2022-01-19 Thread Irit Katriel
Irit Katriel added the comment: > Is there any other danger in not overriding it? No issue as long as you don't use split()/subgroup() or except*. -- ___ Python tracker ___

[issue46431] Trouble subclassing ExceptionGroup

2022-01-19 Thread Petr Viktorin
Petr Viktorin added the comment: > can you just assign the task to a field on the exception other than __note__? That might work, but I'm afraid of touching namespaces I don't own. If the subclass is feasible, I'd rather go with that. -- ___

[issue46431] Trouble subclassing ExceptionGroup

2022-01-19 Thread Petr Viktorin
Petr Viktorin added the comment: Thanks for looking into it! > If you don't define derive the superclass constructor is used, which means > you get something of type ExceptionGroup, not your subclass. That might be fine in my case (for a MVP at least). Is there any other danger in not

[issue46431] Trouble subclassing ExceptionGroup

2022-01-19 Thread Irit Katriel
Irit Katriel added the comment: For your use case - can you just assign the task to a field on the exception other than __note__? The only reason we needed __note__ as an official feature is because we want the interpreter's traceback code to use it. But I think you can assign any field to

[issue46431] Trouble subclassing ExceptionGroup

2022-01-19 Thread Irit Katriel
Irit Katriel added the comment: Re the exceptions attribute - I don't think there's a reason not to document it, I can add that (it is mentioned in the PEP). -- ___ Python tracker

[issue46431] Trouble subclassing ExceptionGroup

2022-01-19 Thread Irit Katriel
Irit Katriel added the comment: We probably do need better documentation for subclassing ExceptionGroup. When you subclass an ExceptionGroup you want to make sure that split() and subgroup() (which are used by except*) will continue working, usually by defining a derive() method:

[issue46431] Trouble subclassing ExceptionGroup

2022-01-19 Thread Petr Viktorin
New submission from Petr Viktorin : I want to test a web application by crawling every reachable page. If an error occurs, I need to keep track of the page the error occured at (and additional info like what links were followed to get to the page, so a `__note__` string isn't enough). This