FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[MNT]: macOS backend should always pair `+alloc`/`-init` calls · Issue #31798 · matplotlib/matplotlib · GitHub

Repository navigation

[MNT]: macOS backend should always pair +alloc/-init calls #31798

Closed

Description

Summary

I mentioned the following in #21788:

In Objective-C, an -init… method should always be called immediately after +alloc. Calling any other instance method on an object you just allocated before calling -init… is undefined behavior.123

I believe that each tp_new callback should only call tp_alloc and not instantiate an uninitialized Objective-C object. Each tp_init callback should then create a fully initialized Objective-C object via an +alloc/-init… pair.

I'm starting work on #31797 and the use of unpaired +alloc/-init… calls is generating a few warnings. I'd like to clean this up at the same time I do the ARC work.

Proposed fix

No response

Footnotes

  1. "But the resulting object is not yet usable." from Object Allocation ↩

  2. "You must use an init... method to complete the initialization process." from +alloc ↩

  3. "immediately" and "An init message is coupled with an alloc … message in the same line of code" from -init ↩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL