Objective-C Category broken, was working in pyobjc 4.2.1 with Python 3.6

Issue #286 resolved
Riaz Rizvi created an issue

The following code worked in pybojc version 4.2.1 with Python 3.6.

import AppKit as APK

class NSAttributedString(APK.objc.Category(APK.NSAttributedString)):
    def __add__(self,addTo):
        newMS=APK.NSMutableAttributedString.alloc().init()
        newMS.appendAttributedString_(self)
        newMS.appendAttributedString_(addTo)
        return newMS

It now causes a segmentation fault if run in pyobjc 4.2.1 with Python 3.7+, and it also crashes if run in pyobjc 6 with Python 3.6. So newer versions of pyobjc or of Python breaks Categories.

Comments (4)

  1. Riaz Rizvi reporter

    The problem occurred because the choice of method name __add_
    If I change the name to follow objective-c naming convention eg add_ it works. So I guess the older pyobjc just let this slip through which meant I could use Python data model method names. Not a problem. Thanks

  2. Log in to comment