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

Pearu Peterson pearu@ioc.ee
Mon, 1 Nov 1999 20:12:12 +0200 (EET)


I was able to track down where is the bug and I will demonstrate it below.
Let main.py be:

#!/usr/bin/env python
import sub
sub.sub()
# EOF main.py

and let sub.py be:

def sub():
    for l in ['1 2','3 4']:
        if l[1] is ' ':
            flag=1
        else:
            flag=0
        print flag,`l`
#EOF sub.py

Here are the results of repeated calls of main.py:
> python main.py
1 '1 2'
1 '3 4'
> python main.py
0 '1 2'
0 '3 4'
> python main.py
0 '1 2'
0 '3 4'
etc

Note that program works correctly if line 
	if l[1] is ' ':
is replaced with
	if l[1]==' ':
of course.

I am using
Python 1.5.2 (#4, Oct 26 1999, 18:40:59)  [GCC egcs-2.91.66 19990314/Linux
(egcs- on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam

So, it seems that 'is' is interpreted differently when .pyc file is used.
I think this is a serious problem and should be fixed.

With regards,
	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) ***