On Thu, Dec 19, 2024 at 10:31:20PM +0000, José Matos wrote: > On Thu, 2024-12-19 at 15:57 +0100, Scott Kostyshak wrote: > > Is the problem that the object should not be a string? > > Yes, it was expecting bytes.
Why not assert that at the beginning of the Python function?
Or, what's the best way to do type-checking of arguments in Python?
> > $ python3 --version
> > Python 3.12.3
>
> Do you know the Whac-A-Mole game? :-)
Yes, I do. It's fun as a kid, not when coding :).
> It was the same game that I was playing here.
>
> I modernized the code a bit, changing from bytes to str as soon as
> possible since that is now possible. I use kate that uses already some
> plugins to reformat the code on save and so the patch it is a lot
> larger...
>
> Tell me if this works.
Works well on Welcome.lyx. On my original use case, I get the following now:
$ lyx -e lyxgz paper.lyx
starting local cmake binary for lyx
Traceback (most recent call last):
File "/home/scott/lyxbuilds/master-master/repo/lib/scripts/lyxpak.py", line
405, in <module>
main(sys.argv)
File "/home/scott/lyxbuilds/master-master/repo/lib/scripts/lyxpak.py", line
334, in main
gather_files(lyxfile, incfiles, lyx2lyx)
File "/home/scott/lyxbuilds/master-master/repo/lib/scripts/lyxpak.py", line
172, in gather_files
gather_files(file, incfiles, lyx2lyx)
File "/home/scott/lyxbuilds/master-master/repo/lib/scripts/lyxpak.py", line
130, in gather_files
lines = f.readlines()
^^^^^^^^^^^^^
File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid
start byte
support/Systemcall.cpp (306): Systemcall: 'python3
"/home/scott/lyxbuilds/master-master/repo/lib/scripts/lyxpak.py"
"/home/scott/strikes/"/"paper.lyx"' finished with exit code 1
Error: Cannot convert file
----------------------------------------
An error occurred while running:
python3 $$s/scripts/lyxpak.py "/home/scott/strikes/"/"paper.lyx"
Scott
signature.asc
Description: PGP signature
-- lyx-devel mailing list [email protected] https://lists.lyx.org/mailman/listinfo/lyx-devel
