jmartiuk5 / python-on-a-chip

Automatically exported from code.google.com/p/python-on-a-chip
Other
0 stars 0 forks source link

ipm do_load() broken by fix for issue 175 #200

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
ipm> load testload.py
Traceback (most recent call last):
  File "./ipm.py", line 418, in <module>
    main()
  File "./ipm.py", line 383, in main
    i.run()
  File "./ipm.py", line 337, in run
    self.cmdloop()
  File "/usr/lib/python2.6/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "./ipm.py", line 269, in onecmd
    cmd.Cmd.onecmd(self, line)
  File "/usr/lib/python2.6/cmd.py", line 219, in onecmd
    return func(arg)
  File "./ipm.py", line 240, in do_load
    self.stdout.write(self.conn.read())
TypeError: argument 1 must be string or read-only character buffer, not 
generator

The fix for 175 introduced generators for the serial I/O which cannot be passed 
directly to stdout() as done on line 240 of ipm.py:

self.stdout.write(self.conn.read())

This error occurs on Debian testing (LMDE) using python 2.6.  

The suggested fix is to change line 240 to the following (which is a copy from 
the code in the onecmd() function):

        try:
            for c in self.conn.read():
                self.stdout.write(c)
        except Exception, e:
            self.stdout.write(
                "Connection read error, type Ctrl+%s to quit.\n" % EOF_KEY)

Alternatively it might be better to put this code in an echoinput() function 
and call it from do_load() and onecmd()

Original issue reported on code.google.com by j...@houseoftechnology.org on 6 May 2011 at 3:41

GoogleCodeExporter commented 8 years ago
JT, thank you for the excellent report and suggestion.  I made the suggested 
changes.

Testing: ipm, "load timmy.py" fails before the fix; loads and executes timmy.py 
after the fix.  ipm works the same for other typical cases.  System tests work.

Original comment by dwhall...@gmail.com on 9 May 2011 at 7:13

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 6d0817f3ce5e.

Original comment by dwhall...@gmail.com on 9 May 2011 at 7:15

GoogleCodeExporter commented 8 years ago

Original comment by dwhall...@gmail.com on 9 May 2011 at 7:24