Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

del OSError().characters_written raises SystemError #79685

Closed
Bachsau mannequin opened this issue Dec 14, 2018 · 10 comments
Closed

del OSError().characters_written raises SystemError #79685

Bachsau mannequin opened this issue Dec 14, 2018 · 10 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@Bachsau
Copy link
Mannequin

Bachsau mannequin commented Dec 14, 2018

BPO 35504
Nosy @serhiy-storchaka, @ZackerySpytz, @miss-islington, @Bachsau
PRs
  • bpo-35504: Fix a SystemError when delete the characters_written attribute of an OSError. #11172
  • bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs #11175
  • [3.7] bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175) #11197
  • [2.7] bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175) #11249
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2018-12-17.15:28:06.032>
    created_at = <Date 2018-12-14.22:22:24.790>
    labels = ['interpreter-core', '3.7', '3.8']
    title = '`del OSError().characters_written` raises `SystemError`'
    updated_at = <Date 2018-12-20.17:38:56.688>
    user = 'https://github.com/Bachsau'

    bugs.python.org fields:

    activity = <Date 2018-12-20.17:38:56.688>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2018-12-17.15:28:06.032>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2018-12-14.22:22:24.790>
    creator = 'Bachsau'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35504
    keywords = ['patch']
    message_count = 10.0
    messages = ['331876', '331879', '331882', '331905', '331906', '331907', '332005', '332007', '332009', '332242']
    nosy_count = 4.0
    nosy_names = ['serhiy.storchaka', 'ZackerySpytz', 'miss-islington', 'Bachsau']
    pr_nums = ['11172', '11175', '11197', '11249']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue35504'
    versions = ['Python 3.7', 'Python 3.8']

    @Bachsau
    Copy link
    Mannequin Author

    Bachsau mannequin commented Dec 14, 2018

    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.

    @Bachsau Bachsau mannequin added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Dec 14, 2018
    @Bachsau Bachsau mannequin changed the title del OSError().characters_written raises SystemError del OSError().characters_written raises SystemError Dec 14, 2018
    @serhiy-storchaka serhiy-storchaka self-assigned this Dec 14, 2018
    @serhiy-storchaka
    Copy link
    Member

    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

    @serhiy-storchaka serhiy-storchaka added the 3.8 only security fixes label Dec 14, 2018
    @Bachsau
    Copy link
    Mannequin Author

    Bachsau mannequin commented Dec 15, 2018

    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.

    @ZackerySpytz
    Copy link
    Mannequin

    ZackerySpytz mannequin commented Dec 15, 2018

    PR 11175 fixes some other related SystemErrors (and segfaults).

    @serhiy-storchaka
    Copy link
    Member

    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.

    @serhiy-storchaka
    Copy link
    Member

    Good catch Zackery! Thank you for your PR.

    @serhiy-storchaka
    Copy link
    Member

    New changeset e2af34f by Serhiy Storchaka in branch 'master':
    bpo-35504: Fix a SystemError when delete the characters_written attribute of an OSError. (GH-11172)
    e2af34f

    @serhiy-storchaka
    Copy link
    Member

    New changeset 842acaa by Serhiy Storchaka (Zackery Spytz) in branch 'master':
    bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175)
    842acaa

    @miss-islington
    Copy link
    Contributor

    New changeset cb27284 by Miss Islington (bot) in branch '3.7':
    bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175)
    cb27284

    @serhiy-storchaka
    Copy link
    Member

    New changeset f347c6e by Serhiy Storchaka (Zackery Spytz) in branch '2.7':
    bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175) (GH-11249)
    f347c6e

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants