[Edu-sig] Version 0.2.03 of PataPata released (adds Jython/Swing support)

Paul D. Fernhout pdfernhout at kurtz-fernhout.com
Tue Aug 8 03:33:34 CEST 2006


Andreas-

Thanks for trying PataPata and sending the informative bug report.

Reading through the stack trace, there is an error when loading 
WorldCommonTK.py (a file defining supporting prototypes for the TK based 
GUI). But (see below) the error doesn't seem to happen when importing the 
file, just when doing introspection for the source of a function.
As a first guess I suspect the Windows Python version of inspect.py you 
are using is somehow having trouble parsing the WorldCommonTK.py file on 
your XP system for some reason, but Python itself can parse it. So again 
as a first guess it seems like some sort of tab-to-space problem, or line 
ending translation, or character encoding issue, or something like that, 
where inspect.py might use a different approach than Python compiler 
itself. Or maybe a garbled file?

My focus on 2.03 was for Jython support, so I'd be curious if you would 
have the same problem trying to run the previous version (2.02). If both 
have the same problem (no source loaded) then that may mean it is an issue 
with something about the configuration of Python under XP you are using 
which I would have to adjust for (I test under 2.3 for Debian). I just 
tested under 2.4 under Debian and it starts also so it might be a Windows 
issue?

Sorry I don't have a clearer answer for you; we don't have XP here, just 
2000 under VMWare, and I just now tested under that with Python2.3 and it 
works OK. I know from Francois Schnell's testing in June that previous 
versions a while back did run under Windows XP, so it would be something I 
more recently introduced (perhaps with the metaclass function handling?)

== more details on my reasoning and other ideas to try

That error by itself is directly from a line of code I see I 
unintentionally left in when I was testing today. Sorry. Remove the line 
that says "raise" in Prototypes.py on line 49 which reraises a caught 
exception. I normally catch that exception, but temporarily reraised it to 
resolve something related to Jython packaging at the last minute and 
forgot to take it out, sorry. Normally, that exception should not be 
generated in the first place though unless something else is wrong, so if 
the system otherwise works, that line should be mostly harmless. Removing 
that "raise" line might let it start if there are no other issues, however 
there would at best remain a deeper problem (probably making a new error).

If it is failing there, that also means there is likely another problem 
where it is not finding or parsing the source code for a method it is 
loading from the file. Assuming the source code for the file being loaded 
was correctly parsable (and I suspect it is not for some reason), you 
might get a GUI, but you could not look at the source for some or all 
methods. (Think of it as almost like some variation of "sources file not 
found" in Squeak. :-) But, normally that code should never have an 
exception in the first place -- it is mainly a holdover from supporting 
the wx version where you can type in code from the command line and the 
source is not stored in a file and so inspect does not work for such 
functions. So while the "raise" should ideally be removed, I don't think 
that will fix the entire problem.

The stack trace part:

      File "C:\PataPata_v203\PataPata_v203\WorldCommonTK.py", line 794, in
define_prototype
      class SimpleSequenceLayoutManager:

is probably most significant here, as "SimpleSequenceLayoutManager" is 
likely the prototype being defined at the time in "WorldCommonTK.py". The 
rest of the stack below that is calling the metaclass function 
(world.buildPrototype) to define a prototype instead of a class and that 
in turn is calling library functions to look up the source of a function. 
(And frankly, I feel that source introspection code is a little shaky in 
Python, unlike Smalltalk. :-) That prototype only has one function 
("layoutMorphs"). However, if the code is not indented properly, likely 
loading that file would fail in some other way as an import even if that 
exception you saw was not raised.

I just replicated a similar error (but not identical) by going into that 
function and adding one extra space before "layout = {}". I got:
Traceback (most recent call last):

   File "PataPata.py", line 18, in ?
     PataPataViewerTK.main()
   File "/home/pdf/workspace/PataPata/PataPataViewerTK.py", line 24, in main
     world = PrototypeClass(None).newPrototypeFromFile("WorldExampleTK.py")
   File "/home/pdf/workspace/PataPata/Prototypes.py", line 513, in 
newPrototypeFromFile
     newPrototype = worldModule.define_prototype(self.world)
   File "/home/pdf/workspace/PataPata/WorldExampleTK.py", line 9, in 
define_prototype
     world.worldLibraries = [world.newWorldFromFile("WorldCommonTK.py")]
   File "/home/pdf/workspace/PataPata/Prototypes.py", line 521, in 
newWorldFromFile
     result = newWorld.newPrototypeFromFile(fileName)
   File "/home/pdf/workspace/PataPata/Prototypes.py", line 508, in 
newPrototypeFromFile
     worldModule = imp.load_module(moduleName, file, pathname, description)
   File "/home/pdf/workspace/PataPata/WorldCommonTK.py", line 803
     layout = {}
               ^
IndentationError: unindent does not match any outer indentation level

But it is not identical (instead failing earlier on "imp.load_module", not 
later after import when actually running "worldModule.define_prototype" as 
in the stack trace you supplied), which makes me think the source file on 
your machine might parse correctly, but the problem is possibly more 
likely that inspect.py can't then parse it back from the file for some 
reason. Still, that is just an educated guess.

Another much less likely possibility is that you accidentally edited and 
saved WorldCommonTk.py or that it got garbled in transmission? Unlikely I 
know, and I would think that would result in a shorter stack trace like 
the one I included above. You could try just doing a:

   $python WorldCommonTK.py

from the command line. It should actually do nothing (except parse itself 
and return a shell prompt), which would be a good sign that the file was 
valid.

You could also try runnign tabnanny.py. Here is how I ran it just now 
under GNU/Linux:

   $ python /usr/lib/python2.3/tabnanny.py -v WorldCommonTK.py
'WorldCommonTK.py': Clean bill of health.

Tabnanny should come with your python distribution. So, maybe it will turn 
up something?

Between seeing whether the problem under XP is also in 0.2.02 and whether 
your machine's copy of WorldCommonTK.py is correctly indented and parsable 
(I use Eclipse with PyDev and that flags such errors right in the editor), 
that should bring us closer to resolving this issue.

You could also try the new Jython version if you have a JVM 1.4.2 or later 
installed. :-) Working under Jython would at least indicate the source 
files on your machine were somewhat reasonable and not garbled, and that 
the problem was more likely in the Python2.4/XP side.

Thanks again for trying it and the bug report. If you keep getting snarled 
perhaps we can chat over Skype, irc, or something.

--Paul Fernhout

Andreas Raab wrote:
> Hi Paul -
> 
> When I try to run 0.2.3 (Python 2.4 on Windows XP) all I get is an 
> indentation error (stack dump below). Any ideas?
> 
> Cheers,
>    - Andreas
> 
> ---------------------------------------------------------------------
> 
> PataPata Version 0.2.03
> Using 'Alt' as the meta key to drag Morphs and get menus
> You can change this key in the file "options.py"
> If you use ALT under GNU/Linux and it drags windows instead of morphs,
> then you need to change a setting in your desktop settings.
> Loading world file: WorldExampleTK.py from C:\PataPata_v203\PataPata_v203
> Loading world file: WorldCommonTK.py from C:\PataPata_v203\PataPata_v203
> Traceback (most recent call last):
>    File "PataPata.py", line 18, in ?
>      PataPataViewerTK.main()
>    File "C:\PataPata_v203\PataPata_v203\PataPataViewerTK.py", line 24, 
> in main
>      world = PrototypeClass(None).newPrototypeFromFile("WorldExampleTK.py")
>    File "C:\PataPata_v203\PataPata_v203\Prototypes.py", line 514, in 
> newPrototypeFromFile
>      newPrototype = worldModule.define_prototype(self.world)
>    File "C:\PataPata_v203\PataPata_v203\WorldExampleTK.py", line 9, in 
> define_prototype
>      world.worldLibraries = [world.newWorldFromFile("WorldCommonTK.py")]
>    File "C:\PataPata_v203\PataPata_v203\Prototypes.py", line 522, in 
> newWorldFromFile
>      result = newWorld.newPrototypeFromFile(fileName)
>    File "C:\PataPata_v203\PataPata_v203\Prototypes.py", line 514, in 
> newPrototypeFromFile
>      newPrototype = worldModule.define_prototype(self.world)
>    File "C:\PataPata_v203\PataPata_v203\WorldCommonTK.py", line 794, in 
> define_prototype
>      class SimpleSequenceLayoutManager:
>    File "C:\PataPata_v203\PataPata_v203\Prototypes.py", line 641, in 
> buildPrototype
>      prototype.setAttributeWithoutSideEffects(propertyName, value)
>    File "C:\PataPata_v203\PataPata_v203\Prototypes.py", line 576, in 
> setAttributeWithoutSideEffects
>      value = PrototypeMethod(self, value)
>    File "C:\PataPata_v203\PataPata_v203\Prototypes.py", line 47, in __init__
>      source = inspect.getsource(function)
>    File "C:\Python24\Lib\inspect.py", line 563, in getsource
>      lines, lnum = getsourcelines(object)
>    File "C:\Python24\Lib\inspect.py", line 555, in getsourcelines
>      else: return getblock(lines[lnum:]), lnum + 1
>    File "C:\Python24\Lib\inspect.py", line 538, in getblock
>      tokenize.tokenize(ListReader(lines).readline, BlockFinder().tokeneater)
>    File "C:\Python24\Lib\tokenize.py", line 153, in tokenize
>      tokenize_loop(readline, tokeneater)
>    File "C:\Python24\Lib\tokenize.py", line 159, in tokenize_loop
>      for token_info in generate_tokens(readline):
>    File "C:\Python24\Lib\tokenize.py", line 229, in generate_tokens
>      raise IndentationError(
> IndentationError: unindent does not match any outer indentation level


More information about the Edu-sig mailing list