[Matrix-SIG] Bug in generating .pyc files?

Pearu Peterson pearu@ioc.ee
Mon, 1 Nov 1999 19:32:01 +0200 (EET)


Hi,

I have found the following problem:

I have created a Python program and it works correctly on the first run.
On the second (third,etc) run it works incorrectly.
When I delete the .pyc file or edit the program, the same behaviour
occurs: on the first run everything is OK, but on the following runs it
works incorrectly again.

So, I conclude that the code in .pyc file is incorrect (may be due to my 
incorrect program, but it shouldn't run on the first run, either).
Unfortunately, I cannot give you much of details since my program is
rather large and I don't know where to start looking for my or .pyc file
bugs.

Any ideas?

I will sketch how my program works:
There is two python files: sub.py, main.py.
sub.py contains lots of useful functions that use global variables.
main.py imports sub.py and calls these useful functions.
Before the call, main.py changes the global variables in sub.py
(In main.py 'sub.global_var=value', for example).

My (pythons?) problem occures in the following:
> python main.py
Correct result
> python main.py
Incorrect result (meaning, strange behaviour)
> rm sub.pyc
> python main.py
Correct result
> python main.py
Incorrect result
etc.

Again, any ideas what could be the problem?

Thanks,
	Pearu

Pearu Peterson <pearu@ioc.ee>, MSc, Researcher
Department of Mechanics and Applied Mathematics          http://koer.ioc.ee/~pearu/
Institute of Cybernetics at Tallinn Technical University Phone: (+372) 6204168
Akadeemia Rd. 21, 12618 Tallinn ESTONIA                  Fax:   (+372) 6204161
*** the nonvalidity of rigorous causality is necessary 
    and not just consistently possible (Heisenberg, 1925) ***