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.

Title: `del OSError().characters_written` raises `SystemError`
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.8, Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Bachsau, ZackerySpytz, miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-12-14 22:22 by Bachsau, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11172 merged serhiy.storchaka, 2018-12-14 22:53
PR 11175 merged ZackerySpytz, 2018-12-15 21:04
PR 11197 merged miss-islington, 2018-12-17 14:53
PR 11249 merged ZackerySpytz, 2018-12-20 17:38
Messages (10)
msg331876 - (view) Author: Bachsau (Bachsau) Date: 2018-12-14 22:22
`del OSError().characters_written` raises `SystemError`:
"null argument to internal routine"

I don't know why anyone should try this in productive code, but since the documentation says, that every `SystemError` should be reported, I'm doing that. My suggestion would be to make that attribute behave like the other ones of `OSError`, e.g. defaulting to `None` and returning to that value on deletion.
msg331879 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-14 22:56
PR 11172 makes deleting characters_written to be as for other non-special attributes. Deleting it will be successful only if it was set before, and will raise an AttributeError otherwise.

>>> e = OSError()
>>> e.characters_written = 1
>>> del e.characters_written
>>> del e.characters_written
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: characters_written
msg331882 - (view) Author: Bachsau (Bachsau) Date: 2018-12-15 00:26
Why is it using -1 instead of NULL as the "not-set-indicator"? -1 is a valid python integer, that can be assigned, even if it doesn't make sense in the context, while `None` can not, because it's missing an `__index__` method.
msg331905 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2018-12-15 21:05
PR 11175 fixes some other related SystemErrors (and segfaults).
msg331906 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-15 21:25
> Why is it using -1 instead of NULL as the "not-set-indicator"?

Because the field of the C structure has integer type, and it can not be the NULL pointer.
msg331907 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-15 21:26
Good catch Zackery! Thank you for your PR.
msg332005 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-17 14:43
New changeset e2af34fcf84b41189b54e1f2912faded5daabaca by Serhiy Storchaka in branch 'master':
bpo-35504: Fix a SystemError when delete the characters_written attribute of an OSError. (GH-11172)
msg332007 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-17 14:52
New changeset 842acaab1376c5c84fd5966bb6070e289880e1ca by Serhiy Storchaka (Zackery Spytz) in branch 'master':
bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175)
msg332009 - (view) Author: miss-islington (miss-islington) Date: 2018-12-17 15:10
New changeset cb272843f2d5dfc4ef996ba952b99a3e30c88bbc by Miss Islington (bot) in branch '3.7':
bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175)
msg332242 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-20 17:38
New changeset f347c6eb75ca46990cd7ad3efbe02002603d8460 by Serhiy Storchaka (Zackery Spytz) in branch '2.7':
bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175) (GH-11249)
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79685
2018-12-20 17:38:56serhiy.storchakasetmessages: + msg332242
2018-12-20 17:38:54ZackerySpytzsetpull_requests: + pull_request10500
2018-12-17 15:28:06serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-12-17 15:10:24miss-islingtonsetnosy: + miss-islington
messages: + msg332009
2018-12-17 14:53:02miss-islingtonsetpull_requests: + pull_request10436
2018-12-17 14:52:47serhiy.storchakasetmessages: + msg332007
2018-12-17 14:43:19serhiy.storchakasetmessages: + msg332005
2018-12-15 21:26:31serhiy.storchakasetmessages: + msg331907
2018-12-15 21:25:52serhiy.storchakasetmessages: + msg331906
2018-12-15 21:05:29ZackerySpytzsetnosy: + ZackerySpytz
messages: + msg331905
2018-12-15 21:04:27ZackerySpytzsetpull_requests: + pull_request10416
2018-12-15 00:26:59Bachsausetmessages: + msg331882
2018-12-14 22:56:48serhiy.storchakasetmessages: + msg331879
versions: + Python 3.8
2018-12-14 22:53:08serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request10412
2018-12-14 22:40:25serhiy.storchakasetassignee: serhiy.storchaka

nosy: + serhiy.storchaka
2018-12-14 22:23:06Bachsausettitle: `del OSError().characters_written` raises SystemError -> `del OSError().characters_written` raises `SystemError`
2018-12-14 22:22:24Bachsaucreate