homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: signalmodule.c does "is" comparisons for SIG_IGN and SIG_DFL
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, mark.dickinson, serhiy.storchaka
Priority: normal Keywords:

Created on 2016年09月10日 19:49 by mark.dickinson, last changed 2022年04月11日 14:58 by admin.

Messages (3)
msg275687 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2016年09月10日 19:49
Modules/signalmodule.c contains this code:
 if (handler == IgnoreHandler)
 func = SIG_IGN;
 else if (handler == DefaultHandler)
 func = SIG_DFL;
 ...
Here IgnoreHandler and DefaultHandler are ints. The code above effectively does an "is" comparison with those ints, assuming that SIG_IGN and SIG_DFL are amongst the small interned ints.
msg275688 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2016年09月10日 19:52
Also applies to 2.7, 3.5.
msg275696 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016年09月10日 20:54
This was not a problem before 3.5 since IgnoreHandler and DefaultHandler were singletons exposed in the signal module as SIG_DFL and SIG_IGN. But in issue21076 they were converted to enums. This involves converting between enums and ints. All works only while SIG_DFL and SIG_IGN are small integers and there is small integer cache. I proposed either revert this change (signal_no_enum_handlers.patch in issue21076) or even make SIG_DFL and SIG_IGN non-integer singletons (issue23325).
History
Date User Action Args
2022年04月11日 14:58:36adminsetgithub: 72256
2018年08月23日 23:54:00berker.peksagsetnosy: + berker.peksag
components: + Library (Lib)
2016年09月10日 20:54:08serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg275696
2016年09月10日 19:52:20mark.dickinsonsetmessages: + msg275688
versions: + Python 2.7, Python 3.5
2016年09月10日 19:49:19mark.dickinsoncreate

AltStyle によって変換されたページ (->オリジナル) /