Pyobjc

Latest version: v11.0

Safety actively analyzes 701298 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 13 of 18

1.4

--------------------------

- Classes whose name starts with and underscore are no longer imported when
using ``objc.loadBundle``. They are still available using
``objc.lookUpClass``.

Methods whose name starts with an underscore are no longer visible when
introspecting using ``dir()``, but can still be called.

These changes were done to make introspection slightly more user-friendly:
anything that is now hidden from introspection is most likely not part of
a public API.

- Most of the libffi testsuite is now run using a module that emulates
dejagnu.

- Introduction of a GUI tool to manage custom method signatures
(``Tools/Signatures``). This replaces the ``find-raw-pointers.py`` script.

- Fixed memory leak in ``OC_PythonObject``, this was due to bad reference
counting.

- ``NSMutableArray.sort`` now has the same API as ``list.sort``. Due to
implementation constraints the ``key`` argument results in slower sorting
than you'd see with ``list.sort``.

- Selectors now have a read-only property 'native_signature' that contains
the untampered signature for the method. This is for use by tools.

- 'void*' arguments are treated like unsigned integers, they are almost always
opaque cookies.

- ``FILE*`` arguments are recognized and mostly work correctly. We can't
reliably detect if the file was opened in append mode though.

- Make it possible to override the KVO methods, like ``setValue:forKey:`` and
``valueForKey:`` in Python for all levels in the inheritance hierarchy.

- Fix issues with reference counts for ``__slots__``.

- Experimental: use ``-autorelease`` instead of ``-release`` to release
values in destructors. This seems to solve at least one memory management
issue.

- A slight complication in the naming rule:

1) Don't translate leading underscores in Python to colons in Objective-C,
``_doFoo_andBar_`` in Python will be ``_doFoo:andBar:`` in Objective-C.

2) If a name starts and ends with double underscores don't modify the
name at all when moving from Python to Objective-C,
``__foobar__`` in Python will stay that way in Objective-C.

These changes fix some minor annoyances with the older scheme. Note that
the translation from Objective-C to Python is unmodified and is entirely
consistent with the modified rules for translating from Python to Objective-C.

- Fix for a memory leak in ``__pyobjc_object__`` handling.

1.3.7

--------------------------

- Added wrappers for embedded DiscRecording frameworks
([ 1224188 ] Fix for DiscRecording framework)

- Probably working Xcode 2.1 support (for converted Xcode 2.0 projects)

- Hide List, Object, and Protocol classes from objc.loadBundle
to prevent confusion with Python code. They can still be looked
up with objc.lookUpClass.

- Fixed a regression where type signatures for pointers weren't
normalized (fixes uses of NSModalSession, etc.)

- Fixed a bug with -[NSObject hash] to __hash__, there was a mismatch
between integer types.

- Removed traces of the old Project Builder and Xcode templates in the
examples and Foundation initialization code (PYOBJCFRAMEWORKS).

- Fixed a problem with reference counting in initializers.

- New TinyURLService example in AppKit that demonstrates how to write
a service that transforms URLs into their tinyurl.com equivalents.

- Ported to macOS on Intel. This is an initial, experimental port. The
Intel ABI has not been finalised yet. It is also possible to build fat
binaries, that option should not be used in production builds.

- Support a number of new frameworks:

* SenTestingKit

TODO: this framework uses lots of macros (such as STAssertEquals), these
have not yet been wrapped/converted.

* SecurityFoundation

1.3.6

--------------------------

- Fixed bugs in the ProgressViewPalette example

- Fixed a bug in the class builder that caused most plugins to break

- Removed all references to Project Builder

- macOS 10.2 (Jaguar) no longer supported

1.3.5

--------------------------

- Importing objc now ensures that Foundation is multi-threaded, previously
it only ensured that Python was.

- New ``objc.RegisterCFSignature`` used to register ``CFTypeRef``-like
signatures with the runtime.

- ``PyObjCTools.Conversion`` functions now support all property list
types with the following conversions:

- NSData <-> buffer
- NSDecimalNumber <-> decimal.Decimal (if present)
- NSDate <-> datetime.datetime

New ``toPythonDecimal``, ``fromPythonDecimal`` functions which convert
between NSDecimalNumber and decimal.Decimal using an intermediate string.

New ``serializePropertyList`` and ``deserializePropertyList`` functions
which serialize (Objective-C) property lists to and from NSData.

- ``OC_PythonObject``, the proxy for Python objects that do not have
an Objective-C superclass and are not otherwise special-cased, now
act slightly more like typical Objective-C objects (supporting
``-isEqual:``, ``-hash``, and ``-compare:``). This allows them
to work with Key-Value Coding if they are contained by an Objective-C
object, among other things.

- New objc.signature decorator that allows easier specification of
objc.selector wrappers for functions when using Python 2.4:

.. sourcecode:: python

objc.signature('i:if')
def methodWithX_andY_(self, x, y):
return 0

- ``PyObjCTools.KeyValueCoding.getKeyPath`` now supports all of the
Array Operators supported by macOS 10.4.

- Key-Value Coding of Python objects (whether or not using an Objective-C
base class) should act like Objective-C now. In previous versions
there were inconsistencies with the use of capitalization, the
underscore postfix in setters, and Key-Value Observing.

- The formal protocol list is now complete. A new internal function,
``objc.protocolsForProcess()`` enumerates over all mach
headers and returns all of the protocols defined in the expected
place. This fixes the scenario where an application uses a
protocol but does not define any classes that
conform to that protocol (i.e. to check plugin conformity).
Previously it was not possible to reach these protocols simply by
walking over all of the classes.

- A special value, ``objc.NULL``, may now be passed in the place
of 'in' and 'inout' arguments. This tells the bridge to pass
a NULL pointer to the Objective-C method, instead of a pointer
to the value. The return value will still be a tuple of the
expected size.

- Some of the new Tiger frameworks now have wrappers:

- ``AppleScriptKit``
- ``Automator``
- ``CoreData``
- ``DiscRecording``
- ``DiscRecordingUI``
- ``OSAKit``
- ``Quartz``
- ``QTKit``
- ``SyncServices``
- ``XgridFoundation``

Documentation and tests not yet written.

- New ``OutlineEditor`` example in ``Examples/CoreData``,
it is a Python version of the identically named Apple example.

- The last argument of selectors that end with ':error:' is now
assumed to be 'out' if its type is an object pointer.

- More conveniences for ``list``-like and ``dict``-like
objects: ``__reversed__``, ``reverse``, ``pop``,
``remove``, ``fromkeys``.

- ``OC_PythonDictionary`` and ``OC_PythonArray`` now return
``NSNull`` to Objective-C callers as appropriate.

- New ``WebKitInterpreter`` example in ``Examples/Plugins``.
Uses the new WebKit Cocoa plugin API available in Safari 1.3
and later to embed a PyInterpreter in the browser.

- Fixed a ``CFBundleRef`` reference counting bug in
``Foundation._Foundation``. The symptom of this is usually
a crashing application after having loaded a PyObjC-based
plugin into an otherwise Objective-C app.

- New ``PyObjCTools.AppHelper`` functions: ``callAfter`` and
``callLater``, conveniences for calling Python functions on
the main thread as soon as possible, or after a delay.

- Twisted examples changed to use ``threadedselectreactor``
instead of ``cfreactor``. ``cfreactor`` is deprecated.
Needs Twisted newer than 2.0 (svn r13575 or later).

- ``objc.inject`` now injects on main thread by default,
and takes an optional third ``useMainThread`` argument
to change this behavior. This is a complete rewrite
which should be correct, stable, Tiger compatible,
and synchronized with mach_* 1.1.

- Removed an ``NSAutoreleasePool`` category hack that has
been deprecated for quite some time.

- New ``objc.removeAutoreleasePool`` function that will remove
PyObjC's global ``NSAutoreleasePool``, which may be useful
for plugins.

- Fixed bug in the ``NSBundle`` hack that caused a ``NULL``
pointer dereference if looking up a non-existent class using
``NSBundle`` API.

- Added ``OC_PythonUnicode`` and ``OC_PythonString`` classes that
preserve the identity of ``str`` and ``unicode`` objects across
the bridge. The bridge for ``str`` now uses the default
encoding of ``NSString``, rather than ``sys.getdefaultencoding()``
from Python. For macOS, this is typically MacRoman. The reason
for this is that not all Python ``str`` instances could cross the
bridge at all previously. ``objc.setStrBridgeEnabled(False)`` will
still trigger warnings, if you are attempting to track down an
encoding bug. However, the symptoms of the bug will be incorrectly
encoded text, not an exception.

- New Xcode project template "PyObjC Mixed Application" that is
a py2app based Python application that loads an Objective-C
plug-in built as a separate target.

- New py2app based Xcode templates "PyObjC Application" and
"PyObjC Document-based Application", these replace the
older "Cocoa-Python Application" and
"Cocoa-Python Document-based Application" respectively.

- New ``InjectBrowser`` example in ``Examples/Inject`` that demonstrates
injection of the ``ClassBrowser`` example into another application using
``objc.inject``.

- ``NSData`` and ``NSMutableData`` instances now support the Python buffer
protocol.

- ``NSData`` instances now support a convenience API that allow them to
act like a ``buffer`` instance for ``str()`` and slicing.

- Objects that support the Python buffer protocol, such as ``buffer`` and
``array.array`` (but not ``str`` or ``unicode``) are now bridged as
``NSData`` subclasses.

1.3

------------------------

- New ``objc.pyobjc_id`` function that returns a the id of the underlying
NSObject as an integer. (Python wrapper objects are often made on the
fly, meaning ``id(obj)`` is not constant during the lifetime of the
object.)

- The bridge now maintains object identity across the bridge
in both directions. Previous versions of the bridge only did this when
bridging from Objective-C to Python.

Exceptions: ``NSString`` and ``NSNumber`` do not have unique proxies. These
types are converted to subclasses of Python types as appropriate, so they
can not have unique proxies. The identity of the original Objective-C
object is maintained by these subclasses, but there may be many Python
"value proxies" for a single Objective-C object.

Any Python object that is proxied using the ``__pyobjc_object__``
interface will only get a unique proxy if the ``__pyobjc_object__``
method implements that feature.

- New ``objc.protocolsForClass`` function that returns a list of protocols
that the class directly claims to conform to.

- PyObjC classes can now declare that they implement formal protocols,
for example:

.. sourcecode:: python

class MyLockingClass(NSObject, objc.protocolNamed('NSLocking')):
implementation
pass

It is also possible to define new protocols:

.. sourcecode:: python

MyProtocol = objc.formal_protocol("MyProtocol", None, [
selector(None, selector='mymethod', signature='v:'),
])

All formal protocols are instances of ``objc.formal_protocol``.

- PyObjCTools.KeyValueCoding has a new ``kvc`` class that allows
Pythonic Key-Value Coding.

- ``__getitem__`` is mapped to ``valueForKeyPath:``
- ``__setitem__`` is mapped to ``setValue:forKeyPath:``
- ``__getattr__`` is mapped to ``valueForKey:``
- ``__setattr__`` is mapped to ``setValue:forKey:``

The ``kvc`` class uses ``__pyobjc_object__``, so it may cross the bridge
as the wrapped object.

- ``NSNumber`` instances are bridged to a ``float``, ``long``, or ``int``
subclass that uses ``__pyobjc_object__``.
``NSDecimal`` is converted to ``NSDecimalNumber`` when used as an object,
``NSDecimalNumber`` is not bridged to ``NSDecimal`` because the latter is
a mutable type.

- The Python to Objective-C bridge now looks for a ``__pyobjc_object__``
attribute to get a PyObjC object from a Python object.

- New IDNSnitch example in Inject that demonstrates how to write an
monitor for the launch of another application,
use ``objc.inject`` to load code into a target process,
and override the implementation of an existing method but still
call back into the original implementation (method swizzling).

- ``objc.IMP`` should do the right thing now. This type is returned
by ``+[NSObject methodForSelector:]`` and
``+[NSObject instanceMethodForSelector:]``

- New ToDos example in CocoaBindings that demonstrates how to use
two array controllers for the same data, and how to use value
transformers to alter the color of text. Originally from
"Cocoa Bindings Examples and Hints", converted to PyObjC by u.fiedler.

- New Bookmarks example in CocoaBindings that demonstrates how to
subclass ``NSArrayController`` to implement the ``NSTableView``
delegate drag and drop protocol, including copying of objects between
documents and accepting URL drops from other applications. Also
demonstrates re-ordering of the content array. Originally from
"Cocoa Bindings Examples and Hints", converted to PyObjC by u.fiedler.

- New FilteringController example in CocoaBindings that demonstrates
how to subclass ``NSArrayController`` to implement filtering
of a ``NSTableView``. Also demonstrates the use of indexed accessors.
Originally from "Cocoa Bindings Examples and Hints", converted to PyObjC
by u.fiedler.

- New ControlledPreferences example in CocoaBindings that demonstrates
how to use Cocoa Bindings to simplify storing and retrieving user
preferences. Originally from "Cocoa Bindings Examples and Hints",
converted to PyObjC by u.fiedler.

- New TemperatureTransformer example in CocoaBindings that demonstrates
how to use NSValueTransfomers with PyObjC. Based on Apple's
"Cocoa: Value Transformers" documentation, converted to PyObjC
by u.fiedler.

- New CurrencyConvBindings example in CocoaBindings that demonstrates
a Cocoa Bindings enabled version of the CurrencyConverter example.
Converted to PyObjC by u.fiedler from the example in Apple's
"Introduction to Developing Cocoa Applications Using Bindings".

- New ManualBindings example in CocoaBindings that demonstrates how
to develop programmatic bindings from a PyObjC application.
Converted to PyObjC by u.fiedler from the "Cocoa Bindings and Hints"
example of the same name.

- New HotKeyPython example in AppKit that demonstrates how to use
Carbon global hot keys from a PyObjC application. Also demonstrates
how to use a NSApplication subclass.

- Key-Value Observing support is now automatic in Python classes that
descend from ``NSObject``, unless they implement a custom
``willChangeValueForKey:``, ``didChangeValueForKey:``, or
``__useKVO__`` is not True. This allows ``self.foo = 1`` to
automatically trigger notifications. This works in all cases,
whether ``foo`` is a ``property``, ``ivar``, or just in the
``__dict__``.

- New Inject folder in Examples, with an InjectInterpreter
example that will inject a GUI Python interpreter into any process.

- New ``objc.inject()`` function for macOS 10.3 and later,
allows an arbitrary bundle to be loaded into another process
using mach_inject.

- ``objc.classAddMethods`` now recognizes and supports
classmethods.

- GC is now correctly implemented for struct wrappers.

- The ``NSNumber`` bridge has been removed, now you will get
``NSNumber`` instances across the bridge instead of a
Python representation.

- ``PyObjCTools.AppHelper.runEventLoop()`` will now bring your
application to the front at startup when using pdb
mode for convenience.

- ``objc.loadBundle()`` no longer filters the class list. This
solves a few potential issues and shaves off about 1/3rd of
the overhead of ``python -c "import AppKit"``.

- ``PyObjCTools.AppHelper.runEventLoop()`` no longer breaks on
pure Objective-C exceptions. Most exceptions of this variety
are more like warnings, and there is nothing that can be done
them anyway.

- ``PyObjCTools.AppHelper.runEventLoop()`` now installs the
interrupt handler and verbose exception logging when using pdb,
either explicitly or by the USE_PDB environment variable.

- There is now a fast path for the ``NSString``/``unicode``
bridge when ``Py_UNICODE_SIZE`` is 2. This is the default
setting for Python.

- The default selector signature will have a void return value
unless a "return" statement with an argument is used in the
bytecode. In that case, it will default to an object return
value.

- ``__bundle_hack__`` is no longer necessary, py2app now sets
a different environment variable to the current plugin during
execution, and a hack is installed to ``NSBundle`` so that classes
may respond to requests for their bundle with the ``+bundleForClass``
method. The class builder adds a default implementation of this to
Python classes if this environment variable is set.

- Added ``objc.currentBundle()``, which is equivalent to
``NSBundle.mainBundle()`` except after loading a plug-in.
Makes it easier to load nib files.

- ``PyObjCTools.NibClassBuilder.extractClasses()`` now uses
``objc.currentBundle()`` instead of ``NSBundle.mainBundle()``. This
makes plugins less of a hassle to develop and allows identical code
to be used for application or plugin development.

- ``objc.registerPlugin()`` and ``objc.pluginBundle()`` are now deprecated
as they are no longer useful.

- It is now possible to subclass a class that implements ``copyWithZone:``
without setting ``__slots__`` to ``()``.

- It is now possible to override ``dealloc``. It is still possible to
define ``__del__``.

- As an experimental feature it is also possible to override ``retain`` and
``release``. Note it almost never a good idea to do this (even when you're
programming in Objective-C and much more so in Python).

- ``poseAsClass:`` can be used, although it is not very useful in python, use
categories instead.

A major issue with ``poseAsClass:`` is that existing references to the old
version of the class won't be changed to point to the new class.

- It is now possible to access all instance variables of a class using
the functions ``objc.listInstanceVariables(aClassOrInstance)``,
``objc.getInstanceVariable(obj, name)`` and
``objc.setInstanceVariable(obj, name, value [, updateRefCount])``.

The last argument of ``setInstanceVariable`` is required when the instance
variable is an object. If it is true the bridge will update reference counts,
otherwise it won't.

- All wrappers for opaque pointers (such as ``NSZone*``) now have the same
interface and share a single implementation. This decreases code-size and
makes it easier to add new wrappers. A new feature is a ``__typestr__``
attribute on the type object, this contains the encoded Objective-C type
of the pointer.

A function for creating new wrappers is exposed to python, as
``objc.createOpaquePointerType(name, typestr, doc)``. The same function is
also exposed in the C-API.

- Wrappers for C-structs how have a ``__typestr__`` attribute on their type.
This attribute contains the encoded Objective-C type of the struct.

The default ``__init__`` for struct-wrappers now initializes fields with an
appropriate default value, instead of ``None``.

New wrappers can now be created from Python using the function
``objc.createStructType(name, typestr, fieldnames, doc)``. The same
function is also exposed in the C API (and has been for a while).

1.2

------------------------

- ``PyObjCTools.AppHelper.stopEventLoop`` will attempt to stop the current
``NSRunLoop`` (if started by ``runConsoleEventLoop``) or terminate the
current ``NSApplication`` (which may or may not have been started by
``runEventLoop``).

- This version no longer support Python 2.2. Python 2.3 or later is
required.

- It is now possible to use ``reload`` on modules containing Objective-C
classes.

- ``objc.loadBundle`` now returns bundle we just loaded.

- Added ``objc.loadBundleVariables`` and ``objc.loadBundleFunctions``,
two functions for reading global variables and functions from a bundle.

- objc.runtime will now raise AttributeError instead of objc.nosuchclass_error
when a class is not found.

- objc.Category can be used to define categories on existing classes:

.. sourcecode:: python

class NSObject (objc.Category(NSObject)):
def myMethod(self):
pass

This adds method ``myMethod`` to class NSObject.

- ``py2app`` is now used for all Example scripts and is the recommended method
for creating PyObjC applications.

- Proxies of dict, list, and tuple now respect the invariant that you should
get an identical instance if you ask for the same thing twice and the
collection has not been mutated. This fixes some problems with binary
plist serialization, and potentially some edge cases elsewhere.

- There is now a ``__bundle_hack__`` class attribute that will cause the PyObjC
class builder to use a statically allocated class wrapper if one is
available via certain environment variables. This functionality is used
to enable +[NSBundle bundleForClass:] to work for exactly one class from
a py2app-created plugin bundle.

- We now have a working Interface Builder palette example due to
``__bundle__hack__``.

- ``bool(NSNull.null())`` is now false.

- ``setup.py`` supports several new commands:

build_libffi:

builds libffi (used by build_ext)

build_html:
builds html documentation from ReST source

bdist_dmg:
creates a disk image with the binary installer

bdist_mpkg:
creates a binary installer

test:
runs unit test suite (replaces Scripts/runPyObjCTests
and Scripts/runalltests)

- ``PyObjCStrBridgeWarning`` can now be generated when Python ``str`` objects
cross the bridge by calling ``objc.setStrBridgeEnabled(False)``. It is
HIGHLY recommended that your application never send ``str`` objects over
the bridge, as it is likely to cause problems due to the required
coercion to unicode.

- The coercion bridge from Python to Objective-C instances can now be
augmented from Python as it is exposed by ``OC_PythonObject``. See
``objc._bridges``. This is how the ``str`` -> ``unicode`` -> ``NSString``
bridge with optional warnings is implemented.

- The coercion bridge between Python objects and Objective-C structures
can now be augmented from Python as it is exposed by ``OC_PythonObject``.
See ``objc._bridges``. This is how the ``Carbon.File.FSRef``
<-> ``'{FSRef=[80c]}'`` structure bridge is implemented.

- Extension modules such as ``_objc``, ``_AppKit``, etc. are now inside
packages as ``objc._objc``, ``AppKit._AppKit``, etc. They should never be
used directly, so this should not break user code.

Page 13 of 18

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.