displaycal-py3 icon indicating copy to clipboard operation
displaycal-py3 copied to clipboard

"Can't mix strings and bytes in path components" when installing a profile on a Mac

Open VS-X opened this issue 2 years ago • 1 comments

I have built and ran Displaycal on a Mac (M1 Pro, Ventura). When I attempt to install the profile for current user only, I get an error "Can't mix strings and bytes in path components", at worker.py line 13968:

profile_tmp_path = os.path.join(
    tmp_dir, safe_asciize(profile_name)
)

the function safe_asciize returns a byte object, which then cannot be os.path.joined with the tmp_dir which is a normal string. profile_name is U3277WB #2 2022-10-28 13-16 120cdm² D6500 2.2 F-S 1xCurve+MTX.icc the output of safe_asciize(profile_name) is b'U3277WB #2 2022-10-28 13-16 120cdm2 D6500 2.2 F-S 1xCurve+MTX.icc'

I edited safe_asciize function:

elif isinstance(obj, str):
    return obj.encode("ASCII", "safe_asciize")

into

elif isinstance(obj, str):
    return obj

Which made the installation of the profile work, but I assume it is not a proper solution. I barely know python so I don't know how it is supposed to work. Should the tmp_dir be a b'' as well if the safe_asciize returns a byte object instead of a string?

VS-X avatar Oct 28 '22 13:10 VS-X

DisplayCal 3.9.11, macOS sonoma 14.3 - issue still present

arigit avatar Feb 11 '24 17:02 arigit