Skip to content

osxphotos import fails when pic has numerical exif keyword/subject in xmp sidecar, e.g. 144 #1964

@oPromessa

Description

@oPromessa

Before submitting a bug report, please ensure you are running the most recent version of osxphotos and that the bug is reproducible on the latest version

osxphotos, version 0.73.3
Python 3.12.12 (main, Oct 12 2025, 15:04:06) [Clang 14.0.0 (clang-1400.0.29.202)]
Python executable: osxphotos/venv/bin/python3.12
macOS 12.7.6, x86_64

Describe the bug
An image file with keyword 144 which is interpreted as an int. Using osxphotos import image --export .osxphotos_export.db
The file (originally had 144 subject/keyword) and on export with merge_keywords option with export_as_hardlink=true osxphotos correctly added 144 to the tmp file.

To Reproduce

osxphotos import img027.jpg --exportdb photos/.osxphotos_export.db  --walk --stop-on-error 10 --sidecar --verbose --timestamp  --dup-check --skip-dups --resume

Expected behavior
Loading the pic and assign keyword correctly.
Will try to prepare a PR.

Screenshots
N/A

Desktop (please complete the following information):

osxphotos, version 0.73.3
Python 3.12.12 (main, Oct 12 2025, 15:04:06) [Clang 14.0.0 (clang-1400.0.29.202)]
Python executable: oxphotos/venv/bin/python3.12
macOS 12.7.6, x86_64

Additional context
Log output:

/Users/MSP/Documents/GitHub/osxphotos/osxphotos/cli/import_cli.py:1616 in set_photo_metadata     │
│                                                                                                  │
│   1613photo.title = normalize_unicode(metadata.title)                                       │
│   1614photo.description = normalize_unicode(metadata.description)                           │
│   1615keywords = metadata.keywords.copy()                                                   │
│ ❱ 1616keywords = normalize_unicode(keywords)                                                │
│   1617if merge_keywords:                                                                    │
│   1618 │   │   if old_keywords := normalize_unicode(photo.keywords):                             │
│   1619 │   │   │   keywords.extend(old_keywords)                                                 │
│                                                                                                  │
│ /Users/MSP/Documents/GitHub/osxphotos/osxphotos/unicode.py:86 in normalize_unicode               │
│                                                                                                  │
│   83if isinstance(value, tuple):                                                            │
│   84 │   │   return tuple(unicodedata.normalize(form, v) for v in value)                         │
│   85elif isinstance(value, list):                                                           │
│ ❱ 86 │   │   return [unicodedata.normalize(form, v) for v in value]                              │
│   87elif isinstance(value, str):                                                            │
│   88 │   │   return unicodedata.normalize(form, value)                                           │
│   89else:                                                                                   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: normalize() argument 2 must be str, not int

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions