NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI
Wrappers for the framework ApplicationServices on macOS
Last release 1 months ago
11 Aug 2026
Ships fairly regularly
a new release about every 2 months
Nearly every release is documented
notes for 53 of 53 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
59 releases · first in 2016
The project can now be build using Xcode 27.
The Network framework builds upon grand central dispatch (the pyobjc-framework-libdispatch package), and because of that exceptions in callback handle
#670: A number of test files were in a directory name with lower-case letters where upper-case letters should have been used. This only affects users checking out the repository on systems with a case-sensitive filesystem.
#671: Fix build error in the Quartz bindings when the SDK is for macOS 15 or later and the build target is also macOS 15 or later.
#659: Implement basic support for handling Swift classes that
have an Objective-C representation but are not subclasses of NSObject,
as used in the Network framework.
note
The Network framework builds upon grand central dispatch
(the pyobjc-framework-libdispatch package), and because of that
exceptions in callback handlers will cause a hard crash.
One column per quarter.
Backward incompatible changes: CFBagCreate and CFBagCreateMutable now match the API in Objective-C, that is, a value for the callbacks argument must b…
Update framework bindings for macOS 26.5 SDK
The following code failed at the last line in previous versions:
class MyObject(NSObject):
pass
obj = MyObject()
obj.alloc = MyObject.alloc
print(obj.alloc) # Raised AttributeError
Backward incompatible changes: CFBagCreate and CFBagCreateMutable now match the API in Objective-C, that is, a value for the callbacks argument must be passed (must be kCFTypeBagCallBacks).
#663: Fix retain count management for the callbacks registered with DARegisterDiskEjectApprovalCallback, DARegisterDiskMountApprovalCallback, and DARegisterDiskUnmountApprovalCallback in DiskArbitration bindings.
“Hidden” instance methods were not hidden when looking them up as an attribute on the class, but found an unbound method as if the method was not hidden.
“Hidden” instance methods were visible in dir(SomeClass).
#664: Fix anObject.methodForSelector_(some_selector) resolving to a class method IMP when a bound selector object for some_selector is a class attribute.
Fixed some memory leaks on unlikely error paths.
#637: numbers.Number values are proxies as an NSNumber value.
#665: the new of Objective-C classes now also support keyword arguments derived from class selectors of the form valueWithKey1:key2: (with an arbitrary prefix instead of value).
The following calls are now possible (as examples):
Foundation.NSHost(address="www.python.org"), returns Foundation.NSHost.hostWithAddress_("www.python.org").
AppKit.NSImage(systemSymbolName="multiply.circle.fill", accessibilityDescription="multiply icon"), returns AppKit.NSColor.colorWithSystemSymbolName_accessibilityDescription_("multiply.circle.fill", "multiply icon").
Add NSMutableData.take_bytes on Python 3.15 to mirror the new bytearray method of the same name.
Rewrite the construction of objects representing method and function metadata, this should result in (slightly) less memory usage.
This release gets the testsuite for pyobjc-core to a point where there is comprehensive test coverage for the entire bridge. All extension modules now have 100% test coverage according to lcov, although with use for exclusion comments to ignore code blocks that cannot be reached for various reasons (e.g. PyDict_New can fail, but that only happens when running out of memory and it not preproducable during testing).
This enables refactoring the code in pyobjc-core with more confidence that this won’t result in unexpected changes in behaviour.
Fix error message for invalid argument to a callable with a variable length output buffer argument.
Fix error handlign for incomplete struct encodings.
Raise better error when specifying a negative array size for (Objective-)C arguments where the size of a buffer is passed as one of the arguments to a method or function.
A side effect of this is that a number of manual bindings no longer support passing -1 as the size of a buffer to derive the size from the Python sequence.
A Python implementation for a method that returns void and has a single output parameter used to leak a reference to the return value.
Fix crash when a Python implementation with a pass-by-reference output argument or return value returns an Objective-C instance that is no longer referenced in Python when the function returns, e.g.:
@objc.objc_method(signature=b"@@:o^@")
def myOutput_(self, a):
return (1, NSObject.alloc().init())
The bridge could pass a null pointer for a function pointer argument in some (unlikely) edge cases instead of raising an error.
Fix various crashes related to edge cases in pass-by-reference argument handling (none of which happen are used in bindings for Cocoa frameworks)
Metadata with a tuple as the value for c_array_length_in_arg for an output argument is now honored for methods implemented in Python.
Fix crash when c_array_length_in_arg metadata refers to an non-existing argument.
Fix handling of transient proxy value, such as when Objective-C calls a Python method when the object is kept alive from Objective-C (no active reference in Python).
Edge case found while debugging an unexpected crash in the free-threaded build which uncovered a bug that also affected the regular build (but was not triggered there in the test suite).
aValue.methodForSelector_ now works when the selector is implemented in Python, the result will be the Python callable (not wrapped in an objc.IMP value).
#644: A number of constants in the CoreAudio bindings evaluated to byte strings, while the framework expects regular strings.
Foundation.NSDecimalNumber can no longer be subclassed in Python.
Subclasses was possible in older versions, but this is something that isn’t supported in Objective-C and has unexpected behaviour.
The cobject and c_void_p arguments for opaque pointer types and objc.objc_object are now keyword only.
This should not affect user code because passing these values by value isn’t useful (esp. because the c_void_p argument is the only one that’s useful for interop with 3th-party code).
#668: “frozendict” is supported with Python 3.15a7 and later.
Instances roundtrip to Objective-C objects similarly as the dict type, including for keyed archiving. For non-keyed archiving a frozendict value is read back as a plain dict.
The metadata method on objc.function, objc.selector, and objc.IMP now returns a frozendict instead of a regular dict to indicate that changing the value has no effect.
#674: Drop GIL when sending KVO notifications
PR by github user Tim Clem.
#669: Drop dependency on dis.dis
PR by github user Max Bélanger.Update framework bindings for macOS 26.5 SDK
Update framework bindings for macOS 26.5 SDK
The following code failed at the last line in previous versions:
class MyObject(NSObject):
pass
obj = MyObject()
obj.alloc = MyObject.alloc
print(obj.alloc) # Raised AttributeError
Backward incompatible changes:
CFBagCreate and CFBagCreateMutable now match the API in Objective-C, that is, a value for the callbacks argument must be passed (must be kCFTypeBagCallBacks).
663: Fix retain count management for the callbacks registered with DARegisterDiskEjectApprovalCallback, DARegisterDiskMountApprovalCallback, and DARegisterDiskUnmountApprovalCallback in DiskArbitration bindings.
"Hidden" instance methods were not hidden when looking them up as an attribute on the class, but found an unbound method as if the method was not hidden.
"Hidden" instance methods were visible in dir(SomeClass).
664: Fix anObject.methodForSelector_(some_selector) resolving to a class method IMP when a bound selector object for some_selector is a class attribute.
Fixed some memory leaks on unlikely error paths.
637: numbers.Number values are proxies as an NSNumber value.
665: the __new__ of Objective-C classes now also support keyword arguments derived from class selectors of the form valueWithKey1:key2: (with an arbitrary prefix instead of value).
The following calls are now possible (as examples):
Foundation.NSHost(address="www.python.org"), returns Foundation.NSHost.hostWithAddress_("www.python.org").
AppKit.NSImage(systemSymbolName="multiply.circle.fill", accessibilityDescription="multiply icon"), returns AppKit.NSColor.colorWithSystemSymbolName_accessibilityDescription_("multiply.circle.fill", "multiply icon").
Add NSMutableData.take_bytes on Python 3.15 to mirror the new bytearray method of the same name.
Rewrite the construction of objects representing method and function metadata, this should result in (slightly) less memory usage.
This release gets the testsuite for pyobjc-core to a point where there is comprehensive test coverage for the entire bridge. All extension modules now have 100% test coverage according to lcov, although with use for exclusion comments to ignore code blocks that cannot be reached for various reasons (e.g. PyDict_New can fail, but that only happens when running out of memory and it not preproducable during testing).
This enables refactoring the code in pyobjc-core with more confidence that this won't result in unexpected changes in behaviour.
Fix error message for invalid argument to a callable with a variable length output buffer argument.
Fix error handlign for incomplete struct encodings.
Raise better error when specifying a negative array size for (Objective-)C arguments where the size of a buffer is passed as one of the arguments to a method or function.
A side effect of this is that a number of manual bindings no longer support passing -1 as the size of a buffer to derive the size from the Python sequence.
A Python implementation for a method that returns void and has a single output parameter used to leak a reference to the return value.
Fix crash when a Python implementation with a pass-by-reference output argument or return value returns an Objective-C instance that is no longer referenced in Python when the function returns, e.g.:
@objc.objc_method(signature=b"@@:o^@")
def myOutput_(self, a):
return (1, NSObject.alloc().init())
The bridge could pass a null pointer for a function pointer argument in some (unlikely) edge cases instead of raising an error.
Fix various crashes related to edge cases in pass-by-reference argument handling (none of which happen are used in bindings for Cocoa frameworks)
Metadata with a tuple as the value for c_array_length_in_arg for an output argument is now honored for methods implemented in Python.
Fix crash when c_array_length_in_arg metadata refers to an non-existing argument.
Fix handling of transient proxy value, such as when Objective-C calls a Python method when the object is kept alive from Objective-C (no active reference in Python).
Edge case found while debugging an unexpected crash in the free-threaded build which uncovered a bug that also affected the regular build (but was not triggered there in the test suite).
aValue.methodForSelector_ now works when the selector is implemented in Python, the result will be the Python callable (not wrapped in an objc.IMP value).
A small milestone over the last couple of releases is that test coverage of the C extension in pyobjc-core is now at 100%, although with a liberal sprinkling of coverage exclusions for conditions that cannot be triggered during testing (such as memory errors).
This makes it possible to refactor parts of this extension module with more confidence, and has fixed a number of issues in edge conditions.
644: A number of constants in the CoreAudio bindings evaluated to byte strings, while the framework expects regular strings.
Foundation.NSDecimalNumber can no longer be subclassed in Python.
Subclasses was possible in older versions, but this is something that isn't supported in Objective-C and has unexpected behaviour.
The cobject and c_void_p arguments for opaque pointer types and objc.objc_object are now keyword only.
This should not affect user code because passing these values by value isn't useful (esp. because the c_void_p argument is the only one that's useful for interop with 3th-party code).
668: "frozendict" is supported with Python 3.15a7 and later.
Instances roundtrip to Objective-C objects similarly as the dict type, including for keyed archiving. For non-keyed archiving a frozendict value is read back as a plain dict.
The __metadata__ method on objc.function, objc.selector, and objc.IMP now returns a frozendict instead of a regular dict to indicate that changing the value has no effect.
674: Drop GIL when sending KVO notifications
PR by github user Tim Clem.
669: Drop dependency on dis.dis
PR by github user Max Bélanger.
Update framework bindings for the macOS 26.1 SDK
#661: 12.0 incorrectly has support for Python 3.9 in packaging metadata.
Update framework bindings for the macOS 26.1 SDK
Instances of bytearray can be used as the argument for a function or selector that expects a null-terminated C char array.
Automatically disable KVO usage for subclasses of NSProxy defined in Python.
Fix SystemError when calling objc.propertiesForClass(objc.objc_object).
objc.classAddMethods no longer supports callable's whose __name__ attribute is a byte string.
Clearer error messages when an entry in the methods added with objc.classAddMethod is invalid.
Using objc.classAddMethods to add a method for which a custom IMP helper has been registered now works correctly (previously the default libffi IMP implementation was used in these cases), and likewise for using :func`setattr` to assign methods.
It is no longer possible to use objc.classAddMethods to override an existing method with an incompatible Objective-C signature, and likewise for using setattr to do the same.
It was already not possible to override a method from a super class with an incompatible Objective-C signature.
It is now possible to use an objc.objc_method instance in the method list argument for objc.classAddMethod.
-[OC_PythonObject copy] now actually copies the value if the value is not known to be immutable (such as subclasses of the builtin number types).
CFNetwork: The following functions were deprecated before macOS 10.6 and were removed in the macOS 10.15 SDK: CFHTTPReadStreamSetRedirectsAutomaticall…
Drop support for Python 3.9, which will go out of support before PyObjC 3.12 is released.
Added AVFAudio as a separate toplevel package, instead of keeping
it merged in into AVFoundation.
The package is included in the pyobjc-framework-AVFoundation distribution.
Updated metadata for the macOS 26 SDK.
As part of this introduce bindings for the following new framework bindings:
There are no bindings for the MetalPerformancePrimitives at this time, it is
a low-level C++ library that would require a lot of work to create bindings.
In macOS 26 a number of type encodings for block arguments include a signature for the block interface. Update PyObjC runtime introspection to ignore that information.
Dropped old metadata scans. That is, all framework bindings are now created from the most recent macOS SDK headers with some manual additions and annotations.
This change required adding manual entries for, in particular, constants that were renamed in by now old versions of macOS and have been removed from Apple's headers by now. These will be removed from PyObjC in a future update as well (but after a transition period where using them will raise a warning).
This has the following user visible side effects (as far as they are visible, most of the the changes below affect versions of macOS that are long gone):
Accounts: The following constants are no longer available (on the old versions
of macOS where these were available): ACFacebookAppVersionKey,
ACFacebookPermissionGroupKey, ACFacebookPermissionGroupRead,
ACFacebookPermissionGroupReadWrite, and ACFacebookPermissionGroupWrite.
AppKit: The NSFileWrapper class no longer supports with keyword arguments path,
and serializedRepresentation, and the keyword set (URL, options, error).
AuthenticationServices: The classes
ASAccountAuthenticationModificationReplacePasswordWithSignInWithAppleRequest
and ASAccountAuthenticationModificationUpgradePasswordToStrongPasswordRequest
no longer have a keyword argument set named (user, serviceIdentifier).
Automator: class AMBundleAction no longer accepts the keyword set (definition, fromArchive).
CFNetwork: The following functions were deprecated before macOS 10.6 and were removed
in the macOS 10.15 SDK: CFHTTPReadStreamSetRedirectsAutomatically, and
CFNetServiceSetProtocolSpecificInformation.
CloudKit: CKDiscoverUserInfosOperation no longer recognizes the keyword
set (emailAddresses, userRecordIDs). CKFetchDatabaseChangesOperation
no longer recognizes the keyword argument previousServerChangeToken.
CKShare no longer recognizes the keyword arguments recordZoneID,
rootRecord, and the keyword set (rootRecord, shareID).
CKSubscription no longer recognizes the keyword argument coder,
and the keyword sets (recordType, predicate, options),
(recordType, predicate, subscriptionID, options),
(zoneID, options) and zoneID, subscriptionID, options).
CoreAudio: The following functions are no longer available (all were deprecated between
macOS 10.5 and 10.8, and removed from the macOS 10.15 SDK):
AudioHardwareClaimAudioDeviceID, AudioHardwareDevicesDied,
AudioHardwareDevicePropertyChanged, AudioHardwareDevicesCreated, AudioObjectCreate,
AudioHardwareStreamPropertyChanged, AudioHardwareClaimAudioStreamID, AudioObjectPropertiesChanged,
AudioHardwareStreamsCreated, AudioObjectsPublishedAndDied,
AudioHardwareStreamsDied.
The following constants are no longer available because they are not useful
in python code: CA_PREFER_FIXED_POINT and COREAUDIOTYPES_VERSION.
CoreData: The constant NSFetchRequestExpressionType is no longer available.
CoreLocation: CLBeaconIdentityConstraint no longer supports the
keyword UUID and the keyword sets (UUID, major) and (UUID, major, minor).
CoreServices: The following functions are no longer available (all were removed
in the macOS 10.7 SDK): LSInit and LSTerm.
CoreText: The constant kCTVersionNumber10_6_7 is no longer available.
CryptoTokenKit: The following constants are no longer available. Use the modern
names instead: TKSmartCardNoSlot, TKSmartCardSlotEmpty,
TKSmartCardSlotProbing, TKSmartCardSlotMuteCard, and TKSmartCardSlotValidCard.
DiscRecording: The following constants are no longer available:
DRCDTextEncodingASCII, kDRCDTextEncodingASCII,
DRCDTextEncodingISOLatin1Modified, and kDRCDTextEncodingISOLatin1Modified.
DiskArbitration: The following constants are no longer available:
kDADiskOptionEjectUponLogout, kDADiskOptionMountAutomatic,
kDADiskOptionMountAutomaticNoDefer, and kDADiskOptionPrivate.
GameController: The struct type registration GCExtendedGamepadValueChangedHandler
is gone (the existence of this type was a bug).
ImageCaptureCore: Constant ICCameraDeviceSupportsFastPTP is no longer
available (only affects macOS 10.11).
Intents: Removed constant INMessageReactionTypeEmojiReaction, use
INMessageReactionTypeEmoji instead.
Intents: INAggregatedMessageReaction no longer accepts the keyword set
reactionType, emoji, reactionCount). INMessage no longer accepts
the keyword sets (identifier, conversationIdentifier, content, dateSent, sender, recipients, groupName, serviceName, messageType, referencedMessage, reaction, aggregatedReactions)
and
(identifier, conversationIdentifier, content, dateSent, sender, recipients, groupName, serviceName, messageType, referencedMessage, sticker, reaction, aggregatedReactions). It
does accept these keyword sets without the aggregatedReactions keyword though.
Intents: The INColor class no longer accepts the keyword set (read, green, blue).
Intents: The INHeadUnit class no longer accepts the keyword set (bluetoothIdentifier, iap2Identifier).
Intents: The INMediaSearch class no longer accepts the keyword set
(mediaType, sortOrder, mediaName, artistName, albumName, genreNames, moodNames, activityNames, releaseDate, reference, mediaIdentifier).
Intents: The INStartCallIntent class no longer accepts the keyword set
(audioRoute, destinationType, contacts, callCapability).
JavaScriptCore: Constants WEBKIT_VERSION_* are no longer available.
LocalAuthentication: The following constants are no longer available:
kLAOptionAuthenticationReason and kLAOptionUserFallback.
Metal: The constant MTLStitchedLibraryOptionStoreLibraryInMetalScript
is no longer available (was only present in a beta SDK)
MLCompute: Class MLCOptimizer no longer has a keyword argument named descriptor.
PassKit: The following constants are no longer available:
PKDisbursementRequestScheduleFuture and PKDisbursementRequestScheduleOneTime.
Because of this the type PKDisbursementRequestSchedule has been removed as well.
The metadata for PKDisbursementAuthorizationController has been removed.
Class PKShareablePassMetadataPreview no longer accepts the
keyword set (passThumbnail, localizedDescription).
PubSub: Class PSFeed no longer accepts the keyword URL and
the keyword set (data, URL).
Note that the entire framework was removed in macOS 10.15, and the Python bindings will be removed in PyObjC 13 at the latest.
Quartz: The following constants are no longer available: CGFLOAT_EPSILON,
CA_TEST, CA_TESTABLE_CLASS, CA_TESTABLE, kCGErrorLast.
Quartz: The following structs are no longer available (all of them contain
callback pointers which aren't used in PyObjC's bindings for the APIs that use
those structs): CGFunctionCallbacks, CGDataProviderCallbacks,
CGPatternCallbacks, CGDataConsumerCallbacks, CGDataProviderDirectAccessCallbacks,
CGDataProviderSequentialCallbacks, and CGPSConverterCallbacks.
Quartz: The CIColor class no longer accepts the keyword argument CGColor.
Quartz: The CIFilterGenerator class no longer accepts the keyword argument contentsOfURL.
Quartz: The CIFilterShape class no longer accepts the keyword argument rect.
Quartz: The CImage class no longer accepts the keyword sets (bitmapData, bytesPerRow, size, format, colorSpace),
(CGImage, options), (CGLayer, options), (CVImageBuffer, options), (CVPixelBuffer, options),
(contentsOfURL, options), (data, options), (IOSurface, options), (IOSurface, plance, format, options),
(imageProvider, size, format, colorSpace, options), (texture, size, flipped, colorSpace),
(texture, size, flipped, options),
and keywords CGImage, CGLayer, CVImageBuffer, CVPixelBuffer, color, contentsOfURL,
data and IOSurface.
Quartz: The CIImageAcculator class no longer accepts the keyword set (extent, format, colorSpace).
Quartz: The CISampler class no longer accepts the keyword sets
(image, keysAndValues), (image, options), (values, count), (x, y),
(x, y, z), (x, y, z, w),
and keywords image, CGAfineTransform, CGPoint, CGRect, string,
and x.
ScreenSaver: Class ScreenSaverView no longer accepts frame as its
sole keyword argument (always use it in combination with isPreview).
Security: The constant SEC_PROTOCOL_CERT_COMPRESSION_DEFAULT is no longer
available.
ServiceManagement: The following constants are no longer available:
kSMInfoKeyAuthorizedClients and kSMInfoKeyPrivilegedExecutables.
SharedWithYouCore: SWCollaborationOption no longer has a keyword argument
named coder.
SyncServices: Informal protocol ISyncSessionDriverDataSourceOptionalMethods is
no longer available.
SystemConfiguration: The following constants are no longer available:
kSCEntNetAppleTalk, kSCEntNetNetInfo, kSCNetworkProtocolTypeAppleTalk,
kSCPropNetAppleTalkComputerName, kSCPropNetAppleTalkComputerNameEncoding,
kSCPropNetAppleTalkConfigMethod, kSCPropNetAppleTalkDefaultZone,
kSCPropNetAppleTalkNetworkID, kSCPropNetAppleTalkNetworkRange,
kSCPropNetAppleTalkNodeID, kSCPropNetAppleTalkSeedNetworkRange,
kSCPropNetAppleTalkSeedZones, kSCPropNetNetInfoBindingMethods,
kSCPropNetNetInfoBroadcastServerTag, kSCPropNetNetInfoServerAddresses,
kSCPropNetNetInfoServerTags, kSCValNetAppleTalkConfigMethodNode,
kSCValNetAppleTalkConfigMethodRouter, kSCValNetAppleTalkConfigMethodSeedRouter,
kSCValNetNetInfoBindingMethodsBroadcast, kSCValNetNetInfoBindingMethodsDHCP,
kSCValNetNetInfoBindingMethodsManual, and kSCValNetNetInfoDefaultServerTag.
WebKit: : The following constants are no longer available:
DOM_VARIABLES_RULE and WK_API_ENABLED.
WebKit: -[WKWebView callAsyncJavaScript:arguments:inContentWorld:completionHandler:],
-[WKWebView evaluateJavaScript:inContentWorld:completionHandler:] block
arguments are no longer supported.
These methods were in a beta version of the macOS 11 SDK, but are no longer present in SDKs.
WebKit: A number of informal protocol definitions were removed. This should not affect
using the library: WebUIDelegate, WebViewEditingDelegate, WebPolicyDelegate,
WebDownloadDelegate, WebResourceLoadDelegate, WebFrameLoadDelegate,
and WebJavaPlugIn.
Added objc.NSInteger, objc.NSUInteger and objc.CGFloat that will make
it easier to use type annotations that match Apple's type information.
Fix edge cases in method accessors when some uses of SomeClass.pyobjc_instanceMethods.method
would result in a method object that's bound to a meta class.
Fix memory leak due to incorrect reference count handling in looking up metadata.
Fix edge case in handling registration of multiple custom helpers to call a selector.
objc.UninitializedDeallocWarning is now soft deprecated because this warning will never be emitted.
The major change in this release is aligning behaviour of the core bridge with clang's documentation for automatic reference counting for initializer methods. In particular, PyObjC now correctly models that methods in the "init" family steal a reference to self and return a new reference.
In previous version of PyObjC the proxy for [NSObject alloc] would be marked as 'partially initialized' and would be cleared when the -init method returns something else then self.
This has two problems:
Behaviour is incorrect when +alloc returns a singleton whose -init method(s) are factory methods (such as NSArray in recent versions of macOS)
The proxy for Objective-C objects needs to contain mutable state. This in turn requires locking in the implementation to work correctly with free-threading.
This version drops the concept of "uninitialized" values and correctly models how reference counts are handled by -init methods.
Update framework bindings for the macOS 15.5 SDK
Added bindings for the SecurityUI framework
Restructure the PyObjC website
The theme of the PyObjC websites is now [shibuya](https://shibuya.lepture.com) to give a more modern look and feel to the website.
The actual content is mostly still the same, with some minor restructuring of pages. Restructuring will continue in future updates.
objc.FSRef now implements os.PathLike.
642: Fix concurrency issue when creating NSArray instances using NSArray.alloc().init....
In previous versions the following would fail on recent versions of macOS:
value1 = NSArray.alloc()
value2 = NSArray.alloc()
value1 = value1.init()
value2 = value2.init()
That's a unrealistic code pattern, but the same can be triggered using NSArray.alloc().init() when run concurrently in multiple threads, especially when using free-threading.
Fixing the previous issue required rearchitecting the way partially initialized objects (e.g. the result of SomeClass.alloc() are handled, and has some other user visible behaviour changes (none of which should affect normal code):
objc.UninitializedDeallocWarning is now soft deprecated because this warning will never be emitted.
Bit 0x1 will never be set in the __flags__ attribute of Objective-C objects.
The proxied value of an objc.objc_object instance will never be nil, all exceptions about accessing attributes or methods of a NIL object are gone.
It is now possible to call methods on a partially initialized object, in previous versions that would often result in setting the proxied value to nil.
It is now possible to call an init method multiple times an an partially initialized value, e.g.:
part = SomeClass.alloc()
value1 = part.init()
value2 = part.init()
Whether or not this is safe depends on the implementation of the Objective-C class. In general it is advised to not use this pattern, but always call SomeClass.alloc().init...() or the more pythonic SomeClass(...) introduced in PyObjC 10.3.
The following code accidentally worked in previous versions of PyObjC and will now crash. Handling of partially initialized objects in previous versions hides the reference counting bug in this code.
class NilObject(NSObject):
def init(self):
self.release()
return None
The isAlloc attribute of objc.selector is deprecated and will be removed in PyObjC 12.
The bridge no longer uses CFRetain and CFRelease to maintain the reference counts of Objective-C values. The original reason to do this is no longer needed, there are edge cases where mixing native ObjC retain count updates with these functions causes problems.
Python 3.14: Use PyUnstable_Object_IsUniquelyReferenced to check if the dealloc helper is uniquely referenced when trying to release it instead of manually checking the reference count.
This fixes an unlikely edge case in the free threading build where checking the reference count like this is not correct.
Deprecated objc.objc_object.pyobjc_ISA.
Implement __class_getitem__ for objc.function, objc.selector. objc.varlist. and objc.WeakRef
This allows for treating these classes a generic in type annotations.
Add some methods to PyObjCTools.TestSupport.TestCase, in particular :meth:`assertIsInitializer <PyObjCTools.TestSupport.TestCase.assertIsInitializer`, :meth:`assertIsNotInitializer <PyObjCTools.TestSupport.TestCase.assertIsNotInitializer`, :meth:`assertDoesFreeResult <PyObjCTools.TestSupport.TestCase.assertDoesFreeResult`, :meth:`assertDoesNotFreeResult <PyObjCTools.TestSupport.TestCase.assertDoesNotFreeResult`.
Add implementation for NSMutableData.resize to match bytearray.resize that was introduced in Python 3.14.
Using a instance of a Python class with an __call__ method as an Objective-C block is now possible.
Change PyObjC's internal assertions in C code from PyObjC_Assert to assert (and only enable them using debug builds of CPython). This is slightly more efficient and enables removing error return paths in a number of functions due to internal APIs that could only fail due to assertion errors.
Removed some helper code that was used when subclassing a number of NSDecimalNumber methods. This should have no effect because overriding these methods is effectifly impossible anyway on recent versions of macOS.
Fix some free-threaded race conditions
Classes NSString and NSMutableString are marked as "final", which means these classes can no longer be subclassed.
Reason for this is that Cocoa strings have special handling in PyObjC and trying to subclass these classes in Python will result in crashes.
The objc._objc extension no longer performs imports from native code, all external dependencies are passed in as (private) options from Python code.
This simplifies PyObjC's code, and avoids having imports that are hidden from analysis tools.
Remove usage of pkg_resources in PyObjC's setup.py files.
This is needed because this library is deprecated in setuptools and will be removed.
651: Fix build issue on macOS 10.12 by changing the invocation of sw_vers(1).
The major change in this release is experimental support for free-threading (PEP 703 _) which was introduced as an experimental feature in Python 3.13
The major change in this release is experimental support for free-threading (PEP 703) which was introduced as an experimental feature in Python 3.13.
This required fairly significant changes in the core of PyObjC to change C Python API use and PyObjC internal APIs (mostly related to the use of borrowed references).
Dropped support for Python 3.8. PyObjC 11 supports Python 3.9 and later.
Updated metadata for the macOS 15.2 SDK, including bindings for the following frameworks:
MediaExtension
DeviceDiscoveryExtension
249: Added minimal bindings to the Carbon framework.
At this time only some functions and constants related to hotkeys are available. Please file an issue if you have a usecase for other APIs.
249: Added minimal bindings to the Carbon framework.
At this time only some functions and constants related to hotkeys are available. Please file an issue if you have a usecase for other APIs.
615: Struct wrappers now support a number of functions from copy: copy.replace (new in Python 3.13), copy.copy and copy.deepcopy.
The __pyobjc_copy__ method has been removed from struct wrappers. This was never a public API. Use copy.deepcopy instead.
objc.FSRef.from_path` now supports os.PathLike values as its arguments (as well as strings).
608: Experimental support for the free-threading mode introduced in Python 3.13.
The core bridge and framework bindings claim compatibility with free-threading as introduced as an experimental feature in Python 3.13.
The support in PyObjC is also an experimental feature: I've reviewed code for free-threading issues and adjusted it where needed, but the code has seen only light testing w.r.t. concurrency.
Some functionality that's explicitly not thread-safe:
Defining an Objective-C class with the same name in multiple threads concurrently.
Splitting calls to alloc and init and calling init multiple times concurrently. E.g.:
import threading from Cocoa import NSObject v = NSObject.alloc() t_list = [] for _ in range(2): t = threading.Thread(target=lambda: v.init()) t_list.append(t) t.start() for t in t_list: t.join()
The internal mapping from Python values to their active Objective-C proxy value now uses weak references. This should not affect user code, other than being a bit more efficient.
The internal interfaces for updating this mapping, and the reverse mapping from Objective-C values to their active Python proxy was changed to remove a small race condition. This was required for free threading support, but could in theory also bit hit when using the GIL.
The data structure for mapping Python values to their Objective-C proxy has been rewritten to support free threading. This also simplifies the code, and should be small performance improvement for the regular build of Python.
The TypeError raised when passing a non-sequence value to some APIs implemented in C now has a __cause__ with more detailed information.
This is a side effect of dropping the use of PySequence_Fast in the implementation of PyObjC.
Removed objc.options._nscoding_version, a private option that is no longer used.
Changing the __block_signature__ of a block value when the current value of the signature is not None is no longer possible.
Please file an issue if you have a use case for changing the signature of a block.
Fix compatibility with Python 3.14 (alpha 3)
Removed private function objc._sizeOfType because its unused.
Fix memory leak when using Python callables as blocks.
The memory leak also resulted in leaking a reference to the callable (and hence anything kept alive by that reference).
The generic __new__ implementation now works as intended when registering methods that other than init... methods.
Dropped '%n' support in handling printf-format strings for variadic functions and methods.
Two reasons for that: 1) supporting this properly should return the value writing to the %n location (requiring significant changes) and 2) Apple's libraries require using static strings for '%n' to work (at least on some platforms and versions of the OS)
633: Fix manual bindings for AVAudioPCMBuffer methods for getting channel data (floatChannelData, int16ChannelData and int32ChannelData)
632: fix broken bindings for CGWindowListCreateImageFromArray.
The private __is_magic attribute on objc.objc_object has been renamed to __pyobjc_magic_coookie__.
Various fixes to edge case behaviour that were found while improving test coverage.
Fix a number of test failures on macOS 15 These are all documentation and test updates.
Fix a number of test failures on macOS 15 These are all documentation and test updates.
#593: PyObjCTools.AppHelper.runConsoleEventLoop no longer exits the process on macOS 14 or later when stopping the event loop.
#613: Actually expose protocols KHTTPCookieStoreObserver, WKURLSchemeTask, and WKURLSchemeHandler in the WebKit bindings.
Remove workaround for a linker problem in early versions of Xcode 15, which restores support for building with Xcode Command Line tools.
The release contains wheels for the free-threaded build of Python 3.13.
Note that PyObjC does not support running without the GIL at this time.
Fix for running test suite with recent versions of setuptools
Recent versions of setuptools broke the "test" command, the full command has been reimplemented as part of PyObjC.
#627: Fix build issue when deployment target is 15.0 or later.
#623: Don't lowercase the first character of the first keyword argument for __new__ when the segment only contains upper case characters.
Before this change initWithURL: mapped to an uRL keyword argument, with this fix the keyword argument is named URL.
Fix by user @rndblnch on github
#625: Fix crash for calling NSIndexSet.alloc().initWithIndex_(0)
This "fix" is a workaround for what appears to be a bug in Foundation.
#569: Actually remove the workaround for Xcode 15.0
#619: Fix race condition in creating proxy objects for Objective-C classes.
Fix a number of test failures on the first macOS 15 beta. These are all documentation and test updates.
593: PyObjCTools.AppHelper.runConsoleEventLoop no longer exits the process on macOS 14 or later when stopping the event loop.
613: Actually expose protocols KHTTPCookieStoreObserver, WKURLSchemeTask, and WKURLSchemeHandler in the WebKit bindings.
621: Drop dependency on setuptools.command.test which is deprecated and will be removed by the end of the year.
627: Fix build issue when deployment target is 15.0 or later.
argument for __new__ when the segment only contains upper case characters.
Before this change initWithURL: mapped to an uRL keyword argument, with this fix the keyword argument is named URL.
Fix by user rndblnch on github
625: Fix crash for calling NSIndexSet.alloc().initWithIndex_(0)
This "fix" is a workaround for what appears to be a bug in Foundation.
The proxy objects created when passing a Python callable to an Objective-C method/function expecting a block value were never released due to an error in the cleanup code in PyObjC.
Variadic methods and functions where the one of the arguments contains a count of the number of variadic values now work as intended (so far this feature hasn't been necessary in binding Apple frameworks, so shouldn't affect existing code)
Add support for 'long double' in function/method interfaces, including support for '%Ld' in printf-style varargs handling.
Note that this primarily affects x86_64, on arm64 systems 'long double' is effectively an alias for 'double'.
Version 10.3 dropped support for calling __init__, but that breaks a number of popular projects. Reintroduce the ability to use __init__ when a class
#610: Ensure __init__ can be used when user implements __new__.
Version 10.3 dropped support for calling __init__, but that breaks
a number of popular projects. Reintroduce the ability to use __init__
when a class or one of its super classes contains a user implemenentation
of __new__.
Code relying on the __new__ provided by PyObjC still cannot use
__init__ for the reason explained in the 10.3 release notes.
610: Ensure __init__ can be used when user implements __new__.
Version 10.3 dropped support for calling __init__, but that breaks a number of popular projects. Reintroduce the ability to use __init__ when a class or one of its super classes contains a user implemenentation of __new__.
Code relying on the __new__ provided by PyObjC still cannot use __init__ for the reason explained in the 10.3 release notes.
619: Fix race condition in creating Python proxyies for Objective-C classes.
The release contains binary wheels for Python 3.13
The release contains binary wheels for Python 3.13
PyObjC does at this time not support the experimental free threading support in Python 3.13.
#569: Removed the workaround for a bug in Xcode 15.0
The workaround is no longer necessary, and caused problems when building with the Command Line Tools development tools from Apple.
Updated SDK bindings for macOS 14.5
A minor change in the (currently private) tooling I use for collecting the raw metadata resulted in minor fixes to the framework bindings, in particular for metadata for a number of block and function typed arguments and return values.
#275: It is now possible to create instances of Objective-C classes by calling the class, e.g. NSObject() instead of NSObject.alloc().init().
The implementation of __new__ forwards calls to the underlying SomeClass.alloc().init...() pattern. In particular, all public init methods are translated into sets of keyword arguments:
Remove init or initWith from the start of the selector name
Lowercase the first character of what's left over
The strings before colons are acceptable keywords, in that order
For example, given a selector initWithX:y: the __new__ method will accept x, y as keyword arguments, in that order.
Framework bindings have been updated with additional metadata to support this pattern, and the sets of keyword arguments are automatically calculated for subclasses in written in Python.
The limitation on the order of keyword arguments may be lifted in a future version, it is currently present to keep the code closer to the Objective-C spelling which should make it easier to look up documentation on Apple's website.
For some Objective-C classes some of the init and new methods are not available even if they are available in super classes. Those methods are marked with NS_UNAVAILABLE in Apple's headers.
As of this version these methods are also not available in Python code, trying to call them will result in an exception.
To make methods unavailable in Python classes set these methods to None, e.g.:
```python
init = None # NS_UNAVAILABLE
```
Added objc.registerUnavailableMethod, objc.registerNewKeywordsFromSelector and objc.registerNewKeywords to support the generic __new__ in framework bindings.
A limitation for registerUnavailableMethod is that it is currently not supported to reintroduce the method in a subclass, primarily because that functionality is not needed for framework bindings.
Instantiating an Objective-C class by calling the class (e.g. invoking __new__) will not call __init__ even if one is defined.
The implementation of a subclass of NSObject should always follow the Objective-C convention for initializing using one or more methods with a name starting with init.
This can affect code that manually defines a __new__ method for an Objective-C class, in previous versions that was the only way to create instances in a Pythontic way.
NSArray, NSMutableArray, NSSet and NSMutableSet accepted a sequence keyword argument in previous versions. This is no longer supported.
It is still supported to create instances using a positional argument for a sequence, e.g. NSArray([1, 2, 3]).
accepted a value keyword argument in previous versions. This is no longer supported.
It is still supported to create instances using a positional argument, e.g. NSData(b"hello").
NSDictionary and NSMutableDictionary do not support the generic new interface because this conflicts with having a similar interface to dict for creating instances.
That is, NSDictionary(a=4, b=5) is the same as NSDictionary({"a":4, "b":5}), and not like NSDictionary.alloc().initWithA_b_(4, 5).
The release contains binary wheels for Python 3.13
PyObjC does at this time not support the experimental free threading support in Python 3.13.
569: Removed the workaround for a bug in Xcode 15.0
The workaround is no longer necessary, and caused problems when building with the Command Line Tools development tools from Apple.
Updated SDK bindings for macOS 14.5
A minor change in the (currently private) tooling I use for collecting the raw metadata resulted in minor fixes to the framework bindings, in particular for metadata for a number of block and function typed arguments and return values.
275: It is now possible to create instances of Objective-C classes by calling the class, e.g. NSObject() instead of NSObject.alloc().init().
The implementation of __new__ forwards calls to the underlying SomeClass.alloc().init...() pattern. In particular, all public init methods are translated into sets of keyword arguments:
Remove init or initWith from the start of the selector name
Lowercase the first character of what's left over
The strings before colons are acceptable keywords, in that order
For example, given a selector initWithX:y: the __new__ method will accept x, y as keyword arguments, in that order.
Framework bindings have been updated with additional metadata to support this pattern, and the sets of keyword arguments are automatically calculated for subclasses in written in Python.
The limitation on the order of keyword arguments may be lifted in a future version, it is currently present to keep the code closer to the Objective-C spelling which should make it easier to look up documentation on Apple's website.
For some Objective-C classes some of the init and new methods are not available even if they are available in super classes. Those methods are marked with NS_UNAVAILABLE in Apple's headers.
As of this version these methods are also not available in Python code, trying to call them will result in an exception.
To make methods unavailable in Python classes set these methods to None, e.g.:
class MyObject(NSObject):
init = None # NS_UNAVAILABLE
Added objc.registerUnavailableMethod, objc.registerNewKeywordsFromSelector and objc.registerNewKeywords to support the generic __new__ in framework bindings.
A limitation for registerUnavailableMethod is that it is currently not supported to reintroduce the method in a subclass, primarily because that functionality is not needed for framework bindings.
Instantiating an Objective-C class by calling the class (e.g. invoking __new__) will not call __init__ even if one is defined.
The implementation of a subclass of NSObject should always follow the Objective-C convention for initializing using one or more methods with a name starting with init.
This can affect code that manually defines a __new__ method for an Objective-C class, in previous versions that was the only way to create instances in a Pythontic way.
The primairy reason for this change is that the new default __new__ implementation resulted in calling __init__ for some code paths and not others due to the python semantics for creating instances, e.g.:
class MyDocument(NSDocument):
def __init__(self, *args, **kwds): pass
document = MyDocument() # __init__ gets called
document, error = MyDocument(type="mytype", error=None). # __init__ does not get called
In the last statement __init__ does not get called because __new__ does not return an instance of MyDocument.
NSArray, NSMutableArray, NSSet and NSMutableSet accepted a sequence keyword argument in previous versions. This is no longer supported.
It is still supported to create instances using a positional argument for a sequence, e.g. NSArray([1, 2, 3]).
accepted a value keyword argument in previous versions. This is no longer supported.
It is still supported to create instances using a positional argument, e.g. NSData(b"hello").
NSDictionary and NSMutableDictionary do not support the generic new interface because this conflicts with having a similar interface to dict for creating instances.
That is, NSDictionary(a=4, b=5) is the same as NSDictionary({"a":4, "b":5}), and not like NSDictionary.alloc().initWithA_b_(4, 5).
Fix a number of warnings found by adding -Wpendantic to the CFLAGS for pyobjc-core
Fix a number of warnings found by adding -Wpendantic to the CFLAGS for pyobjc-core
Fix undefined behaviour warnings:
Suppress the undefined behaviour warning about out of range values in double to (unsigned) long long in the OC_PythonNumber implementation as these are unavoidable when matching NSNumber behaviour.
Switch to using memcpy instead of direct assignment in converting plain C values to/from Python because "packed" structs might result in accessing values through unaligned pointers.
Updated bindings for the macOS 14.4 SDK (Xcode 15.3)
Added bindings for the "BrowserEngineKit" framework on macOS 14.4 or later.
Add obj.registerPathType to register a Python type as a path like type with PyObjC. By default only pathlib.Path is registered as such.
A minor backward compatibility issue is that instances of the registered types will be written to NSArchive and NSKeyArchive archives as instances of NSURL and won't roundtrip back to the original Python type. This might change in future versions of PyObjC, at least for pathlib.Path.
#589: Instances of pathlib.Path (and other types registered with objc.registerPathType) are bridged into Objective-C as instances of NSURL.
This means that these types can be used as values passed to APIs expecting a filesystem URL, e.g.:
```python
path = pathlib.Path("/Applications/Numbers.app") bundle = NSBundle.bundleWithURL_(path) ```
Fix some warnings in pyobjc-core when testing with Python 3.13a4.
Add support for NSBezierPathElementQuadraticCurveTo in NSBezierPath.elementAtIndex_associatedPoints_.
#595: Fix compilation error in pyobjc-framework-Cocoa with a recent deployment target.
Upgrade framework bindings for the macOS 14.2 SDK
Upgrade framework bindings for the macOS 14.2 SDK
#579: Make sure the install.py and develop.py scripts in the
repository work when run out of tree.
#577: os.fspath(someURL) will not work with Cocoa URLs (NSURL, CFURLRef) that
refer to local filesystem paths. TypeError will be raised for other URLs.
This enables using regular Python filesystem APIs with URLs that refer to local filesystem paths.
#572: Fix compilation issue when building on macOS 13 or earlier
Fix build error on ancient macOS versions where clang doesn't support
-flto=thin.
Add a workaround for a crash in pyobjc-core when running the testsuite on macOS 10.14.
Fix some issues found while running the testsuite on macOS 10.9 to macOS 13, instead of only testing on the latest macOS version. Most issues found where problems in the testsuite itself, but not all.
Some of the changes skip tests on older macOS versions (10.12, 10.13 and 10.14) due to running into what appears to be crashing platform bugs.
#581: Fix dependencies between framework binding packages
Fix build error with the current Python 3.13 alpha release (3.13a2).
The entire framework was deprecated in macOS 10.13 and removed in macOS 14. The bindings can not be build using the latest SDK, and had (at best) limi…
Update bindings for macOS 14
Symbols newly introduced in macOS 14 were added to the existing bindings, and the following new bindings were introduced:
Cinematic
MediaExtension
SensitiveContentAnalysis
Symbols
The "IMServicePlugIn" bindings are no longer available
The entire framework was deprecated in macOS 10.13 and removed in macOS 14. The bindings can not be build using the latest SDK, and had (at best) limited use.
#542: PyObjC 10 requires Python 3.8 and no longer supports Python 3.7
#547: Removed all MAC_OS_X_VERSION* constants from objc.
These constants are needed in practice (switch to objc.available to check for platform availability), and caused unnecessary code churn.
The value for objc.options.deprecation_warnings is now a string instead of an integer.
#555: Fix unintended incompatibility with pytest in PyObjCTools.TestSupport
#295: The lazy loading machinery by default no longer uses objc.ObjCLazyModule, but uses module level __dir__ and __getattr__ instead. The class objc.ObjCLazyModule is still available, but is deprecated
As a side effect of this objc is no longer an attribute of framework binding packages (e.g Foundation.objc is no longer a valid attribute).
Another side effect of this is that all attributes added by the import system are now correctly present in the packages for framework bindings.
And a final side effect is that private symbols (prefixed with underscore) are no longer imported from dependencies of framework bindings (more closely matching the from dependency import * behaviour that the lazy importer emulates.
Add attribute __framework_identifier__ to all framework bindings with the identifier of the corresponding system framework.
#295: Introduce objc.createFrameworkDirAndGetattr to create module level __dir__ and __getattr__ for use by framework bindings.
#561: Tests now validate the bundle identifier value used in framework bindings.
This resulted in a number of changes to framework bindings with incorrect bundle identifier values. This shouldn't affect user code because the bundle loader falls back on the framework path when the identifier cannot be found.
#559: Avoid test failures in pyobjc-core when pyobjc-framework-Quartz is not installed.
A number of classes can no longer be subclasses in Python because they are marked as non-subclassable in the macOS 14 SDK (either directly or as "subclassing is deprecated": CKAllowedSharingOptions, CKAsset, CKContainer, CKDatabase, CKDatabaseNotification, CKDatabaseSubscription, CKFetchRecordZoneChangesConfiguration, CKNotification, CKNotificationID, CKNotificationInfo, CKOperationConfiguration, CKOperationGroup, CKQuery, CKQueryCursor, CKQueryNotification, CKQuerySubscription, CKRecord, CKRecordID, CKRecordZone, CKRecordZoneID, CKRecordZoneNotification, CKRecordZoneSubscription, CKReference, CKServerChangeToken, CKShare, CKShareMetadata, CKShareParticipant, CKSubscription, CKSyncEngine, CKSyncEngineAccountChangeEvent, CKSyncEngineConfiguration, CKSyncEngineDidFetchChangesEvent, CKSyncEngineDidFetchRecordZoneChangesEvent, CKSyncEngineDidSendChangesEvent, CKSyncEngineEvent, CKSyncEngineFailedRecordSave, CKSyncEngineFailedZoneSave, CKSyncEngineFetchChangesOptions, CKSyncEngineFetchedDatabaseChangesEvent, CKSyncEngineFetchedRecordDeletion, CKSyncEngineFetchedRecordZoneChangesEvent, CKSyncEngineFetchedZoneDeletion, CKSyncEnginePendingDatabaseChange, CKSyncEnginePendingRecordZoneChange, CKSyncEnginePendingZoneDelete, CKSyncEnginePendingZoneSave, CKSyncEngineRecordZoneChangeBatch, CKSyncEngineSendChangesContext, CKSyncEngineSendChangesOptions, CKSyncEngineSentDatabaseChangesEvent, CKSyncEngineSentRecordZoneChangesEvent, CKSyncEngineState, CKSyncEngineStateSerialization, CKSyncEngineStateUpdateEvent, CKSyncEngineWillFetchChangesEvent, CKSyncEngineWillFetchRecordZoneChangesEvent, CKSyncEngineWillSendChangesEvent, CKSystemSharingUIObserver, CKUserIdentity, CKUserIdentityLookupInfo.
The encoding of a number of basic types changes, in particular those of CoreFoundation struct types and SIMD struct types. None of this should affect user code.
objc.getClassList now has an optional positional argument to ignore classes with a name that aren't identifiers.
Some of the functionality in CoreFoundation was rewritten in Swift in macOS 14, with Swift subclasses of NSArray and NSDictionary. Those classes break an invariant of PyObjC: the superclass of the root of the Swift class hierarchy changes when the class is instantiated for the first time (from NSObject to the correct superclass).
PyObjC 10 contains a workaround for this by ignoring these classes unless they are needed to create a proxy for an instance (FB12286520).
Fix crash when the method signature retrieved from the Objective-C runtime contains the class name for a method returning id.
Remove old 32-bit support in metadata override files.
Restructure objc.simd: The matrix types are now named simd_float3x3 instead of matrix_float3x3, with the older name as an alias (to match older system headers).
Fix crash when loading the libdispatch bindings on recent macOS versions (at least macOS 13, possibly earlier)
dispatch.dispatch_source_t is renamed to dispatch.dispatch_source_type_t to match the type name in C code.
#569: Xcode 15 has a bug when using weak symbols and targeting older macOS versions. Switch to the old linker when detecting Xcode 15.
Recent versions of pip give a deprecation warning for projects without a pyproject.toml, and version 23.1 enabled the pyproject.toml backend by defaul…
#549: Added warning objc.ObjCSuperWarning that is used
to warn about classes that use argument-less super without binding that
name to objc.super.
The correct code pattern is:
from Foundation import NSObject
from objc import super
class MyObject(NSObject):
def init(self):
self = super().init()
if self is None:
return None
...
return self
#549: Document that objc.super must be used instead of
builtin.super when calling superclass methods in a Cocoa subclass.
See the documentation <(https://pyobjc.readthedocs.io/core/super.html>_
for more details.
#550: Add minimal pyproject.toml to all subprojects
Recent versions of pip give a deprecation warning for projects without
a pyproject.toml, and version 23.1 enabled the pyproject.toml
backend by default. Add a minimal pyproject.toml to get a consistent
build regardless of the version of pip
#551: Fix crash in pyobjc-core when using Python 3.12a7.
#449: Added explicit tests for dealing with Objective-C categories that are loaded while using classes from Python.
#552: Fix the version of macOS where the SafariServices framework is present.
#552: Fixed some issues found by testing on a macOS 10.11 system
Trying to implement a method with SIMD types as arguments or return value will now give a more useful error when the bridge does not support the signature.
#554: Fix incomplete metadata for CoreMediaIO.CMIOObjectSetPropertyData
Fix incorrect metadata for
xpc.xpc_uuid_create,
xpc.xpc_dictionary_set_uuid ,
xpc.xpc_array_set_uuid,
JavaScriptCore.JSObjectMakeDeferredPromise,
JavaScriptCore.JSValueIsEqual,
JavaScriptCore.JSValueIsInstanceOfConstructor,
JavaScriptCore.JSValueCreateJSONString,
JavaScriptCore.JSValueToNumber,
JavaScriptCore.JSValueToStringCopy,
JavaScriptCore.JSValueToObject,
Quartz.CGImageCreateWithJPEGDataProvider,
Quartz.CGImageCreateWithPNGDataProvider,
Quartz.CGImageMaskCreate,
Quartz.CVBufferCopyAttachment,
Quartz.CVMetalTextureCacheCreate,
Quartz.CVMetalTextureCacheCreateFromImage,
Quartz.CVOpenGLTextureCacheCreate,
CoreMedia.CMAudioClockCreate,
CoreMedia.CMAudioFormatDescriptionCreate,
CoreMedia.CMBlockBufferGetDataPointer,
CoreMedia.CMBlockBufferAccessDataBytes,
CoreMedia.CMBlockBufferGetDataPointer,
CoreMedia.CMAudioFormatDescriptionGetMostCompatibleFormat,
CoreMedia.CMAudioFormatDescriptionGetRichestDecodableFormat,
CoreMedia.CMSampleBufferCreateWithMakeDataReadyHandler,
CoreMedia.CMSampleBufferCreateForImageBufferWithMakeDataReadyHandler,
CFNetwork.CFNetServiceBrowserSearchForDomains,
CFNetwork.CFNetServiceBrowserStopSearch,
CFNetwork.CFNetServiceMonitorStop,
CFNetwork.CFNetServiceRegister,
CFNetwork.CFNetServiceResolve,
CoreText.CTFontCreateCopyWithSymbolicTraits,
CoreText.CTFontCreateCopyWithFamily,
CoreText.CTFontCreateCopyWithAttributes,
CoreMIDI.MIDISourceCreateWithProtocol,
CoreMIDI.MIDISourceCreate,
CoreMIDI.MIDISetupCreate,
CoreMIDI.MIDIDestinationCreate,
CoreMIDI.MIDIClientCreate,
CoreMIDI.MIDIClientCreateWithBlock,
CoreMIDI.MIDIOutputPortCreate,
CoreMIDI.MIDIObjectGetStringProperty,
CoreMIDI.MIDIObjectGetProperties,
CoreMIDI.MIDIObjectGetIntegerProperty,
CoreMIDI.MIDIObjectGetDictionaryProperty,
CoreMIDI.MIDIObjectGetDataProperty,
CoreMIDI.MIDIObjectFindByUniqueID,
CoreMIDI.MIDIDestinationCreateWithProtocol,
CoreMIDI.MIDIEndpointGetEntity,
CoreMIDI.MIDIEntityGetDevice,
CoreMIDI.MIDIEntityGetRefCons,
CoreMIDI.MIDIEntitySetRefCons,
DVDPlayback.DVDRegisterEventCallBack,
DiskArbitration.DADiskMountWithArguments,
GameController.NSDataFromGCExtendedGamepadSnapShotDataV100,
HealthKit.HKAppleWalkingSteadinessClassificationForQuantity,
IOSurface.IOSurfaceSetPurgeable,
Network.nw_ethernet_channel_send,
Removed Quartz.CGColorConversionInfoCreateFromListWithArguments. This function
was already documented as unsupported, but was still present in the framework
wrapper.
Removed Quartz.CVPixelBufferCreateWithPlanarBytes. This function requires a
manual binding, but was still present with a generic (and non-working) binding.
Removed CoreMedia.CMBufferQueueCreate, CoreMedia.CMBufferQueueGetCallbacksForSampleBuffersSortedByOutputPTS,
CoreMedia.CMBufferQueueGetCallbacksForUnsortedSampleBuffers, CoreMedia.CMVideoFormatDescriptionGetH264ParameterSetAtIndex,
CoreMedia.CMVideoFormatDescriptionGetHVECParameterSetAtIndex,
These functions require a manual binding, but were still present with a generic (and non-working) binding.
Explicitly exclude definitions from CMIOHardwarePlugIn.h from the CoreMediaIO
bindings.
Added deref_result_pointer key to the metadata for a return value. Use this
when a callable returns a pointer to a single value (for example CMAudioFormatDescriptionGetMostCompatibleFormat)
Removed unsupported functions from the ApplicationServices bindings (not named individually due to the size of the list). Also fixed annotations for other ApplicationServices bindings.
Add manual binding for CFNetwork.CFNetServiceBrowserCreate, CFNetwork.CFNetServiceSetClient,
and CFNetwork.CFNetServiceMonitorCreate.
Fix incompatibility with Python 3.12 beta 1.
warning:
Due to changes to the bytecode compiler the bridge will (incorrectly)
deduce that a method does not return a value (void return in Objective-C)
when a method only contains return None statements and no return
statements that return some other value (expressions or constants).
That is the following method is implied to return id for Python 3.11 or
earlier, but is implied to return void in Python 3.12.
def mymethod(self):
return None
548: Fix unexpected error when using mix-in classes
548: Fix unexpected error when using mix-in classes
Fix handling python_method(native_selector) when assigning to a class attribute. That is, the following was broken in 9.1b1:
Fix handling python_method(native_selector) when assigning to a class attribute. That is, the following was broken in 9.1b1:
import Foundation, objc
NSArray.makeArray = objc.python_method(NSArray.arrayWithArray_)
535: Reverted ome of the speedups in assertCallableMetadataIsSane
A new sanity check required reverting some of the speedups in assertCallableMetadataIsSane.
The callable attribute is deprecated, use __wrapped__ instead to access the wrapped callable.
This is a fairly large larger update due to rewriting part of the core logic in Python (where the previous version used C). This does result in some minor semantic changes, but those should only affect edge cases and not normal user code.
These changes were done because it simplifies the code base, and makes it easier to evolve the code (which has already led to a number of easy-of-use improvements as described below).
306: The code that converts a Python callable into an objc.selector when creating an Objective-C class is now written in Python instead of Objective-C.
Note that the interface that the C extension uses to invoke Python code is not a public API and can change in minor releases.
The rewrite found a number of edge cases where the older implementation in C was incorrect or inconsistent. Those problems have been fixed as part of this effort (see below for details).
The BadPrototypeError raised when a method is not compatible with number of arguments expected by Objective-C now mentions the number of arguments excluding the "self" argument, instead of including it.
The new code will accept callables other than functions and bound method as a possible source of objc.selector objects, this can affect code storing a callable object (other than types) as a class attribute.
Wrap these in an objc.python_method to avoid conversion.
Added objc_objc_method that can be used to decorate functions that must be converted to an objc.selector. The decorator has optional keyword arguments to affect the conversion.
objc.python_method is now implemented in Python.
The callable attribute is deprecated, use __wrapped__ instead to access the wrapped callable.
The new implementation requires that the wrapped value is either a callable or a classmethod and won't work with arbitrary values.
Coroutines (generators, async method) are no longer wrapped in an objc.selector by default.
Using a callable that's not compatible with use a selector due to having the wrong number of positional arguments or having keyword-only arguments will now raise consistently during class construction.
objc.python_method is now implemewnted in Python. Due to the reimplementation the callable attribute has been renamed to the more standard __wrapped__ attribute.
For native selectors the signature attribute no longer contains the raw signature, but a cleaned up copy.
Added private function to look for an informal protocol related to a selector name.
Added private function to look registered metadata for a selector name.
PEP-8 compatible multi-word method names are no longer converted to selectors, e.g.:
class MyObject(NSObject):
def some_method(self, a, b):
pass
In previous versions this required using the @objc.python_method decorator.
Method names containing double underscores are no longer converted to selectors, e.g:
class MyObject(NSObject):
def spam__(self, a, b):
pass
def spam__ham_(self, a, b, c):
pass
In previous versions these were converted to, nonsensical, selectors: spam:: and spam::ham:.
Introduce a new optional subkey in __metadata__(): full_signature contains the complete signature for a method.
Setting dunder names in a class will no longer create a selector:
def __dir__(self):
return []
NSObject.__dir__ = __dir__
In PyObjC 9.0 or earlier this resulted in a new selector on NSObject, in PyObjC 9.1 this results a new Python-only method.
This matches the behaviour of defining dunder methods in a class definition.
Wrapping a python_method in a classmethod now works:
class MyClass(NSObject):
@classmethod
@python_method
def spam_spam(self):
pass
Method definitions with varargs are now accepted for selectors when the number of arguments expected in Objective-C "fits":
class MyClass(NSObject):
def correctMethod_(self, *args):
# Args will be a 1-tuple when called
# from Objective-C
pass
def correctMethod2_(self, value, *args):
# 'args' will always be empty when
# called from Objective-C
pass
def incorrectMethod2_(self, value, value2, *args):
# Objective-C will pass exactly one argument,
# this method needs at least 2.
pass
If a python class overrides a method in the superclass it will now use the selector of the superclass method instead of defaulting to a transformation of the method name.
class SuperClass(NSObject):
@objc.selector(selector=b"buttonPressed:")
def pressed(self):
...
class SubClass(SuperClass):
def pressed(self):
...
In previous versions of PyObjC SubClass.pressed would have been a selector with name b"pressed", in PyObjC 9.1 the selector name is inherited from the super class (b"buttonPressed:").
Subclassing an NSCoder has an incompatible change. In previous version of PyObjC the "at" argument for, for example -[NSCoder decodeValueOfObjCType:at:] was not passed to Python, e.g.:
class MyCoder(NSCoder):
def decodeValueOfObjCType_at_(self, encoding):
...
As of PyObjC 9.1 the "at" argument must be present in the the python argument list, and will always be passed None:
class MyCoder(NSCoder):
def decodeValueOfObjCType_at_(self, encoding, at):
...
The same is also true for -[NSCoder decodeBytesWithReturnedLength:].
This makes these methods consistent with the general convention for implementing Objective-C method. This change was missed at earlier cleanups because implementing these NSCoder methods uses custom logic in C.
Added objc._C_PythonObject with the encoding for PyObject*.
This is primarily for internal use by PyObjC, using PyObjC as an FFI tool for calling CPython APIs is not supported.
Added isSlot argument to objc.ivar to define Python variable slots.
This is primairly here for internal use of the bridge, use __slots__ to define slots.
objc.ivar instances can now be compared for equality. Two instances are considered equal if the tuple (name, type, isOutlet, isSlot) for the two values are equal.
When __slots__ is a string the class will have a single slot with that name. In previous versions the class would have a number of slots with single-character names.
The new behaviour matches that of regular Python classes.
The objc.objc_class type now has a __hasdict__ attribute that is True if instances of the class have a __dict__ attribute and is False otherwise.
It is now an error when two instance variables (objc.ivar, including those defined through __slots__) have the same Objective-C name, and that includes redefining a slot in a superclass.
In previous versions this was not an error and the two objc.ivar objects would use the same memory in the instance, which could lead to crashes if the two did not have the same type encoding.
Fix longstanding bug in class construction:
class MyClass(NSObject):
@objc.objc_method(selector="foobar")
def method(self):
pass
In previous versions only MyClass.method is defined, whereas the code in the bridge intended to define MyClass.foobar as well.
Fix type encoding for respondsToSelector: method that's implicitly defined by the bridge.
In previous versions accessing a hidden selector showed an objc.native_selector instead of an objc.selector for hidden selectors implemented in Python, and those objects did not have the isHidden attribute set to true.
506: Code no longer uses PySlice_GetIndicesEx, which was deprecated by CPython in 3.6.
Tweak pyobjc_setup.py to re-enable the error message when trying to install framework bindings on systems other than macOS.
"Hidden" selectors implemented in Python can now be introspected though pyobjc_instanceMethods and pyobjc_classMethod. In previous versions the following assertion would fail:
class MyClass(NSObject):
def hidden(self):
pass
hidden = objc.selector(hidden, isHidden=True)
assert isinstance(MyClass.pyobjc_instanceMethods.hidden)
A side effect of this is that calling hidden methods implemented in Python from Python now uses the "python to python" code path and won't translate argument and return values from Python to Objective-C and back again.
Also note that (as usual) Key-Value Observing (KVO) complicates the picture, if the hidden method is a property accessor (for KVO) and the object is observed accessing the method will result in a "native" selector, not the original one due to the way KVO is implemented in the system.
522: Remove the implementation of respondsToSector: and methodSignatureForSelector:.
In previous versions PyObjC included custom implementation of these methods for subclasses of NSObject implemented in Python, but the default implementation in NSObject works just as well for Python classes.
Creating an objc.ivar will now raise an exception if the specified type encoding is not valid. Previous versions would raise on the first use of the instance variable.
522: Reimplemented objc.informal_protocol in Python
The new implementation adds a number of new methods to give objc.informal_protocol the same interface as objc.formal_protocol, which simplifies the implementation of code using protocols.
That said, objc.informal_protocol still has a selectors attribute that is not present on objc.formal_protocol. This will not change.
522: The code that validates if a new class conforms to all protocols it claims to conform to is now written in Python.
As a side effect of this the error message for an invalid protocol conformance definition no longer mentions with definition was invalid (the protocols keyword or the __pyobjc_protocols__ class attribute).
The new implementation is also more strict in the values of selectors that are accepted, all selectors not be instances of objc.native_selector and must have a callable attribute that is not None.
523: PyObjC's default implementation for -forwardInvocation: now calls the method stub (IMP) through libffi, instead of trying to reproduce the logic of the method stub in the implementation for -forwardInvocation:. This removes about 300 lines of C code and makes sure the semantics of message forwarding match that of regular method calls.
This only affects subclasses of NSObject implemented in Python, the bridge contains a second implementation of forwardInvocation: for regular Python class with limited functionality (and very low performance).
In previous versions PyObjC would introduce an intermediate class between a pure Objective-C super class and the first Python sub class when this was needed for correctness. This class is now always introduced.
There are two reasons for this:
Adding some methods (such as copyWithZone_) to a class after it was constructed caused problems in older version because the intermediate class wasn't present.
Simplifies the code for building a class
The intermediate class is named _PyObjCIntermediate_{NAME} where {NAME} is the name of the super class, in previous versions it was named _PyObjCCopying_{NAME}.
Fix objc.listInstanceVariables failure when one of the classes in the class hierarchy does not have instance variables.
Fix crash when the filter for the UninitializedDeallocWarning warning is set to "error".
Fix conversion of float subclasses with custom __repr__ to objc.NSDecimal.
Fix handling objc.NSDecimal in boolean contexts: In previous versions objc.NSDecimal(0) was interpreted as true-ish in boolean contexts, it now is interpreted as false-ish just like other number types.
381: Add bindings for the IOBluetooth and IOBluetoothUI frameworks
Add bindings for the PHASE framework
#363: Support possible buffer overrun in NSCoder API helpers
The implementations for NSCoder APIs that have a type encoding argument assumed that the Py_buffer representation of the type encoding is a NUL-terminated string.
This is a valid assumption for the bytes and bytesarray types, but is not guaranteed by the buffer API and could result in reading past the end of the buffer when an incomplete type encoding is passed to these APIs.
As a side effect of this fix there is minor change in the API for these methods: - Type encodings containing unions and bitfields now error out early; - Type encodings for structs cannot contain embedded field names; - The APIs are slightly slower due to validating the type encoding.
Calling -[SFAuthorizationView authorizationRights] now works, in previous version the support code was present but enabled for a non-existing method name.
527: The type of objc.NULL is now created with PyType_FromSpec.
This has the unfortunate side effect of making it possible to change type attributes on Python 3.9 or earlier. Do not do this, the type is immutable in Python 3.10 or later.
527: A number of types are now created with PyType_FromSpec:
objc.PyObjCPointer
objc.FILE
objc.formal_protocol
objc.function
objc.NSDecimal
objc.varlist
objc.WeakRef
objc.super
objc.IMP
objc.FSRef
objc.selector
objc.native_selector
objc.python_selector
all types created by objc.createStructType
CoreAudio.AudioBuffer
CoreAudio.AudioBufferList
CoreAudio.AudioChannelDescription
CoreAudio.AudioChannelLayout
CoreAudio.AudioValueTranslation
For these types the class can be changed in Python 3.9 earlier, but not in 3.10 or later. The ability to change class attributes in Python 3.9 and earlier is due to a limitation in PyType_FromSpec in those versions, don't rely on this.
This is a small step towards supporting subinterpreters, although it is unclear at this time when PyObjC will support this in part due to CPython missing some API functionality required by the implementation of objc.objc_object and objc.objc_class when using PyType_FromSpec.
423: objc.ivar is now created with PyType_FromSpec. Because of that the private method objc.ivar._add_attribute has been removed.
The creation of objc.super is now less hacky although it still relies on implementation details of builtins.super.
Fixed bug that could result in a crash when the proxy for a Python iterator ended up being deallocated after the Python interpreter is finalized.
Code cleanup for objc._objc continues, in this version the module initialisation code was much simplified, most of it is now table-driven. This has no user visible effects.
Types created by objc.createStructType now have a (read-only) __packed__ attribute that's -1 if the C struct has default packing, and positive integer when the C struct has some other packing.
382: Add bindings for APIs defined in header xpc/xpc.h
This is a low-level API to perform RPCs using the XPC protocol on macOS.
376: Updated libdispatch bindings, fixing a number of issues with automatic retaincount management.
The python package name in pyobjc-framework-libdispatch is now dispatch instead of libdispatch. The old name also works, with no plans to remove it.
113: Implement JavaScriptCore.JSExportAs
This required some change to pyobjc-core as well. The exact interface used by JSExportAs is for now considered a private implementation detail.
XXX: As this time actually using JSExportAs doesn't work, even though the shape of the protocol looks correctly.
The Metal bindings now contain definitions for MTLPackedFloat3, MTLPackedFloat4x3, MTLAccelerationStructureInstanceDescriptor and MTLPackedFloat3Make.
Upgraded framework bindings for Xcode 14.3 (macOS 13.3 SDK)
Dropped custom implementation of protocol_getMethodDescription
FB11984735: In earlier versions of macOS there were problems with actually registering protocols in some cases. A custom implementation of this function allowed tests to pass. Turns out that debugging code that uses protocol_getMethodDescription during protocol construction caused problems...
535: Speed up standalone tests with assertCallableMetadataIsSane
This assertion method is very slow because it looks at all callable attributes, sped up considerably for standalone tests by only looking at attribute names that might be callable (by poking in implementation details of the lazy loader).
This halves the time needed to run the check for the Cocoa bindings (from over 200 seconds to just over 100 seconds). That's still too slow, but does help.
The method is also smarter about iterating over methods, shaving another 20 seconds from this test.
539: Fix incorrect metadata for IOSurfaceCreate that resulted in a crash when that API was used.
537: Switch from pkg_resources to importlib in the support for bridgesupport XML files because the setuptools project has deprecated the pkg_resources module.
512: Fix metadata for webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler: and webView:runJavaScriptTextInputPanelWithProm
512: Fix metadata for webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler: and webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler: in the WebKit bindings.
508: Reintroduce support for bridgesupport files that was dropped in 9.0.
There are external users for this interface and the replacement used by PyObjC itself is not yet in a state where it can be used by other projects.
Framework bindings were updated for the SDK included in Xcode 14.1
517: Fix bad markup in overview of wrapped frameworks
519: Fix compile error with Python 3.12
Support for macOS 13 (Xcode 14 beta 4)
Support for macOS 13 (Xcode 14 beta 4)
Updated framework bindings for macOS 13
The list below lists the frameworks that have API changes that affect the framework bindings.
Added bindings for the following frameworks (all new in macOS 13):
AVRouting
BackgroundAssets
ExtensionKit
HealthKit
MetalFX
SafetyKit
SharedWithYou
SharedWithYouCore
ThreadNetwork
The definition of a number of basic structs has moved in the SDK for macOS 13 and PyObjC conforms to this change on all platforms.
In particular:
CGPoint, CGSize, CGVector, CGRect, CGAffineTransform and CGAffineTransformComponents are now defined in the CoreFoundation module.
(instead of the other way around in previous versions of PyObjC).
Both changes should require no changes to scripts, unless code relies on the particular __name__ of a type.
The extension API ("pyobjc-api.h") now has nullability annotations, which may lead to compilation errors or warnings when compiling 3th-party extensions using this API.
The extension API ("pyobjc-api.h") has a changed interface for creating method IMPs, because of this extensions for older versions of PyObjC cannot be used with PyObjC 9.
416: PyObjC 9.0 requires Python 3.7 or later
384: Remove support for BridgeSupport files
The bridge itself hasn't used these files for a long time, and system bridgesupport files are basically unusable.
415: Remove objc._setClassExtender
This was an internal function that's no longer used by PyObjC itself.
429: Remove -[OC_PythonNumber getValue:forType:]
This method is never actually used by the system and is not part of the NSNumber interface (but possibly was in the past)
438: Removed bindings for the Message and ServerNotification frameworks.
Both frameworks were removed in macOS 10.9 and hence cannot be used on a platform that's still supported by PyObjC.
451: Removed the type attribute for ObjCPointer
The typestr attribute contains the same value and has more consistent naming with the rest of PyObjC.
436: Quarrtz.CVPixelBufferCreateWithBytes now conforms to the PyObjC standard for returning values: it returns a tuple of two values, the C return value and the value return through pixelBufferOut.
In older versions the return value was only the value return through pixelBufferOut.
464: The encodings objc._C_NSBOOL and objc._C_BOOL are now treated exactly the same as the types BOOL and bool have the same size and representation on arm64 and x86_64.
94: Add support for SIMD types in APIs (types such as vector_float3)
The python representation of these types are types with the same name in defined in objc.simd.
Because the FFI library used by PyObjC (libffi) does not support these types the bridge only supports the method signatures found in system frameworks, other signatures will result in exceptions at runtime.
The relevant libffi issue for this is #408. But note that even if that issue were to be fixed PyObjC likely won't use SIMD support in libffi until that's merged in the system version on macOS.
Because of the previous change APIs that have a SIMD type are now callable from Python.
Changes due to generic implementation for SIMD types:
SpriteKit.SK3DNode.projectPoint_: The result is now objc.simd.vector_float3 instead of a tuple
SpriteKit.SK3DNode.unprojectPoint_: The result is now objc.simd.vector_float3 instead of a tuple
SpriteKit.SKFieldNode.direction: The result is now objc.simd.vector_float3 instead of a tuple
SpriteKit.SKPhysicsWorld.sampleFieldsAt_: The result is now objc.simd.vector_float3 instead of a tuple
Still not supported (requires some more infrastructure):
SpriteKit.SKFieldNode.customFieldWithEvaluationBlock_
The registered metadata can now contain a key full_signature with the full encoding type signature for a method. This is used to replace the encoding extracted from the Objective-C runtime when one or more types have an empty encoding in the Objective-C runtime (such as the SIMD types mentioned earlier)
The Objective-C proxy for Python methods that require a custom helper (instead of using libffi) now use imp_implementationWithBlock.
492: For a number of classes in AVFoundation the system actually uses instances from a parallel class hierarchy with _Tundra as a suffix of the class name.
Updated the metadata generator to automatically register the same metadata updates for these classes as for the original classes.
493: Fix typos in CoreMedioIO metadata for CoreFoundation types
495: Added two new assertions to PyObjCTools.TestSupport.TestCase:
assertArgIsIDLike
assertResultIsIDLike
These assert that the type of an argument or return value is a Objective-C or CoreFoundation object, or a pointer to one.
Fix internal error when an object that cannot be used in a boolean context is used for an ObjC argument that expects a bool or BOOL value.
502: Fix incompatibility with Nuitka.
Earlier version of PyObjC failed when compiled using Nuitka, this version does work when using Nuitka 1.1.6 or later.
Limitations:
The automatic calculation of the method signature in selector() assumes that methods return id for Nuitka compiled code.
That should not be a problem in practice.
As a side effect of this builtin functions are accepted as the callable for a selector, even when not specifying a signature (e.g. objc.selector(dir) now works).
Fixed crash in objc.selector due to uninitialized memory.
Move helpers for NSInvocation from pyobjc-framework-Cocoa to pyobjc-core.
505: Don't use static buffer during creation of "native" selector objects
This can avoid an objc.error exception when introspecting existing Cocoa classes.
479: Revert change that made it impossible to replace a method with a property.
This release contains a small number of bug fixes, most import of which is support for Python 3.11
This release contains a small number of bug fixes, most import of which is support for Python 3.11
Added objc.ObjCPointer.typestr with the same value as objc.ObjCPonter.type. The latter is now deprecated and will be removed in PyObjC 9.
This release continues the work on test coverage in pyobjc-core, resulting in a number of minor bug fixes.
Added two options to the build_ext command in the setup.py of pyobjc-core:
--no-lto: Disable link time optimization
--no-warnings-as-errors: Disable -Werror
For struct bindings in frameworks the "in" operator no longer swallows exceptions raised by the __eq__ method.
Improved handing of invalid type encodings for struct types.
Fix crash while handling a struct wrapper with an invalid type encoding.
Fix handling of empty structs (such as struct foo { }; in objc.repythonify.
The type for NSObject.pyobjc_instanceMethod and NSObject.pyobjc_classMethods now supports the GC protocol to avoid garbage collection issues when the value for these properties is stored as an attribute (which introduces a reference cycle)
PyObjC should work with Python 3.11 alpha release, starting at alpha 6. Earlier alpha's are not supported due to reverting a workaround for a bug that was fixed in alpha 6.
NSObject.alloc = 42 now fails. It was already impossible to replace a selector by something else through instances (NSObject.new().description = 42 raises).
Added objc.ObjCPointer.typestr with the same value as objc.ObjCPonter.type. The latter is now deprecated and will be removed in PyObjC 9.
Better error messages when a class implementing a protocol inherits a method of the wrong kind ("class" vs. "instance").
The value of __slots__ in a class definition is now kept in the created class (previous versions always set the attribute to an empty tuple).
This is primarily useful when __slots__ is a dict that is used to document attributes.
Raise the correct exception when the name of a method is not an ASCII string.
objc.loadSpecialVar now better enforces that the module_globals argument is a Python dictionary.
Fixed a crash in objc.loadSpecialVar due to a missing pointer dereference.
pip install pyobjc-framework-... for a framework that is not present on the current machine will now give a better error message when the "wheel" package is not installed.
Setting an integer option in objc.options to a value of an incompatible type (such as a string) will now raise an exception as intended, instead of breaking the interpreter.
Trying to delete an attribute from objc.options now raises AttributeError instead of TypeError.
objc.selector now copies the default signature from its argument when that argument is another objc.selector.
Until now this would raise an exception.
Added some missing error checking in calls to PyObject_New and PyObject_GC_New.
It is now possible to create an objc.selector from a callable that is not a function or bound method. This may require specifying the method signature in the call to objc.selector.
For pyobjc-core the build_ext command in setup.py now includes the command-line option from the standaard command, which means python setup.py build_ext -j 4 can now be used for parallel builds.
On my M1 laptop using python setup.py build_ext -j 8 halves the time needed to build the extension.
The test command setup.py now supports the -v option to print test cases while they are run, in previoius versions this required using the --verbosity option.
Improve error handling when dealing with "isHidden" selectors.
Added pyobjc_hiddenSelectors(classmethods) to objc.objc_class
This method returns a copy of the dictionary with "hidden" selectors, that is Objective-C selectors that are hidden from view.
The method is primarily a debugging aid for development of PyObjC itself.
#456: ApplicationServices.AXIsProcessTrustedWithOptions and Quartrz.CGPDFArrayGetObject had incorrect metadata.
The testsuites for the various framework bindings now have a test that does some basic checks on function and selector metadata. This test found the problem with CGPDFArrayGetObject.
Added objc._C_ATOMIC and objc._C_COMPLEX, both extracted from the clang sources after finding some type encodings that PyObjC could not decode.
objc._C_ATOMIC is ignored by PyObjC (for now), and objc._C_COMPLEX is not yet supported.
#456: Fix internal error for _C_OUT argument markup on arguments that are CoreFoundation types.
This can only happen with invalid metadata definitions in framework bindings, and earlier versions this resulted in an internal assertion error. With this change the "output" argument is always None in the result.
#463: Fix metadata for a number of functions with a C string argument
The metadata for the following functions was changed to have the correct type encoding for string argument, to fix issues with using non-ASCII (byte) strings.
ApplicationServices.PMWorkflowSubmitPDFWithOptions
CoreServices.LocaleRefGetPartString
Foundation.NSGetSizeAndAlignment
Network.nw_advertise_descriptor_create_bonjour_service
Network.nw_browse_descriptor_create_bonjour_service
Network.nw_browse_descriptor_get_bonjour_service_domain
Network.nw_browse_descriptor_get_bonjour_service_type
Network.nw_connection_copy_description
Network.nw_content_context_create
Network.nw_content_context_get_identifier
Network.nw_endpoint_copy_address_string
Network.nw_endpoint_copy_port_string
Network.nw_endpoint_create_bonjour_service
Network.nw_endpoint_create_host
Network.nw_endpoint_create_url
Network.nw_endpoint_get_bonjour_service_domain
Network.nw_endpoint_get_bonjour_service_name
Network.nw_endpoint_get_bonjour_service_type
Network.nw_endpoint_get_hostname
Network.nw_framer_create_definition
Network.nw_framer_message_access_value
Network.nw_framer_message_copy_object_value
Network.nw_framer_message_set_object_value
Network.nw_framer_message_set_value
Network.nw_framer_options_set_object_value
Network.nw_listener_create_with_port
Network.nw_privacy_context_create
Network.nw_quic_get_application_error_reason
Network.nw_quic_set_application_error
Network.nw_txt_record_access_key
Network.nw_ws_options_add_additional_header
Network.nw_ws_options_add_subprotocol
Quartz.CGContextSelectFont
Quartz.CGContextShowText
Quartz.CGContextShowTextAtPoint
Quartz.CGDataProviderCreateWithFilename
Quartz.CGPDFArrayGetName
Quartz.CGPDFContentStreamGetResource
Quartz.CGPDFDictionaryGetArray
Quartz.CGPDFDictionaryGetBoolean
Quartz.CGPDFDictionaryGetName
Quartz.CGPDFDocumentUnlockWithPassword
Quartz.CGPDFScannerPopName
Quartz.CGPDFTagTypeGetName
While fixing this issue I found problems with the metadata for these functions:
CoreMIDI.MIDIExternalDeviceCreate
CoreMedia.CMBlockBufferAccessDataBytes
CoreMedia.CMBlockBufferGetDataPointer
CoreMedia.CMBufferQueueInstallTriggerHandler
CoreMedia.CMBufferQueueInstallTriggerHandlerWithIntegerThreshold
CoreMedia.CMTextFormatDescriptionGetJustification
CoreServices.TECGetTextEncodingFromInternetNameOrMIB
DVDPlayback.DVDGetScanRate
MediaAccessibility.MACaptionAppearanceAddSelectedLanguage
There's also a new test that checks for this problem in all exposed functions.
Fix incorrect reset of the "inline_list" attribute of the lazy importer, this could result in an incorrect TypeError when trying to access an non-existing attribute after looking at __all__.
Fix uniqueness of symbols exposed in the OpenDirectory bindings.
Unhide manual bindings for Security.SecKeychainFindGenericPassword and Security.SecKeychainFindInternetPassword.
Wheels were build with Xcode 13.3 RC
This is a bug fix release.
#455: pip install pyobjc on a macOS 12.2 machine tried
to install pyobjc-framework-ScreenCaptureKit, which is
only can be installed on macOS 12.3 or later.
#456: Fix bad metadata for HIServices.AXIsProcessTrustedWithOptions
Wheels were build with Xcode 13.3 RC
There are no changes in framework bindings relative to PyObjC 8.4 because there are no relevant API changes in Xcode 13.3 RC.
The bindings for the Message and ServerNotification frameworks, which were removed in macOS 10.9, will be removed in PyObjC 9.
The bindings for the Message and ServerNotification frameworks, which were removed in macOS 10.9, will be removed in PyObjC 9.
Added bindings for ScreenCaptureKit (new in macOS 12.3)
Updated framework bindings for the macOS 12.3 SDK.
Based on Xcode 13.3 beta 3
Reverted a change in 8.3: It is once again not possible to use the "is" operator to check if two proxies for an NSString refer to the same Cocoa object.
The change in 8.3 changed long standng behaviour for mutable strings and may have caused unintended problems.
#418: Added typing.NewType definitions to the various framework bindings for all enum types in Cocoa (such as NSComparisonResult).
Using this it is now possible to annotate methods returning such types, although it is not yet possible to type check this.
For example:
class MyObject(NSObject):
def compare_(self, other: NSObject) -> NSComparisonResult:
return NSOrderSame
The actual representation of enum types is provisional and might change in the future.
#440: Added typing.NewType definitions to the various framework bindings for all NS_STRING_ENUM, NS_TYPED_ENUM and NS_TYPED_EXTENSIBLE_ENUM types in Cocoa.
#432: Fix compatibility check when a class implements protocol NSObject.
The following code used to fail the protocol implementation check:
class AppDelegate( Cocoa.NSObject, protocols=[objc.protocolNamed("NSApplicationDelegate")]):
pass
The reason for this is that the type encodings for (at least) -[NSObject respondsToSelector:] in the Objective-C runtime doesn't match the type encoding in @protocol(NSObject) (the former returns char, the latter bool). The compatibility check now handles trivial differences like this.
#428: Class NSData now implements the API from bytes. The methods that return bytes in bytes also return bytes in NSData. This may change in a future version.
Class NSMutableData now implements the API from bytearray as far as this doesn't conflict with the native API. In particular, NSMutableData.copy() returns an immutable copy (instance of NSData), use NSMutableData.mutableCopy() to create a mutable copy.
Note
The implementation is mostly suitable for fairly small amounts of data as the Cocoa value is first copied into a Python value.
NSData([1,2,3]) and NSMutableData([1,2,3]) now work the same as bytes([1,2,3]) and bytearray([1,2,3]).
#334: Workaround for catetory on NSMutableArray that introduces a conflicting pop method
Some class in Cocoa can at times introduce an (undocumented) selector -pop on subclasses of NSArray, which conflicts with a convenience method that emulates list.pop. The version introduces a workaround for this by adding the convenience method to all (statically known) subclasses of NSArray.
This is far from perfect, but fixes the problem for now.
Fix memory manager API misuse
PyObjC's str subclass used the python allocator API incorrectly, causing an assertion failure when running tests with "python3 -Xdev", as well as a hard crash due to using the API without holding the GIL.
#445: Workaround for Python 3.11 support
Workaround for `BPO-46891 <https://bugs.python.org/issue46891 >`_, which causes a hard crash in the PyObjC testsuite. With this workaround the tests for pyobjc-core pass with python 3.11a5, but this does result into adding some implementation internals to the __dict__ of framework wrappers when using Python 3.11
Fix build error on macOS 10.9
Fix str implementation invariant in the objc.pyobjc_unicode subclass. With this fix the string consistency checks in debug builds of CPython pass.
Fix exception handling when passing a bytes object to a C function with a byte buffer "inout" argument.
This release contains a lot of small fixes dueo to the continued improvement of test coverage for the C code in pyobjc-core.
This release contains a lot of small fixes dueo to the continued improvement of test coverage for the C code in pyobjc-core.
Backward incompatible change:
-[OC_PythonDictionary setObject:value forKey:[NSNull null]] now sets key None in the Python dictionary instead of NSNull.null().
This is for consistency with -[OC_PythonDictionary objectForKey:] and other collection classes. Getting and setting key [NSNull null] now actually works.
Backward incompatible change:
-[OC_PythonDictionary removeObjectForKey:] now raises NSInvalidArgumentException instead of Python's KeyError for missing keys. This matches the documented behaviour of NSDictionary.
Backward incompatible change:
-[Protocol descriptionForClassMethod:] now only accepts selector names (such as b"description") as its argument, not instances of objc.selector. This matches the behaviour of other methods with an argument of the C type SEL.
:func"objc.namedSelector and objc.typedSelector now also work when the decorated function is a classmethod.
Fix build problem on macOS 10.14 or earlier
The Objective-C proxy for a python int is now always OC_PythonNumber, in previous versions instances were proxied as NSNumber when the value was in the range of an unsigned long long that's outside of the range of a (signed) long long (that is, a value between 2**63 and 2**64).
Two NSString* values in Objective-C are now proxied to the same objc.pyobjc_unicode instance when the two pointers are equal in Objective-C.
That is, given NSString* value1 and NSString* value2 value1 == value2 in Objective-C can be replaced by value1 is value2 in Python. In older versions of PyObjC this invariant was not maintained, requiring more involved code to check if two strings represent the same object.
This invariant was already maintained for other instances of other Objective-C classes.
The proxy for python's bytearray (and other writable buffers) now supports the mutableBytes method in Objective-C.
As a side effect of this OC_PythonData is now a sublcass of NSMutableData instead of NSData.
Fixed retrieving an bytearray value from a Cocoa archive
In previous versions this resulted in garbage data.
Instances of bytearray can now be included in "secure" Cocoa archives
Remove -[OC_PythonArray getObjects:inRange:], it is not part of the regular NSArray interface and was never used.
The proxy for python datetime objects was rewritten to be a lot simpler.
User visible changes:
The new implementation is more correct, the old implementation truncated timestamps at whole seconds.
Calculating in Objective-C (such as calling -[NSDate dateByAddingTimeInterval:] will now always result in an NSDate value, not a Python value.
The proxy code now calls the "timestamp" method instead of "strftime" during conversion from Python to Objective-C.
Adding datetime.datetime and datetime.date instances to an archive now works, both for keyed and classic archives.
For the exact types datetime.datetime and datetime.date the encoding is compatible with that of NSDate and supports NSSecureCoding as long as the values are not timezone aware.
When communicating with pure Objective-C code any timezone information will be lost.
Note that both datetime.datetime and datetime.date are represented as an NSDate in Objective-C land, even though this Objective-C has semantics of the latter class don't fully match that of the Cocoa class.
Fix python internal error when the "module_globals" argument to objc.loadBundleFunctions is not a dict.
Fix the result of inspect.signature for objc.IMP.
In previous versions this included the implicit "selector" argument that isn't used by Python callers.
Avoid crash when trying to load a "magic" cookie CoreFoundation value for a type unknown to the PyObjC bridge.
Removed -[OC_PythonObject pyObject].
The method is no longer used by PyObjC itself, and these proxy objects are considered a private API that may change at any time.
Removed +[OC_PythonObject classForUnarchiver]
This method was present for compatibility with the NSObject interface, but isn't actually part of Cocoa.
-[OC_PythonObject methodSignatureForSelector:] and +[OC_PythonObject methodSignatureForSelector:] now return nil instead of raising an exception when the queried selector does not exist. This matches the behaviour of NSObject.
Fix the metadata in the bindings for DiscRecording, Intents, SceneKit, and libdispatch to ensure that the __all__ variable actually works.
Eliminated usage of sscanf in pyobjc-core
A possible user visible change is that the use of sscanf to parse an IPv4 address has been replaced by a call to inet_pton(), which may affect different representations of an IPv4 address.
OC_PythonSet now epxlictly calls set related methods instead of using C-API functions like PySet_Clear. This simplifies the pyobjc-core code, and gives fewer problems with set subclasses.
Fix the buffer size used to for "struct sockaddr" arguments
Added objc._C_CFRange and objc._C_NSRange with the type encodings of the C types CFRange and NSRange.
Functions and methods where the length of a C array argument is passed in another argument (such as int function(int* buffer, size_t bufsize)) now also work when the argument with the size is a pointer to a CFRange or a pointer to a char.
A memoryview of an NSMutableData instance is now writable.
Fix crash when trying to create an objc.informal_protocol with a sequence of selectors that contains a value that isn't an instance of objc.selector.
#435: Fix build problem with Xcode 13.3
Xcode 13.3 introduces a new warning in -Wall: -Wunused-but-set-variable, and this found some code quality issues with PyObjC.
objc.allocateBuffer is deprecated, use bytearray instead
This release contains a lot of little fixes due to improving test coverage of the C code in pyobjc-core. These are mostly fixes for edge cases that don't happen in normal programs.
Reintroduce binary wheels for Python 3.6
PyObjC 8.x still supports Python 3.6, but I didn't ship binary wheels until now.
I plan to explicitly remove support for Python 3.6 in PyObjC 9, which will include updating package metadata to ensure that users of Python 3.6 will keep using PyObjC 8.x.
#414: [Python 3.10] The representation for C structures, like Foundation.NSPoint now have a __match_args__ attribute, which means it is now possible to use positional arguments to these types in match expressions.
For example:
from Foundation import NSPoint
value = ...
match value:
case NSPoint(0, _):
print("On the Y axis")
The internal extension API between framework bindings and pyobjc-core has been cleaned up a little. Because of this extensions need to be recompiled for this version.
objc.allocateBuffer is deprecated, use bytearray instead
This function has always returned a bytearray object in Python 3 and it no longer necessary.
As a side effect of this change the function is now implemented in Python instead of C.
The private function objc._dyld_shared_cache_contains_path is now always available, and unconditionally returns False on systems without a shared library cache.
The private function objc._setClassExtender is now implemented in Python and will be removed in PyObjC 9.
Removed private function objc._typestr2typestr.
This function was untested and is no longer used by PyObjC.
Removed the selector supportsWeakPointers from a number of classes.
This method may have been needed during Apple's transition to ARC, but is no longer document and I've never seen it called during testing on recent versions of the OS.
Furthermore the custom implementation of retain and release in PyObjC is a thin wrapper around the default one with additional locking to avoid race conditions during deallocation.
objc.recylceAutoReleasePool will now restore the global release pool when called after calling objc.removeAutoreleasePool.
Removed objc.FSSpec
This is a wrapper for a C type that's only usable in 32-bit code, PyObjC no longer supports 32-bit.
The default implementation of -copy for subclasses of Objective-C classes that implemented -copy (needed to adjust Python attributes) didn't consider that the superclass implementation of -copy may return an instance of a different class. This caused a hard crash.
The easiest way to trigger this bug: Create a subclass of NSMutableData in Python, create an instance of that class and call the copy method.
The module PyObjCTools.TestSupport was modernized a little
This most visible part of this is that a number of functions and assertion method have been removed because they have a better alternative in the unittest library.
#404: Instances of the Python represention of C structs can now be pickled.
That is, instances of AppKit.NSPoint, Foundation.NSRange, etc. can be pickled. The exception are a number of types in the CoreAudio bindings that have manual wrapper types instead of the generic support in pyobjc-core.
Switch to PyCapsule_Import to load the PyObjC API object in extension modules.
Fix crash when calling objc.FSRef.from_pathname() with a path that cannot be encoded in the filesystem encoding (UTF-8).
Fix name of opaque pointer type wrappers (such as Foundation.NSZonePtr)
The "__name__" and "__qualname__" attributes were correct, but the corresponding slot in the C struct of the type could point to no longer valid memory.
Function objc.registerABCForClass now actually works
Fix bug in lazyloader where fetching the module's __all__ could raise AttributeError for some particular constants.
#317: Cleanup code dealing with libffi closures APIs on various versions of macOS.
If fetching the __pyobjc_object__ attribute during conversion from Python to Objective-C raisea an exception other than AttributeError the conversion will fail.
In previous versions the attribute was ignored when this happens.
Fix error in __str__ and __repr__ of an Objective-C instance when the class' description selector returns nil.
Fixed crash in conversion of an Objective-C exception to a Python exception when the exception name is NULL.
Type encoding that ends with an incomplete pointer definition will now raise an error earlier, in particular before the first time the callable is used.
Using a value for the metadata dict of functions and selectors that is not a dict now raises an exception instead of being silently ignored.
The "suggestion" function metadata was ignored for objc.function instances using the fast FFI variant.
Deprecating the function returned by an API exposed through objc.function would cause a crash.
Fix value of the "deprecated" key in the result of __metadata__() for callables that are deprecated in a macOS version.
Loading metadata for a function with more than 63 arguments would crash the interpreter.
Note that calling such function is not supported even with this bugfix.
#406: The "docstring" field in the function list argument for objc.loadBundleFunctions was effectively ignored. It is now part of the document string (__doc__) of the objc.function object.
Actually implemented cyclic GC support in objc.python_method.
Fix crash when calling -[NSObject dealloc], -[NSObject retain] or -[NSObject release] though an objc.IMP, for example:
anObject = NSObject.alloc().init()
retain = anObject.methodForSelector_("retain")
retain(anObject)
Tests in pyobjc-core better check the message of raised exceptions
This resulted in some minor changes in messages, this should not affect code using PyObjC.
Fix the __name__ and __repr__ result for the exact class objc.objc_object.
Fix use of uninitialized variable in the code that converts a C struct from Objective-C to a Python tuple.
Added PyObjCTools.TestSupport.no_autorelease_pool to disable autorelease pool management by the test runnner for a specific test.
NSMutableArray.insert(idx, value) would fail when idx is beyond the length of the array. It now behaves the same as list.insert, the item will be appended to the array.
Change the way type specific class methods are added to objc.ivar.
This changes the way class methods are added to objc.ivar to be more correct in the CPython interpreter.
#425: Fix CoreMIDI bindings
The CoreMIDI is a wheel with a limited ABI tag, but one of the two extensions was build without using the limited ABI, resulting in a wheel that worked only for one python version.
All messages from the deprecated module PyObjCTools.Signals are now printed on stderr.
Added a "flush" method to objc.FILE
objc.FILE.readline would crash if the file is closed in Python.
Instance variable descriptors can now be retrieved from a class. That is, given:
class SomeClass(NSobject):
myvar = objc.ivar("myvar")
It is now possible to access SomeClass.myvar, in previous versions this raised TypeError.
SomeClass.alloc() would raise an internal error in PyObjC 8 when this method returned nil.
399: Fix error message when passing wrong number of arguments in a call of an Objective-C method
399: Disable support for Py_TPFLAGS_METHOD_DESCRIPTOR in objc.selector and objc.python_method.
I'm looking for a better solutions, but for now this is needed to avoid problems in code that stores a bound selector as class attribute.
401: AppKit.NSCenterTextAlignment and AppKit.NSRightTextAlignment had a wrong value for arm64 systems.
Update framework bindings for Xcode 13.2 (macOS 12.1 SDK)
PyObjC now works correctly on macOS 11 or later when compiled on macOS 10.15 or earlier.
All messages from the deprecated module PyObjCTools.Signals are now printed on stderr.
PyObjCTools.MachSignals won't cause an interpreter error when the signal dictionary doesn't contain a handler for a signal.
value in someNSPoint works again, instead of hanging the interpreter.
The module PyObjCTools.Signals is deprecated and will be removed in PyObjC 9.
## Backward incompatible changes
In PyObjC 7 and earlier it was possible to leave out "output" arguments when calling a method with a Python implementation:
class MyClass(NSObject):
@objc.typedSelector(b"@@:o^@")
def methodWithOutput_(self, a):
return 1, 2
o = MyClass.alloc().init()
print(o.methodWithOutput_())
This no longer works, it is always necessary to pass in all arguments, which was already true for methods implemented in Objective-C. That is:
print(o.methodWithOutput_(None))
This change both simplifies the PyObjC code base and was required to cleanly implement vectorcall support (see the section on performance below).
Removed bindings for InterfaceBuilderKit. This was a way to integrate with InterfaceBuilder in old versions of Xcode, but support for that was dropped before the release of Mac OS X 10.8.
Bindings for the Objective-C runtime API related to "associated objects" is now enabled unconditionally. This will cause problems when running or building on macOS 10.6 or earlier.
It is no longer possible to deploy to macOS 10.7 or earlier when you attempt to create a formal protocol. Protocol creation already failed on those platform due to lack of the required runtime API, and that will now result in a crash because PyObjC no longer checks for availability of that runtime API.
#371: Remove manual bindings for a number of old CoreGraphics APIs
The following functions are no longer available:
CGDataProviderCreate
CGDataProviderCreateDirectAccess
These functions were removed as a public API in macOS 10.8, but were still available through PyObjC through old backward compatibility code. That code has now been removed.
For compatibility with Python's socket APIs functions that return a "struct sockaddr" (either by reference or as a function result) will now encode the IP address as a string and not a bytes object.
The (undocumented) API in pyobjc-api.h (used in some framework bindings to integratie with pyobjc-core) has changed in an incompatible way, in particular the API for "caller" functions now mostly mirrors the vectorcall convention.
Adding a method with a double underscore name will now raise an exception at class definition time instead of silently not creating the Objective-C method.
class AClass (NSObject):
...
def __foo_bar__(self, a, b, c):
pass
MethodNamesClass.__foo_bar__ = __foo_bar__
Before PyObjC 8 this would add a ``__foo_bar__`` selector to the Python
representation of the class without adding a selector to the Objective-C class.
Use objc.python_method to mark this as a python-only function.
## Upcoming incompatible changes
The module PyObjCTools.Signals is deprecated and will be removed in PyObjC 9.
objc.initFrameworkWrapper and objc.parseBridgeSupport are deprecated and will be removed in PyObjC 9.
These functions implement support for ".bridgesupport" XML files, something that PyObjC hasn't used itself in a number of releases (in part because system versions of those files are at best incomplete).
## Performance
Most performance changes use features introduced in Python 3.9, performance in older Python versions is unchanged except for the effects of general cleanup.
Implement the "vectorcall" protocol for objc.function, objc.WeakRef, objc.selector, objc.IMP, objc.python_method.
This reduces the interpreter overhead for calling instances of these objects.
Implement Py_TPFLAGS_METHOD_DESCRIPTOR for objc.selector, objc.python_method.
Use vectorcall in the method stub that forwards Objective-C calls to Python.
Convert internal calls into Python to the vectorcall protocol (pyobjc-core)
Add more optimized vectorcall implementation to objc.function, objc.IMP and objc.selector for simpler callables.
In the current version "simpole enough" callables have a 8 or fewer arguments, and none of those arguments are pass by reference. This will change over time.
## Generic Implementation Quality
#391: Fix some spelling errors found by the codespell tool.
The codespell tool is also run as part of pre-commit hooks.
#296: use clang-format for Objective-C code
The Objective-C code for the various extensions has been reformatted using clang-format, and this enforced by a pre-commit hook.
#374: Use pyupgrade to modernize the code base
This is enforced by a pre-commit hook.
#388: Added "nullability" attributes to Objectice-C sources for pyobjc-core.
This gives the compiler and clang static analyzer more information that can be used to pinpoint possible bugs in the implementation. As a side effect of this a number of internal checks were strengthened, although most of them were for error conditions that should never happen.
That said, this change also found a number of places where Python reference counts weren't updated properly, which may have led to refcount overflows in long running programs.
Add more error checking to pyobjc-core to catch (very) unlikely error conditions.
This is a side effect of the previous item.
## New features
Updated framework bindings for macOS 12
New framework bindings for the following frameworks:
AudioVideoBridging (introduced in macOS 10.8)
DataDetection (introduced in macOS 12.0)
IntentsUI (introduced in macOS 12.0)
LocalAuthenticationEmbeddedUI (introduced in macOS 12.0)
MailKit (introduced in macOS 12.0)
MetricKit (introduced in macOS 12.0)
ShazamKit (introduced in macOS 12.0)
#318: Implement support for __class_getitem__ for Objective-C classes
The result of this is that effectively all Objective-C classes can be used as generic classes, without runtime type checking. This is meant to be used with optional type checking (for example MyPy)
Usage:
def create_integers(count: int) -> NSArray[int]:
return NSArray[int].arrayWithArray_([i for i in range(count)])
Note
This requires typing stubs for framework bindings to be really useful, and those do not yet exist.
#354: Add an option to install all framework bindings, including those not relevant for the current platform. To use this:
$ pip install 'pyobjc[allbindings]'
## Other changes and bugfixes
#390: pyobjc-core is no longer linked with the Carbon framework.
Due to implicit dependencies this also required a change to the Metal bindings: those now import AppKit instead of Foundation.
PyObjC only ships "Universal 2" wheels for Python 3.8 and later. Those work with single-architecture builds of Python as well.
PyObjC 8 only ships with source archives and "univeral2" binary wheels (Python 3.? and later). There are no longer "x86_64" binary wheels.
The AVFoundation bindings (in pyobjc-framework-AVFoundation) now have an install dependency on the CoreAudio bindings (pyobjc-framework-CoreAudio).
This is needed for a new API introduced in macOS 12.
#371: Link extensions in the Quartz bindings to the Quartz frameworks
A number of C extensions in the Quartz bindings package were not linked to a framework. Those now link to the Quartz framework.
#378: Fix raising ImportError when doing from ApplicationServices import *
The root cause for this were private classes in system frameworks that contain a dot in their name (for example Swift.DispatchQueueShim. Those names are both private and invalid attribute names.
Creating protocols that contain methods that have a method signature containing PyObjC custom type encodings now works (those encodings are translated to the corresponding Objective-C encoding.
Fix bindings for SKIndexCopyDocumentRefsForDocumentIDs, that binding didn't work due to a typo in the metadata.
#365: The PyObjCTools namespace package no longer has an __init__.py file in the source tree (that is, the tree switches to implicit namespace packages instead of the older setuptools style for namespace packages).
This primarily affects testing with recent versions of pip/setuptools (which seem to no longer install the __init__.py file for namespace packages).
development-support/run-testsuite now uses venv instead of virtualenv. This removes a development dependency.
PR# 367: Tweak the code that calculates PyObjC_BUILD_RELEASE in the various setup.py files to deal with versions with more than two labels (can happen when building using Xcode 13 beta)
PR by Eric Lin (Tzu Hsiang Lin), github user eric100lin.
PyObjCTest.TestSupport now never uses "10.16" as the OS release but always uses the actual platform version, even when Python was compiled using an old SDK.
Adjusted PyObjC testcases to check for 11.0 instead of 10.16 now that testsupport uses the real platform version.
#385: Fix race condition the lazy importer
When two threads simultaneously try to get an attribute from a framework binding one of them might fail with an attribute error because information for resolving the name was removed before actually resolving the name.
Fix various issues with invalid indices in objc.varlist
Fix support for AF_UNIX in the support code for struct sockaddr.
The implementation for opaque pointer types (such as the proxy for 'NSZone*') has switched to PyType_FromSpec.
The objc.FSRef.from_path and objc.FSRef.as_pathname, methods now use the filesystem encoding instead of the default encoding. C string. This shouldn't affect any code, both encoding default to UTF-8 on macOS.
Inheriting directly from objc.objc_object now raises TypeError instead of objc.InternalError. User code should always inherit from a Cocoa class.
Nothing published for this version
With WWDC and beta of a new major release of macOS approaching fast it is high time to push out a new release for PyObjC. PyObjC 7.3 is primarily a bu
With WWDC and beta of a new major release of macOS approaching fast it is high time to push out a new release for PyObjC. PyObjC 7.3 is primarily a bugfix release, with one minor feature.
I expect this to be the last release for PyObjC 7.x and will start working on PyObjC 8 soon.
issue 356: Explicitly error out when building for unsupported architectures
"python setup.py build" will now fail with a clear error when trying to build PyObjC for a CPU architecture that is no longer supported (such as 32-bit Intel)
issue 319: Use memset instead of bzero in C code to clear memory
Based on a PR by GitHub user stbdang.
issue 348: Fix platform version guard for using protocols in MetalPerformanceShaders bindings
issue 344: Fix test for CFMessagePortCreateLocal
The tests didn't actually test calling the callback function for CFMessagePortCreateLocal.
issue 349: Change calls to htonl in pyobjc-core to avoid compiler warning
The original code had a 32-bit assumption (using 'long' to represent a 32-bit value), and that causes problems for some users build from source.
issue 315: Fix binding for SecAddSharedWebCredential (Security framework)
Trying to use this function will no longer crash Python.
issue 357: Calling Metal.MTLCopyAllDevices() no longer crashes
The reference count of the result of this function was handled incorrect, causing access to an already deallocated value when the Python reference was garbage collected.
issue 260: Add manual bindings for AXValueCreate and AXValueGetValue in ApplicationServices
Calling these crashed in previous versions.
issue 320, 324: Fix the type encoding for a number of CoreFoundation types in the Security bindings
issue 336: Add core support for "final" classes
It is now possible to mark Objective-C classes as final, that is to disable subclassing for such classes.
This is primarily meant to be used in framework bindings for matching Objective-C semantics.
The "final" feature adds two new APIs:
A keyword argument "final" when defining a new class
class MyClass (NSObject, final=True):
pass
An read-write attribute __objc_final__ on all subclasses of NSObject.
Note that this is a separate concept from typing.final.
Update bindings for the macOS 11.3 SDK
Update bindings for the macOS 11.3 SDK
This SDK introduces a separate AVFAudio framework, but PyObjC continues to expose these APIs through the AVFoundation bindings.
Update bindings for the macOS 11.1 SDK
Update bindings for the macOS 11.1 SDK
Add bindings for framework "AdServices" (new in macOS 11.1)
333: Improve SDK version detection in framework bindings
337: PyObjC doesn't work on Catalina or earlier
337: PyObjC doesn't work on Catalina or earlier
Fix by Lawrence D'Anna.
This version drops support for 32-bit executables, both the core bridge and the framework wrappers only support 64-bit executables going forward
This version drops support for 32-bit executables, both the core bridge and the framework wrappers only support 64-bit executables going forward
PyObjC is now always build with the system libffi.
Removed metadata for 32-bit systems
Existing framework bindings were updated for the macOS 11 SDK
Added bindings for the following frameworks: - Accessibility (introduced in macOS 11.0) - AppTrackingTransparency (introduced in macOS 11.0) - CallKit (introduced in macOS 11.0) - ClassKit (introduced in macOS 11.0) - KernelManagement (introduced in macOS 11.0) - MetalPerformanceShaders (introduced in macOS 10.13) - MetalPerformanceShadersGraph (introduced in macOS 11.0) - MLCompute (introduced in macOS 11.0) - PassKit (introduced in macOS 11.0) - ReplayKit (introduced in macOS 11.0) - ScreenTime (introduced in macOS 11.0) - UniformTypeIdentifiers (introduced in macOS 11.0) - UserNotificationsUI (introduced in macOS 11.0) - Virtualization (introduced in macOS 11.0)
Dropped the bindings to the QTKit framework
This framework was removed in macOS 10.15.
These bindings contained a C extension and cannot be build with recent versions of Xcode.
Dropped the bindings for the XgridFoundation framework
This framework was removed in macOS 10.8.
Updated objc.dyld_library and objc.dyld_framework to return a sane result on macOS 11 where system libraries are no longer at the expected location, but in a shared cache.
Another attempt at giving a nice error message when trying to install on platforms other than macOS.
Another attempt at giving a nice error message when trying to install on platforms other than macOS.
#311: Build for the Metal bindings failed on macOS 10.14
#309: Fix incompatibility with macOS 11 in framework loader
Another attempt at giving a nice error message when trying to install on platforms other than macOS.
The classifiers now correctly identify supported Python versions
311: Build for the Metal bindings failed on macOS 10.14
309: Fix incompatibility with macOS 11 in framework loader
The classifiers now correctly identify supported Python versions
301: pyobjc-framework-Metal build failed on macOS mojave
Python 3.10 support: Don't assume the result of Py_REFCNT, Py_SIZE and Py_TYPE are an lvalue.
Python 3.10 support: Completely phase out use of old buffer API, which will be removed in Python 3.10.
As a side effect of this a number of extensions that used the limited ABI once again use the regular ABI.
Removed remnants of support for i386, ppc and ppc64 from pyobjc-core.
Added type to manage Py_buffer lifetimes to the internal API in pyobjc-core, to be used by framework wrappers.
Add objc._C_BYREF. This definition was missing, but isn't used in modern ObjC code.
323: Remove leading slashes from detected SDK patch to avoid miscalculating the version.
Patch by GitHub user linuxfood.
322: Avoid None error in PyObjCTools.AppHelper
Patch by github user mintho
321: Fix typo in documentation
Patch by github user russeldavis
Issue #299: Ensure package 'pyobjc' won't try to build the PubSub bindings on macOS 10.15
Issue #299: Ensure package 'pyobjc' won't try to build the PubSub bindings on macOS 10.15
Reported by Thomas Buchberger
Minor tweaks to build and pass tests on macOS 10.14 with the latest Xcode that can be installed on that version of macOS.
Issue #300: Fix SystemError in block edge case
PyObjC raised a SystemError when converting a callable into an ObjC block when the callable is a bound method without positional arguments.
Issue #275: Fix crash on catalina caused by writing to read-only memory.
Patch by Dan Villiom Podlaski Christiansen
PR #302: Make sure the SDK detection works when the version is not in the SDK name
Patch by Joshua Root
There were no SDK updates in Xcode 11.5 and Xcode 11.6 (beta)
The project has moved from Bitbucket to Github
The project has moved from Bitbucket to Github
Remove most remnants of Python 2 support
Clean up code quality issues found using flake8
Add pre-commit hook to run black on all Python code.
#290: Fix protocol conformance testing when explicitly implementing a protocol
Before this bugfix a class explicitly conforming to a protocol could not implement any method that wasn't declared in the protocol, the bridge would erroneously raise an exception when checking the additional method.
Issue reported by Georg Seifert.
#289: Fix Python 3 issues in PyObjCTools.Conversion
Reported by vinolin asokan.
PyObjCTools.Conversio.propertyListFromPythonCollection didn't
recursively convert members of lists and tuples.
PyObjCTools.Conversio.propertyListFromPythonCollection and
PyObjCTools.Conversio.pythonCollectionFromPropertyList now
support sets.
Update metadata for Xcode 11.4 (beta 2)
Added bindings for framework AutomaticAssessmentConfiguration.framework
introduced in macOS 10.15.4
#298: In some cases the compiler uses the type encoding "^{NSObject=#}" instead of "@".
Reported by Georg Seifert.
#264: Added bindings for the Metal framework (new in macOS 10.11)
Most framework bindings now use the limited ABI for the included C extensions, reducing the number of wheels that are needed. The exception are the bindings for Cocoa, Quartz and libdispatch, those use functionality not available in the limited ABI.
The bridge itself (pyobjc-core) still uses the full CPython API.
The CoreAudio bindings also don't use the limited ABI for now, those need more work to work with that ABI.
Updated for the macOS 10.15.1 SDK (Xcode 11.2)
Updated for the macOS 10.15.1 SDK (Xcode 11.2)
Fix reference counting in -[OC_PythonData length], which resulted in use-after-free.
#281: Fix problems found in pyobjc-core by the clang static analyser
* #277: Remove debug print accidently left in production * #278: Surpress "-Wunguarded-availability" warnings in the extension AppKit._inlines
#277: Remove debug print accidently left in production
#278: Surpress "-Wunguarded-availability" warnings in the extension AppKit._inlines
277: Remove debug print accidentally left in production
278: Suppress "-Wunguarded-availability" warnings in the extension AppKit._inlines
Removed Python 2 support from the C extension in pyobjc-core
Removed Python 2 support from the C extension in pyobjc-core
Reformatted code in pyobjc-core:
Use "black" for Python code
Use "clang-format" for Objective-C code
As a side-effect of this all usage of "NS_DURING" and "PyObjC_DURING" has been replaced by the expansion of those macros, mostly because "clang-format" doesn't understand these kinds of blocks.
Replacing "PyObjC_DURING" by its expansion also reduces the knowledge needed to understand what's going on w.r.t. the Python GIL.
The macro "PyObjC_DURING", and its siblings, have been removed as well.
Updated bindings for macOS 10.15 (Xcode 11.0)
The userspace driver frameworks introduced in macOS 10.15 (DriverKit and related frameworks) will not be exposed through PyObjC. Please let me know if you have a good use case for using these frameworks with Python.
Add new framework wrappers for all other new frameworks in macOS 10.15:
Add new framework wrappers for a number of older frameworks:
Issue #271: Fix crash when creating NSData objects on macOS 10.15
PR 21: Switch xcodebuild invocation to xcrun for sdk path
PR 21: Switch xcodebuild invocation to xcrun for sdk path
Patch by Clément Bouvier
#271: Fix crash when creating NSData objects on macOS 10.15
Fix compile error on macOS 10.15
The function is still deprecated though, the deprecation will reappear once the metadata has been updatd.
Updated metadata for Xcode 10.2
#252: objc.registerStructAlias no longer emits a deprecation warning because it is still used by the framework wrappers.
The function is still deprecated though, the deprecation will reappear once the metadata has been updatd.
#75: The core bridge now uses PyDict_GetItemWithError, which may result in exceptions being raised that were previously swallowed.
#247: Partially switch to the new buffer API instead of the older Python 2 buffer API.
The new implementation is more correct, but may keep Python objects alive longer than the previous implementation, and also affects buffer related functionality of Python objects. In particular, calling [someData bytes] on a Python object keeps the Py_buffer alive until the next flush of the autoreleasepool.
#257: Fix incorrect metadata for the callback argument to -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:].
#258: Add bindings to the "PrintCore" APIs from the ApplicationServices framework.
Python 2: UserDict.UserDict instances are now bridged to instances of a subclass of NSDictionary.
PyObjC's metadata system didn't automaticly set the call signature for blocks passed into a method implemented in Python. This causes problems when th
#254: Fix compile error on macOS 10.9 or earlier
#255: Calling completion handler failed due to incomplete runtime info
PyObjC's metadata system didn't automaticly set the call signature for blocks passed into a method implemented in Python. This causes problems when the ObjC or Swift block does not have signature information in the ObjC/blocks runtime.
Use MAP_JIT when allocating memory for the executable stubs for Python methods.
With the "restricted" runtime you'll have to add the "com.apple.security.cs.allow-jit" entitlement to use this flag, in earlier versions you'd have to use a different entitlement: "com.apple.security.cs.allow-unsigned-executable-memory".
The MAP_JIT flag is only used on macOS 10.14 or later.
Ensure that PyObjC can be built using /usr/bin/python on macOS 10.14
This failed due the problems with header files in the SDK included with Xcode 10.
* Update metadata for Xcode 10.1
Updated the support code for framework wrappers to be able to emit deprecation warnings on the first import of a deprecated constants (functions and m…
Xcode 10 "GM" contains one difference from the last beta: the constant MLComputeUnitsCPUAndGPU in the CoreML bindings.
#222: Add a proxy for C's "FILE*" type on Python 3. This is not necessary on Python 2 because the default IO stack on Python 2 already uses FILE* internally.
This proxy type is very minimal and shouldn't not be used for general I/O.
Bindings are up-to-date w.r.t. Xcode 10.1 (beta)
Updated the support code for framework wrappers to be able to emit deprecation warnings on the first import of a deprecated constants (functions and methods will only raise a deprecation warning when called).
This is just an infrastructure change, the actual framework bindings do not yet contain the information used to emit deprecation warnings.
Add metadata for deprecation warnings to the "Contacts" framework
#252: Import ABCs from collections.abc instead of collections because the latter is deprecated.
#180, #251: Instances of most builtin value types and sequences (int, float, str, unicode, tuple, list, set, frozenset and dict) can now be written to archives that require secureCoding.
Version 5.0 of PyObjC primarily adds support for macOS 10.14 (mojave), and also adds support for a couple of older frameworks that weren't supported b
Version 5.0 of PyObjC primarily adds support for macOS 10.14 (mojave), and also adds support for a couple of older frameworks that weren't supported before.
PR19: Fix deprecation warning in bridgesupport support module
Bindings updated for Xcode 10 beta 6.
Add a custom binding for a number of structure types in CoreAudio:
With this patch using APIs with these types should actually work.
PR19: Fix deprecation warning in bridgesupport support module
Patch by: Mickaël Schoentgen
Creating objc.ObjCPointer instances now results in a Python warning, instead of an unconditional message on stdout.
.. note::
The creation of these objects is a sign that APIs are not wrapped correctly, these objects are created for pointers where the bridge doesn't know how to handle them properly.
System bridgesupport XML files (normally not used by PyObjC) can contain constant numbers with value "inf", PyObjC now knows how to handle those.
Added bindings for the "Metadata" subframework of the "CoreServices" framework.
Added bindings for the "CarbonCore" subframework of the "CoreServices" framework.
Most APIs in this subframework are not available to Python, only those APIs that are not deprecated and seem interesting are exposed.
The separate framework wrappers DictionaryServices, LaunchServices and SearchKit are deprecated, use the CoreServices bindings instead.
These framework wrappers still exists, but are effectively aliases for CoreServices with this release. Because of this these bindings can expose more symbols than previously.
Fix unexpected exception when trying to call getattr on a framework wrapped with a name that isn't a valid identifier.
#244: Bad metadata for CGPDFOperatorTableSetCallback
#247: Fix crash in regression test case
One specific test in pyobjc-core crashed the interpreter when run separately. Because of this I've disabled an optimization that uses alloca instead of PyMem_Malloc to allocate memory for now.
Adds support for macOS 10.14 (Mojave)
Adds support for macOS 10.14 (Mojave)
This release updates the framework wrappers with support for new APIs in macOS 10.14 and adds bindings for the following new frameworks:
Support for CoreAudio, CoreMedia and MediaToolbox is limited in this release due to missing manual wrappers.
Added two features that can help with gating code on the version of macos:
The constants "objc.MAC_OS_X_VERSION_CURRENT" can be compared with one of the "objc.MAC_OS_X_VERSION_..." contants.
The function "objc.macos_avaiable(major, minor[, patch])" returns true if the current macOS version is at least the specified version, comparable with "@available" in Swift.
The binary release now includes wheels for both variants for the Python.org installer for python 3.6 and 3.7: 32- and 64-bit for macOS 10.6 or later,
Update metadata for Xcode 9.4
The binary release now includes wheels for both variants for the Python.org installer for python 3.6 and 3.7: 32- and 64-bit for macOS 10.6 or later, and 64-bit only for macOS 10.9 or later.
Ensure the context manager for NSAnimationContext defined in
PyObjCTools.AppCategories actually works.
Fix convenience wrappers for Foundation.NSCache.
Fix convenience wrappers for Foundation.NSHashTable.
Update metadata for Xcode 9.4 beta 2 (no changes)
Update metadata for Xcode 9.4 beta 2 (no changes)
Restore autodetection of --with-system-ffi, but ignore this python setting for /usr/bin/python because Apple doesn't ship libffi headers.
Undeprecate treating struct wrappers as sequences. Removing this feature would break too much existing code, hence deprecating is not really an option…
Add bindings to the BusinessChat framework introduced in macOS 10.13.4
Update metadata for Xcode 9.3
Issue #233 Fix crash in Security.AuthorizationCopyRights() wrapper
Issue #234 Fix crash in AuthorizationExecuteWithPrivileges() wrapper
Reported by Vangelis Koukis
Ensure doctest can work with modules containing subclasses of NSObject
Reported by Just van Rossum
Issue #236 : Importing can sometimes fail in multi-threaded scenarios
Fix by Max Bélanger
Undeprecate treating struct wrappers as sequences. Removing this feature would break too much existing code, hence deprecating is not really an option. Furthermore, this would also break some nice idioms.
Pull request #17: Fix python 3 issues in PyObjCTools.AppHelper and PyObjCTools.Conversion
Fix by Max Bélanger
The bindings for the Security framework don't expose a number of older APIs that were deprecated in macOS 10.7.
Protection agains buffer overflow and negative indexes in __getitem__ and __setitem__ for objc.varlist instances.
Fix incorrect metadata for +[NSEvent addLocalMonitorForEventsMatchingMask:handler:]
Fix incorrect and misleading error message in the exception that is raised when return a value from a block that should not return a value.
Issue #223: Fix hard crash when executing help(Cocoa)
Fetching the help for PyObjC framework wrappers isn't very useful due to the sheer size of the output (4.5 million lines of output for help(Cocoa) at the moment), but shouldn't cause a hard crash of the interpreter.
Reported by Dave Fuller
Issue #218: Explictly cause an ImportError when reloading `objc._objc`
Reloading the PyObjC core extension now raises an ImportError because this cannot work and used to raise a rather vague error.
Updated metadata for Xcode 9.2
Added missing `MAC_OS_X_VERSION_*` constants
Fix memory error in struct wrappers which resulted in a use-after-free error in the initializer for structs.
#135: Add bindings for frameworks Security, SecurityFoundation and and SecurityInterface.
The bindings for the Security framework don't expose a number of older APIs that were deprecated in macOS 10.7.
#129: Add bindings to libdispatch.
These bindings require macOS 10.8 or later, libdispatch was available earlier but macOS 10.8 changed the API in such a way that wrapping became a lot easier.
Protection against buffer overflow and negative indexes in __getitem__ and __setitem__ for objc.varlist instances.
Fix incorrect metadata for +[NSEvent addLocalMonitorForEventsMatchingMask:handler:]
Fix incorrect and misleading error message in the exception that is raised when return a value from a block that should not return a value.
223: Fix hard crash when executing help(Cocoa)
Fetching the help for PyObjC framework wrappers isn't very useful due to the sheer size of the output (4.5 million lines of output for help(Cocoa) at the moment), but shouldn't cause a hard crash of the interpreter.
Reported by Dave Fuller
218: Explicitly cause an ImportError when reloading `objc._objc`
Reloading the PyObjC core extension now raises an ImportError because this cannot work and used to raise a rather vague error.
Updated metadata for Xcode 9.2
Added missing `MAC_OS_X_VERSION_*` constants
Fix memory error in struct wrappers which resulted in a use-after-free error in the initializer for structs.
135: Add bindings for frameworks Security, SecurityFoundation and and SecurityInterface.
The bindings for the Security framework don't expose a number of older APIs that were deprecated in macOS 10.7.
129: Add bindings to libdispatch.
These bindings require macOS 10.8 or later, libdispatch was available earlier but macOS 10.8 changed the API in such a way that wrapping became a lot easier.
Note
Blocks scheduled using libdispatch are still subject to the Python GIL: just one block implemented in Python can run at any one time.
Issue #213: Fix signature for `-[NSObject forwardInvocation:]`
Issue #213: Fix signature for -[NSObject forwardInvocation:]
Reported by user "pyrocat"
Updated metadata for Xcode 9.1
Changes to PyObjCTools.TestSupport to be able to include/exclude tests based on the minor release of macOS.
Some tweaks to fix test failures when running on OSX 10.5, 10.6, 10.9.
NOTE:
The stacktrace formatting of in PyObjCTools.Debugging (from the
ExceptionHandling bindings) don't work for PPC binaries because symbol
resolution doesn't work.
This is a known issue that won't be fixed.
Issue #204: Metadata for CGPDFDictionaryGetObject was wrong
Issue #204: Metadata for CGPDFDictionaryGetObject was wrong
Reported by Nickolas Pohilets.
Updated metadata for Xcode 9 GM.
Fix #202: Add bindings for CGPDFDictionaryRef, CGPDFScannerRef CGPDFStreamRef and CGPDFStringRef to the Quartz bindings (including some minor updates to function metadata)
Reported by Nickolas Pohilets.
Issue #205: Add ability to read bytes from objc.varlist
Instances of objc.varlist now have a method to return a memoryview that refers to the first section of the list:
def as_buffer(self, count : int) -> memoryview
This returns a memoryview the references the underlying memory for the first count elements in the list.
Reported by Nickolas Pohilets.
Added bindings for the GameKit framework introduced in macOS 10.8.
Added bindings for the GameplayKit framework introduced in macOS 10.11.
Note that these bindings are less useful than they could be because PyObjC currently does not support "vector" types that are used in some APIs.
Using wrappers for C structs as sequences is deprecated, this feature was introduced a long while ago when the framework wrappers were very incomplete…
Removed PyObjCTools.TestSupport.filterWarnings, use warnings.catch_warnings instead.
Building pyobjc-core using "python setup.py develop" will use 'ccache' when available.
Building pyobjc-core will compile the source files from new to old files, to speed up feedback while working on the source code.
Legacy BridgeSupport files on macOS 10.13 (which aren't used by default by PyObjC) can contain junk data in typestring data. Cleanup that data before using it.
Deal with loading bundle variables of a C string type, that used to crash to do an oddity of locating that information.
Using wrappers for C structs as sequences is deprecated, this feature was introduced a long while ago when the framework wrappers were very incomplete and is no longer usefull.
Add objc.options.structs_indexable. When this option is True (the default) wrappers for C structs behave as before, when the option is False these wrappers can no longer be used as writable tuples, that is all "sequence" methods will raise TypeError.
Add objc.options.structs_writable. When this option is True (the default) wrappers for C structs behave as before, when the option is False these wrappers can no longer be modified.
Add availability macro MAC_OS_X_VERSION_10_13 to objc.
New framework wrappers:
ColorSync (new in macOS 10.13)
CoreML (new in macOS 10.13)
ExternalAccessory (new in macOS 10.13)
CoreSpotlight (new in macOS 10.13)
Vision (new in macOS 10.13)
metadata updates:
Accounts
AddressBook
AppKit
ApplicationServices
Automator
AVKit
CalendarStore
CFNetwork
CloudKit
Contacts
CoreBluetooth
CoreData
CoreFoundation
CoreGraphics
CoreImage
CoreLocation
CoreServices
CoreText
CoreVideo
CoreWLAN
CryptoTokenKit
EventKit
FinderSync
Foundation
FSEvents
GameController
IMServicePlugIn
ImageCaptureCore
ImageIO
Intents
IOSurface
JavaScriptCore
LocalAuthentication
MapKit
MediaLibrary
MediaPlayer
ModelIO
MultipeerConnectivity
NetFS
NetworkExtension
OpenDirectory
Photos
PhotosUI
QTKit
Quartz
QuartzCore
QuickLook
SafariServices
SceneKit
ScreenSaver
Social
SpriteKit
SystemConfiguration
WebKit
Small change to the shared setup.py code for framework wrappers to allow building wheels for wrappers without a C exention on any system.
Updates:
Small change to the shared setup.py code for framework wrappers to allow building wheels for wrappers without a C exention on any system.
This was mostly done to make it easier to provide wheels in future releases.
Bugfixes:
Avoid build error with Python 2.7 when using the OSX 10.12 SDK, triggered when Python was build using MacPython support.
Compatibility definitions for MAC_OS_X_VERSION_10_10, MAC_OS_X_VERSION_10_11 and MAC_OS_X_VERSION_10_12 were wrong, adjusted these.
Fix obscure crash in test suite of pyobjc-core: the definition of a class that claims to conform to a protocol but didn't actually conform could result in having a partial class definition in the Objective-C runtime.
Updated implementation for NSMutableArray.extend. This both avoids an
error with the list interface tests in Python 3.6, and avoids unnecessary
memory usage with large arguments.
Nothing published for this version
Backward compatibility note: Due to a change in the way the default method signature is calculated PyObjC is now more strict in enforcing the Python<-
Backward compatibility note: Due to a change in the way the default
method signature is calculated PyObjC is now more strict in enforcing
the Python<->Objective-C mapping for selectors and a number of code patterns
that were allowed before are no longer allowed, in particular the following
method definitions raise objc.BadPrototypeError::
class MyObject (NSObject): def mymethod(self, a, b): ... def method_arg_(self, a, b, c): ...
If these methods are only used from Python and are never used from Objective-C
the error can be avoided by decorating these methods with objc.python_method::
class MyObject (NSObject): @objc.python_method def mymethod(self, a, b): ...
This cannnot be used for methods used from Objective-C, for those you will have to rename the method or you will have to provide an appropriate selector explictly.
Fix crash when using some APIs in the LaunchServices framework.
Issue #100:Building with the Command Line Tools for Xcode installed caused build errors on OSX 10.10
Python 3.6 made a change to the bytecode format that affected the way PyObjC calculates the default method signature for Python methods.
Earlier versions of PyObjC will therefore not work properly with Python 3.6.
Update metadata for macOS 10.12.1
Note: Building PyObjC on macOS 10.12 requires Xcode 8.1 (or a later version)
Added bindings for the SafariServices and Intents frameworks, both introducted in macOS 10.12.
Added bindings for the MediaPlayer framework, introducted in macOS 10.12.1.
Add bindings for the ModelIO framework, introduced in OSX 10.11.
Issue #153: Add missing metadata file to ApplicationServices bindings
Issue #157: Bad reference to "_metadata" in ApplicationServices bindings
ApplicationServices framework didn't do "from ... import *" as was intended.
Don't force the installation of py2app.
Fix build failure using the OSX 10.10 SDK.
Issue #21: Tweak build procedure for PyObjC to avoid building pyobjc-core
multiple times when using pip install pyobjc.
Issue #123: Use Twisted's cfreactor module in the examples using Twisted.
Issue #148: Fix build issue for the MapKit bindings on a case sensitive filesystem.
Added bindings for the IOSurface framework (pyobjc-framework-IOSurface)
Added bindings for the NetworkExtension framework (pyobjc-framework-NetworkExtension)
Issue #149: Fix compile problems with Anaconda
Fix SystemError for accessing a method whose __metadata__ cannot be calculated,
found while researching issue #122.
Issue #146: Don't hang when running python setup.py build using PyPy.
Note that PyPy still doesn't work, this just ensures that the build fails instead of hanging indefinely.
Issue #143: Fix calculation of default type signature for selectors
Due to this change it is possible to use decorators like this::
def decorator(func): @functools.wraps(func) def wrapper(*args, **kwds): return func(*args, **kwds) return decorator
Before this patch PyObjC gave an error due to the signature of wrapper,
and if wrapper was defined with an explicit self argument PyObjC would
not give an error but would calculate the wrong method signature for wrapped
methods.
An unfortunate side effect of this change is that the argument count
of methods must now match the implied argument count of the selector, that is
a method with name someMethod_ must now have exactly two arguments (self
and the argument implied by the underscore at the end).
Use objc.python_method as a decorator for python methods that don't use
this convention and do no need to be registered with the Objective-C runtime
as Objective-C selectors.
The bridge now considers the default arguments for a function when determining if the Python signature of a function is compatible with the Objective-C signature, that is the following method definition is valid::
class MyObject (NSObject): def someMethod_(self, a, b=2): pass
The default selector calculated for Python methods with embedded underscores and without a closing underscore has changed, the embedded underscores are not translated to colons because the resulting Objective-C selector would not be valid.
That is, in earlier versions the default selector for "some_method" would be "some:method", and from this version on the default for selector for this method is "some_method".
(Python 3) Methods and functions with keyword-only arguments that don't have defaults
cause a objc.BadPrototypeError exception when proxied to Objective-C
because those can never be called from Objective-C without causing an
exception.
Sigh... A number for sdists were incomplete due to missing MANIFEST.in files.
Sigh... A number for sdists were incomplete due to missing MANIFEST.in files.
Fix value of FLT_MAX and FLT_MIN in framework bindings.
Fix value of FLT_MAX and FLT_MIN in framework bindings.
Fix for the functions in PyObjCTools.AppHelper: those functions didn't work
correctly when the calling thread didn't have a runloop.
Patch by Max Bélanger.
Issue #126: Load the LaunchServices definitions through the CoreServices umbrella framework to avoid problems on OSX 10.11.
Issue #124: Sporadic crash at program shutdown due to a race condition between Python interpreter shutdown and Cocoa cleanup.
This is mostly a workaround, I don't have a full solution for this yet and I'm not sure if one is possible.
Added objc.PyObjC_BUILD_RELEASE which contains the version of the SDK
that was used to build PyObjC in the same format as the OSX availability
macros.
Added maxTimeout parameter to PyObjCTools.AppHelper.runConsoleEventLoop
to fix issue #117. The default value is 3 seconds, which means that
the console eventloop will stop within 3 seconds of calling stopEventLoop.
Re-enable faster method calls for simple method calls.
Support OSX 10.10 in PyObjCTools.TestSupport (version comparison was too naive)
Add bindings for ApplicationServices, currently only the HIServices sub framework is exposed.
Add bindings for NetFS, introduced in OSX 10.7.
Add bindings for ImageCaptureCore. Initial patch by Max Bélanger.
Add bindings for IMServicePlugIn, introduced in OSX 10.7.
Add bindings for SceneKit, introduced in OSX 10.8.
Add bindings for CoreBluetooth, MapKit, AVKit, MediaLibrary, MediaAccessibility, GameController (all new in OSX 10.9)
Add bindings for FinderSync, CloudKit, CryptoTokenKit, MultipeerConnectivity, NotificationCenter (all new in OSX 10.10)
Add bindings for Contacts, ContactsUI, Photos, PhotosUI (new in OSX 10.11)
Added function objc.callbackPointer.
Updated bindings for AppKit, CoreData, CoreFoundation, CoreGraphics, CoreLocation, CoreText, CoreVideo, CoreWLAN, EventKit, FSEvents, ImageIO, ImageKit, JavaScriptCore, LaunchServices, OpenDirectory, PDFKit, QuartzComposer, QuartzCore, QuartzFilters, QuickLookUI, ServiceManagement, Social, StoreKit and WebKit with the new APIs introduced in OSX 10.9, 10.10 and 10.11.
Unchanged framework bindings: Collaboration, DictionaryServices, ExceptionHandling, InputMethodKit, InstallerPlugins, InstantMessage, InterfaceBuilderKit, LatentSemanticMapping, PreferencePanes, PubSub.
.. note::
InterfaceBuilderKit will likely be removed in a future version of PyObjC
TODO: DiskArbitration, GameController, SpriteKit bindings are incomplete
Fix hard crash with invalid type strings in metadata.
Default value for struct wrappers was incorrect for fields that have a type encoding that's custom to PyObjC.
Fix a type string validation error that could cause PyObjC to continue processing beyond the end of a type string (which can effectively hang the python interpreter with 100% CPU usage)
Fix edge-case in NSCoding support that causes PyObjC to use proxy objects of the wrong type in some cases.
Fix incompatibility with Python 3.6 (where inspect.getargspec no longer
exists)
Added (private) function objc._copyMetadataRegistry. This function returns
a copy of the internal registry that's used to find additional information
about method signatures.
Note that the data structure returned by this function is subject to change, that the data structure is undocumented and that modifying it does not affect the data used by PyObjC.
Your coding agent can read these notes before it upgrades. Set up the MCP server →