PythonWin 2.1 saving bugg???

Tim Gahnström /Bladerman tim at bladerman.com
Wed Oct 31 10:20:35 EST 2001


"Neil Hodgson" <nhodgson at bigpond.net.au> skrev i meddelandet
news:mKRD7.276628$bY5.1090531 at news-server.bigpond.net.au...
> Tim Gahnström:
>
> > What I dont understand is, how can this happen? is this how the
pythonwin
> > savingfunction works?
> >
> > remove_old__file_from_disk
> > Save new_file_that_current_spot
>
>    What it does is, with error checking removed:
>
>    os.unlink(bakFileName)
>    os.rename(fileName, bakFileName)
>    self.SaveFile(fileName)

I couldnt find the function os.rename(new, old)
just a function called renames that actually uses rename. But it doesnt
really matters I guess.
what must have happened is that

my backup was unlinked
my file was unlinked in rename.
something bad happened and the program went crazy.

If the saving strategy would have looked like the one Fredrik Lundh outlined
I would either have had my file or my backupfile still allive. Probably I
would just have lost the tempfile and hav had both backfile and file left.
Right?

>    The actual code is in Pythonwin\pywin\scintilla\document.py.
 Found it in: \Pythonwin\pywin\framework\editor and pooked around a litle,
hope I didnt break anything :p

> > BTW is this what openSource is about? If I look over the saving
> > routines in PythonWin and find that they can be done better and
> > fix it, is there a good chanse that, that will be incorporated into
> > the next release?
>
>    If it is unambiguously better then I'm sure Mark will accept a patch.
> However, he often has a good idea what he is doing so you may need to
> discuss it with him in detail.

I sure assume he is full competent and way more suited then I am for the
task but he might have overlooked something, or not had a reason to bother
about it.
I sure think Fredrik Lunds strategy seemed fairly safe, but I havn't had a
thorough look at it yet. If I finish this Lab that gott lost, "in time", I
might look at it, atleast for the fun of it.

>    I noticed that you wrote:
>
> > But after (abruptly and with scandisk...)  having restarted
> > the computer I came back and found that my program
> > wasn't ther at all! anymore.
>
>   Does this mean you pressed the reset button (or similar) in an attempt
to
> keep the old file? If so this is a really bad idea as you have a good
chance
> of not having any of the copies survive as the on-disk data associated
both
> with the old and new copies may be incomplete.

I don't deny I am stupid once in a while, but every man have a limit to his
stupidity :-)
No! I didnt do like that, thank god.

...but that is almost what happened anyway :-(
as I mentioned I didnt take much notice about it since I had just done minor
changes. And at the time I was doing this I was also baby-sitting. So I let
the little fellow play a game for a while (... call me stupid) The game went
crazy and restarted the computer. Or it might have been someone kicking the
resetbutton or something I dont know for sure but. It didnt matter at the
time... I thought.


Still that "unlinking" seems like it should be fairly easy to "relink" if I
found where the file is lokated on the drive right?
Back in Dos days there was a program called undelete I think.
Maybe such things is around for w2k to... Guess I'll have do do some
websurfing... Or maybe start rewriting the thing instead of finding "easy"
solutions that take twice the time :p

Tim





More information about the Python-list mailing list