Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

File Save is Corrupting code.py
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

File Save is Corrupting code.py

by Willy134 on Tue Sep 01, 2020 7:10 pm

When I save my code.py file I sometimes get:

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "code.py", line 66
SyntaxError: invalid syntax

When I look at the file I see data is appended to the end. This data is copied from another part of my program.

I am running Windows 10. I have tried this in the mu editor and in Visual Studio Code. Both have the same issue. Once I get the error, it is hard to delete the extra code. I have to do a push button reset and then save without.

I am not sure if this is related, but I also am getting a MemoryError. My code is about 60 lines so far. Mostly just writing clue_data[X].text with some small lookup functions. I don't think I have anything complex enough to use much memory yet.

I am using CircuitPython 5.3 (Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit CLUE nRF52840 Express with nRF52840)
Libraries are installed from the version 5 zip file as described in the tutorial (except one appears to be a folder instead of mpy file).

Willy134
 
Posts: 1
Joined: Tue Sep 01, 2020 6:58 pm

Re: File Save is Corrupting code.py

by kevinjwalters on Thu Sep 03, 2020 11:17 am

I have same issue or a similar one but it's extremely infrequent for me. I did a visualisation of how one example of the file was damaged on Easy way to checksum/hash a file from REPL?.

Mine may be different as I think I can just over-write the file from a second save so it's easy to ignore as a mysterious glitch. Windows thinks it has written the file in my case as shown by the checksums in my post. I tend not to save directly to CIRCUITPY from the editor - I generally save to a network drive and then copy that over to the relevant board(s).

On library front, the file adafruit_lsm6ds.mpy morphed into the directory adafruit_lsm6ds recently.

kevinjwalters
 
Posts: 735
Joined: Sun Oct 01, 2017 3:15 pm

Re: File Save is Corrupting code.py

by adafruit_support_carter on Fri Sep 04, 2020 3:15 pm

[MOD EDIT] Topic moved to Circuitpython

Have you read through the info here?
https://learn.adafruit.com/welcome-to-c ... iting-code

You're using Mu, so shouldn't run into text editor issues. But maybe something else?

adafruit_support_carter
 
Posts: 16866
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.