GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-105373: Remove the PyObject_SetAttr(NULL) deprecation by vstinner · Pull Request #105374 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jun 6, 2023 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Remove the deprecation on the following functions:

  • PyObject_SetAttr(obj, attr_name, NULL)
  • PyObject_SetAttrString(obj, attr_name, NULL)
  • PySequence_SetItem(obj, i, NULL)
  • PySequence_SetSlice(obj, i1, i2, NULL)

Deprecation added by commit ed82604.

  • Issue: Keep deprecated functions in Python 3.13: remove this deprecation #105373

📚 Documentation preview 📚: https://cpython-previews--105374.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
pythongh-105373: PyObject_SetAttr(NULL) is no longer deprecated
90d8ff3
Remove the deprecation on the following functions:

* PyObject_SetAttr(obj, attr_name, NULL)
* PyObject_SetAttrString(obj, attr_name, NULL)
* PySequence_SetItem(obj, i, NULL)
* PySequence_SetSlice(obj, i1, i2, NULL)

Deprecation added by commit ed82604.
@bedevere-bot bedevere-bot added awaiting core review docs Documentation in the Doc dir skip news labels Jun 6, 2023
@bedevere-bot bedevere-bot mentioned this pull request Jun 6, 2023
Keep deprecated functions in Python 3.13: remove this deprecation #105373
Closed
@vstinner

vstinner commented Jun 6, 2023

Copy link
Copy Markdown
Member Author

Deprecation added by issue #69887. cc @serhiy-storchaka @vadmium

I would prefer that either we fully removed these deprecations, or to really deprecate them: emit DeprecationWarning at runtime.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Jun 6, 2023

Copy link
Copy Markdown
Member

What is changed since it was discussed 8 years ago?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 6, 2023

Copy link
Copy Markdown
Member Author

What is changed since it was discussed 8 years ago?

I would like to clarify what is really deprecated or not in Python 3.13. I don't see the value of a mention of a deprecation in the documentation without using .. deprecated:: markup and without emitting a DeprecationWarning at runtime.

IMO passing NULL is just fine, it's not going to change, so there is no need to deprecate it.

In 2015, you wrote:

I think the conclusion of Python_Dev discussion is that it is not worth to deprecate this behavior in the code.

So well, I propose to actually not deprecate it :-D

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Jun 6, 2023

Copy link
Copy Markdown
Member

The Gmane link no longer work, the working links to the discussion (it was split on several threads) are
https://mail.python.org/archives/list/[email protected]/thread/OSKS23WDHU67NQCANPNSAPHATZ2J3W7T/
https://mail.python.org/archives/list/[email protected]/thread/UJI3KJQVOY7VELTDJOBTBWM3TYDHEYGD/

The problems with the current behavior:

  1. It looks confusing that some of *Set* functions do removing, while other raise SystemError or crash. Ideally, all such functions should either support deletion by specifying NULL, or raise SystemError. A crash is acceptable too, for performance.
  2. It is a bug magnet. It is easy to get the NULL pointer instead of a pointer to object (just forgot to check for error) and delete instead of set.

Changing the current behavior is a long process. M.-A. Lemburg specified the required procedure. It is interesting, that if we started it in 3.6, it would already be finished.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Jun 9, 2023
Incorrect error handling for APIs that can raise exceptions #105375
Closed
18 tasks done
@vstinner

vstinner commented Jun 9, 2023

Copy link
Copy Markdown
Member Author

I reported this error prone API as capi-workgroup/problems#47

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 9, 2023

Copy link
Copy Markdown
Member Author

It is a bug magnet. It is easy to get the NULL pointer instead of a pointer to object (just forgot to check for error) and delete instead of set.

Oh right. I would prefer to emit a DeprecationWarning in this case and prepare a migration plan towards "Del" functions instead. I don't think that a sentence in the documentation is enough to help users to avoid mistakes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 16, 2023

Copy link
Copy Markdown
Member Author

I created a discussion to specify "Soft Deprecation" in PEP 387: https://discuss.python.org/t/formalize-the-concept-of-soft-deprecation-dont-schedule-removal-in-pep-387-backwards-compatibility-policy/27957

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@CAM-Gerlach CAM-Gerlach changed the title gh-105373: PyObject_SetAttr(NULL) is no longer deprecated gh-105373: Remove the PyObject_SetAttr(NULL) deprecation Jun 17, 2023
@vstinner vstinner mentioned this pull request Jul 9, 2023
Deprecate PyObject_SetAttr(obj, name, NULL): PyObject_DelAttr(obj, name) must be used instead #106572
Closed
@vstinner

vstinner commented Jul 9, 2023

Copy link
Copy Markdown
Member Author

I close this PR in favor of issue #106572: Deprecate PyObject_SetAttr(obj, name, NULL): PyObject_DelAttr(obj, name) must be used instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner closed this Jul 9, 2023
@vstinner
vstinner deleted the keep_obj_setattr_null branch July 9, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review docs Documentation in the Doc dir skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@vstinner @serhiy-storchaka @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.