classification
Title: Delete a pending item in _warning.c
Type: Stage: patch review
Components: Extension Modules Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ppperry, shihai1991
Priority: normal Keywords: patch

Created on 2020-02-08 14:27 by shihai1991, last changed 2020-02-11 09:47 by shihai1991.

Pull Requests
URL Status Linked Edit
PR 18414 open shihai1991, 2020-02-08 14:30
Messages (4)
msg361630 - (view) Author: hai shi (shihai1991) * Date: 2020-02-08 14:27
a pend item could be removed (https://github.com/python/cpython/blob/master/Python/_warnings.c#L493).

two reasons:
1) every warning have `__name__` and it must not NULL(`The tp_name slot must be set;` from pep0253)
2) the `__name__` of Warning class(including children class) can not be removed.

```
>>> del UserWarning.__name__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't set attributes of built-in/extension type 'UserWarning'
```
msg361632 - (view) Author: hai shi (shihai1991) * Date: 2020-02-08 14:32
If I am wrong, remove the check operation of `name` is fine.
msg361778 - (view) Author: (ppperry) Date: 2020-02-11 04:04
What if a warning has a metaclass with a custom __getattribute__ method?
msg361792 - (view) Author: hai shi (shihai1991) * Date: 2020-02-11 09:45
> What if a warning has a metaclass with a custom __getattribute__ method?

Sorry, ppperry. I don't understand your question clearly. Could you give me some examples?

This function could be touched when user call `warnings.warn_explicit()`.
History
Date User Action Args
2020-02-11 09:47:07shihai1991setcomponents: + Extension Modules, - Interpreter Core
2020-02-11 09:45:21shihai1991setmessages: + msg361792
2020-02-11 04:04:47ppperrysetnosy: + ppperry
messages: + msg361778
2020-02-08 14:32:45shihai1991setmessages: + msg361632
2020-02-08 14:30:41shihai1991setkeywords: + patch
stage: patch review
pull_requests: + pull_request17789
2020-02-08 14:27:40shihai1991create