Re: windows preview bug fix
Am Dienstag, dem 12.03.2024 um 13:23 +0200 schrieb Idan Pazi: > I hereby grant a permission for all of my contributions to LyX to be > licensed under the GPL version 2 or later. Thanks, I committed your patch. -- Jürgen -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
I hereby grant a permission for all of my contributions to LyX to be licensed under the GPL version 2 or later. Thank you, Idan Pazi -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
On Tue, 2024-03-12 at 10:37 +0100, Jürgen Spitzmüller wrote: > If nobody beats me to it, I will do it. Thank you Jürgen, I am busy with other issues. Best regards, -- José Abílio -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
Am Sonntag, dem 10.03.2024 um 14:52 -0400 schrieb Richard Kimberly Heck: > On 3/8/24 04:19, Jürgen Spitzmüller wrote: > > Am Samstag, dem 02.03.2024 um 19:49 + schrieb José Matos: > > > After our exchange last week I feel inclined to apply this. > > > > > > I am still note sure that this is the right step but clearly it > > > improves the code regarding the previous one. > > > > > > Does any one opposes to this action? > > My suggestion would be to apply this before the next RC, so we can > > collect feedback from Win users. > > Agreed. If nobody beats me to it, I will do it. But first, Idan, could you please send a blanket permission to this list stating that your contributions to LyX might be licensed under GPL version 2 or later? Thanks, -- Jürgen -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
On 3/8/24 04:19, Jürgen Spitzmüller wrote: Am Samstag, dem 02.03.2024 um 19:49 + schrieb José Matos: After our exchange last week I feel inclined to apply this. I am still note sure that this is the right step but clearly it improves the code regarding the previous one. Does any one opposes to this action? My suggestion would be to apply this before the next RC, so we can collect feedback from Win users. Agreed. Riki -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
Am Samstag, dem 02.03.2024 um 19:49 + schrieb José Matos: > After our exchange last week I feel inclined to apply this. > > I am still note sure that this is the right step but clearly it > improves the code regarding the previous one. > > Does any one opposes to this action? My suggestion would be to apply this before the next RC, so we can collect feedback from Win users. -- Jürgen -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
On Fri, 2024-02-16 at 15:23 +0200, Idan Pazi wrote: > Encountered the following bug (windows 10, python 3.12) - preview of > math fails: > > graphics\PreviewLoader.cpp (2ef): > > PreviewLoader::finishedInProgress(1): processing failed for py -3 - > > tt $$s/scripts/lyxpreview2bitmap.py --png > > "C:/Users/idank/AppData/Local/Temp/lyx_tmpdir.mzhGYGTpQcAc/lyx_tmpb > > uf0/lyxpreviewuaCFJC.tex" --dpi 137 --fg 00 --bg ff -- > > bibtex="bibtex" > > > Running the command manually gives the problem: > > File "C:\Program Files\LyX > > 2.4\Resources\scripts\lyxpreview_tools.py", line 168, in > > run_command_win32 > > data = data + buffer > > ~^~~~ > > TypeError: can only concatenate str (not "bytes") to str > > > Apparently, the returned value from win32file.ReadFile should be > converted to a string. > Fix patch attached. > Thank you, Idan After our exchange last week I feel inclined to apply this. I am still note sure that this is the right step but clearly it improves the code regarding the previous one. Does any one opposes to this action? Best regards, -- José Abílio -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
On Sat, 2024-02-24 at 21:51 +0100, Enrico Forestieri wrote: > Wanting to be very safe, we could use te chardet library for > performing the correct conversion, but if the above is the standard > with python 3 on windows I don't think it is necessary. In [1]: help(str) ... str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str ... encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'. ... In [2]: import sys sys.getdefaultencoding() Out[2]: 'utf-8' So probably this should work more time than what I was expecting. :-) This is unexpected and welcome. :-) -- José Abílio -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
On Sat, Feb 24, 2024 at 01:17:56PM +0200, Idan Pazi wrote: I have sys.flags.utf8_mode = 0. I assume everything is utf8, but I don't think the problem is about finding the right encoding. On the contrary, it is necessary to know the initial encoding of a bytes object for converting it to unicode. However, your patch may actually be correct (despite sys.flags.utf8_mode = 0). I just launched the native python 3 interpreter distributed with lyx and did: import sys print(sys.stdin.encoding) utf-8 So, the input encoding seems to actually be utf-8. In this case your patch is right. Wanting to be very safe, we could use te chardet library for performing the correct conversion, but if the above is the standard with python 3 on windows I don't think it is necessary. -- Enrico -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
I have sys.flags.utf8_mode = 0. I assume everything is utf8, but I don't think the problem is about finding the right encoding. win32file.ReadFile returns bytes, which cannot be added (+) to a string (see data = "" at line 162). Assume that on some cases it returns a string, then this patch won't change a thing. BTW, I think it is possible to use only python Popen on windows without using pywin32 library. would you consider to look at a patch doing that? Thank you, Idan -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
On Sat, 2024-02-17 at 10:41 +0100, Enrico Forestieri wrote: > On Fri, Feb 16, 2024 at 03:28:25PM +, José Matos wrote: > > > > On Fri, 2024-02-16 at 15:23 +0200, Idan Pazi wrote: > > > > > > Apparently, the returned value from win32file.ReadFile should be > > > converted to a string. > > > > > Fix patch attached. > > > Thank you, Idan > > > > What is the encoding of the bytes? Is it UTF8? > > If so the patch look right. > > > > @Enrico, what do you think? > > I don't have a native Windows python 3 installation and the python > distributed with LyX on Windows doesn't include PyWin extension > modules. > Thus I cannot test that code. However, I don't think that > win32file.ReadFile() returns utf8. Most probably it returns some 8- > bit > encoding corresponding to the current code page. But, even using > win32file.ReadFileW() (assuming it exists) that would return utf16. > > -- > Enrico @Idan, I agree with Enrico. So I am also puzzled why this works. What is the output that you get from the following code? import sys print(sys.flags.utf8_mode) The UTF-8 mode that was introduced in Python 3.7 and will be the default in Python 3.15. In https://docs.python.org/3/using/windows.html#win-utf8-mode it reads: """ Note Even when UTF-8 mode is disabled, Python uses UTF-8 by default on Windows for: * Console I/O including standard I/O (see PEP 528 for details). * The filesystem encoding (see PEP 529 for details). """ So I am not sure if the code works because of the last remark... -- José Abílio -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
On Fri, Feb 16, 2024 at 03:28:25PM +, José Matos wrote: On Fri, 2024-02-16 at 15:23 +0200, Idan Pazi wrote: Apparently, the returned value from win32file.ReadFile should be converted to a string. Fix patch attached. Thank you, Idan What is the encoding of the bytes? Is it UTF8? If so the patch look right. @Enrico, what do you think? I don't have a native Windows python 3 installation and the python distributed with LyX on Windows doesn't include PyWin extension modules. Thus I cannot test that code. However, I don't think that win32file.ReadFile() returns utf8. Most probably it returns some 8-bit encoding corresponding to the current code page. But, even using win32file.ReadFileW() (assuming it exists) that would return utf16. -- Enrico -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: windows preview bug fix
On Fri, 2024-02-16 at 15:23 +0200, Idan Pazi wrote: > > Apparently, the returned value from win32file.ReadFile should be > converted to a string. > Fix patch attached. > Thank you, Idan What is the encoding of the bytes? Is it UTF8? If so the patch look right. @Enrico, what do you think? -- José Abílio -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel