issue of load a .py script with Python Scripter Version 3.0.1.0 x64

20 views
Skip to first unread message

Karlsson

unread,
Dec 22, 2017, 4:31:04 AM12/22/17
to PyScripter
Hello,

allways i load a python Script into Python Scripter 3.0.1.0 x64, i lost the last 5 Bytes of the file.


Installation:
Windows 10 (1709)
Intel Core i7-3770K 3.50GHz

For Python 3
Active Python 3.6.0 x64
Python Scripter 3.0.1.0 x64 (looks like a Portable Version)

For Python 2
Active Python 2.7.2 (32bit)
Python Scripter 2.6.0.0 x86 (Windows installation)



Karlsson

PyScripter

unread,
Dec 22, 2017, 5:06:32 AM12/22/17
to PyScripter
PyScripter has an editor option TrimTralingSpaces.   Could it be that PyScripter stripped some trailing spaces?

Karlsson

unread,
Dec 22, 2017, 6:01:58 AM12/22/17
to PyScripter


Am Freitag, 22. Dezember 2017 11:06:32 UTC+1 schrieb PyScripter:
PyScripter has an editor option TrimTralingSpaces.   Could it be that PyScripter stripped some trailing spaces?

TrimTralingSpaces is for writing a file.
The writing works correctly.

It always omits the last 5 bytes when loading, even code.
That's why I noticed.

written and checked with notepad ++

....
if __name__ == '__main__':
     main
(sys.argv [1:])
# 01234567890




Resulat when the file is loaded.

....
if __name__ == '__main__':
     main
(sys.argv [1:])
# 012345



 

PyScripter

unread,
Dec 22, 2017, 10:49:51 AM12/22/17
to PyScripter
I cannot reproduce it here with you little example.  Could you please open an issue at GitHub and provide a test case (i.e. attach a file for which you experience this issue.

Karlsson

unread,
Dec 22, 2017, 7:08:33 PM12/22/17
to PyScripter
OK, Now i Installed the last Version "PyScripter-v3.0.2-x64-Setup.exe beta". The About... say´s "Version 3.0.1.0 x64" ???

My original script has 5147 Lines with 266.197 Bytes.
The problem was the same.

Now I have deleted a few lines and at 3500 lines with 181,879 bytes, I have found the following:

....
if __name__ == '__main__':
    main
(sys.argv[1:])
#012345678


So only two bytes are missing.

At 3200 lines and 162.484 bytes, no bytes are missing at the end

I enlarged the file again and at 3216 lines and 163.665 Bytes only 1 Byte is missing.


The problem is the 4Byte utf8 "lock-character"  in the comment and in the code.

>>> print("🔒".encode("utf8"))
b
'\xf0\x9f\x94\x92'


In my original script this 4byte utf8 character appears 5 times and 5 bytes are missing at the end.

LG
Karlsson

PyScripter

unread,
Dec 22, 2017, 10:34:39 PM12/22/17
to PyScripter
Ok thanks.  At least we now pinned it down a bit.  What encoding are saving the file with?  (Edit, File Format).

I tried to reproduce the problem with a small file containing only the lines

print("🔒".encode("utf8"))
# 01234567890

and I still cannot with the File Formats UTF8, UTF8 No BOM, UTF-16LE, UTF-16BE.   The file is saved and read without loss of data.

PyScripter

unread,
Dec 22, 2017, 11:50:58 PM12/22/17
to PyScripter
Interestingly if you try to paste the lock character to IDLE it crashes.  Scintilla based editors also do not appear to support Unicode characters outside the BMP, i.e. represented by more than 2 bytes in UTF-16.


On Saturday, December 23, 2017 at 2:08:33 AM UTC+2, Karlsson wrote:

Karlsson

unread,
Dec 23, 2017, 5:27:51 PM12/23/17
to PyScripter
 
I analye my script and the problem is an function there translate an text special utf8 into an image.

Multiple lines in combination with the "lock-character".

In at least one line of each block is associated with the lock sign.

I have no idea how it all hangs together.

LINK:

LG
Karlsoon

PyScripter

unread,
Dec 23, 2017, 7:49:47 PM12/23/17
to PyScripter
That's very helpful.  Thanks.  The issue is fixed in version control and will available with the new release coming out soon.  

An interesting finding was that 

len(u"🔒")

returns 2 in Python 2.7 and 1 in Python 3.7. 
Reply all
Reply to author
Forward
0 new messages