[Pyrex] Succinct case (was: Dangerous weirdness happening)

David McNab david at rebirthing.co.nz
Tue Sep 30 05:34:37 CEST 2003


Hi,

I've distilled a tiny test case that reproduces the madness I described
before.

1) Write this into fred.pyx:

  try:
      x = True
  except:
      print "dammit"
      True = 1
  print "About to execute 'print []'"
  print []

2) Write this into setup.py:

  from distutils.core import setup
  from distutils.extension import Extension
  from Pyrex.Distutils import build_ext
 
  setup(
    name = "fred",
    version = '0.1',
    ext_modules=[Extension("fred", ["fred.pyx"])],
    cmdclass = {'build_ext': build_ext}
  )

3) Type 'python2.2 setup.py build'

4) cd into build/lib.linux-i686-2.2

5) Type 'python2.3'

6) Type 'import fred'

Notice that the 'x = True' in the mainline triggers an
exception, and that the 'True = 1' statement is what causes the
nastiness. If you comment out the 'True = 1', then 'print []' works
fine.

My whole reason for this above code, is that in my app I'm using one of
my extension modules that was written for Python 2.1 or later (at which
time there was no True/False).

Could it be that Pyrex might be generating mischievous code?

Cheers
David





More information about the Pyrex mailing list