Skip to content

Commit

Permalink
building: osx: explicitly convert BUNDLE version to string
Browse files Browse the repository at this point in the history
Explicitly convert the value of `version` argument to `BUNDLE` into
a string, in order to mitigate cases when user accidentally enters
an integer or a float. The version value ends up being written to
`Info.plist` as the `CFBundleShortVersionString` entry, and if this
entry is not of a string type (for example, is an integer), the
generated .app bundle crashes at start.
  • Loading branch information
rokm committed Mar 26, 2024
1 parent 8bee174 commit 5992871
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion PyInstaller/building/osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def __init__(self, *args, **kwargs):
self.name = os.path.join(CONF['distpath'], base_name)

self.appname = os.path.splitext(base_name)[0]
self.version = kwargs.get("version", "0.0.0")
# Ensure version is a string, even if user accidentally passed an int or a float.
# Having a `CFBundleShortVersionString` entry of non-string type in `Info.plist` causes the .app bundle to
# crash at start (#4466).
self.version = str(kwargs.get("version", "0.0.0"))
self.toc = []
self.strip = False
self.upx = False
Expand Down
6 changes: 6 additions & 0 deletions news/4466.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(macOS) Explicitly convert the value of ``version`` argument to ``BUNDLE``
into a string, in order to mitigate cases when user accidentally enters
an integer or a float. The version value ends up being written to
``Info.plist`` as the ``CFBundleShortVersionString`` entry, and if this
entry is not of a string type (for example, is an integer), the
generated .app bundle crashes at start.

0 comments on commit 5992871

Please sign in to comment.