Roundup Tracker - Issues

Issue 2550713

classification
StringIO error with Python2.7
Type: crash Severity: major
Components: Web interface, Infrastructure Versions: 1.4
process
Status: closed fixed
:
: schlatterbeck : ber, ced, schlatterbeck
Priority: :

Created on 2011-07-14 10:49 by ced, last changed 2011-07-15 12:58 by schlatterbeck.

Messages
msg4330 Author: [hidden] (ced) Date: 2011-07-14 10:49
The EditCSVAction.handle fails to convert rows value into io_.StringIO because io.StringIO require 
a unicode instead of a str.
Here is the traceback:
 
TypeError: initial_value must be unicode or None, not str	Python 2.7.1
/usr/bin/python2.7
A problem occurred while running a Python script. Here is the sequence of function calls leading 
up to the error, with the most recent (innermost) call first. The exception attributes are:

/usr/lib/python2.7/site-packages/roundup/cgi/actions.py in handle(self=
<roundup.cgi.actions.EditCSVAction instance>)
  298 
  299         # do the edit
  300         rows = io_.StringIO(self.form['rows'].value)
      rows = undefined, global io_ = <module 'roundup.anypy.io_' from '/usr/lib/python2.7/site-
packages/roundup/anypy/io_.pyc'>, global StringIO = undefined, self = 
<roundup.cgi.actions.EditCSVAction instance>, global form = undefined, value = undefined
  301         reader = csv.reader(rows)
  302         found = {}

/usr/lib/python2.7/site-packages/roundup/cgi/actions.py in execute(self=
<roundup.cgi.actions.EditCSVAction instance>)
   37         """Execute the action specified by this object."""
   38         self.permission()
   39         return self.handle()
      self = <roundup.cgi.actions.EditCSVAction instance>, global handle = undefined
   40 
   41     name = ''

/usr/lib/python2.7/site-packages/roundup/cgi/client.py in handle_action(self=
<roundup.cgi.client.Client instance>)
 1140                 return getattr(self, action_klass)()
 1141             else:
 1142                 return action_klass(self).execute()
      action_klass = <class roundup.cgi.actions.EditCSVAction>, self = <roundup.cgi.client.Client 
instance>, global execute = undefined
 1143 
 1144         except (ValueError, Reject), err:

/usr/lib/python2.7/site-packages/roundup/cgi/client.py in inner_main(self=
<roundup.cgi.client.Client instance>)
  450                 # possibly handle a form submit action (may change self.classname
  451                 # and self.template, and may also append error/ok_messages)
  452                 html = self.handle_action()
      html = undefined, self = <roundup.cgi.client.Client instance>, global handle_action = 
undefined
  453 
  454                 if html:
msg4331 Author: [hidden] (ber) Date: 2011-07-14 11:24
Thanks for the report, which version of roundup did you try in 
particular?
msg4332 Author: [hidden] (ced) Date: 2011-07-14 11:28
On 14/07/11 11:24 +0000, Bernhard Reiter wrote:
> 
> Bernhard Reiter <bernhard@intevation.de> added the comment:
> 
> Thanks for the report, which version of roundup did you try in 
> particular?

Version 1.4.16

By the way, I temporary fixed by only use StringIO.StringIO in
roundup/anypy/io_.py
msg4333 Author: [hidden] (ber) Date: 2011-07-14 14:04
Can you add your change? Maybe it leads the way how to fix this.
msg4334 Author: [hidden] (ced) Date: 2011-07-14 14:23
On 14/07/11 14:04 +0000, Bernhard Reiter wrote:
> 
> Bernhard Reiter <bernhard@intevation.de> added the comment:
> 
> Can you add your change? Maybe it leads the way how to fix this.

It is really not the correct way, because I just force to use StringIO from
StringIO module instead of io.

Here is:

try:
    from io import StringIO
except:
    from StringIO import StringIO
from StringIO import StringIO
msg4335 Author: [hidden] (ber) Date: 2011-07-14 19:33
Hmm, how did you create the traceback?
With which version of python on which platform?
I'm trying with roundup 1.4.18+ (from SVN))
and python 2.7.2 on MeeGo (Intel) and running the demo.py
I could not trigger the issue yet.

CVS export worked for me, maybe it needs to be a special entry or action?
msg4336 Author: [hidden] (ced) Date: 2011-07-14 19:43
On 14/07/11 19:33 +0000, Bernhard Reiter wrote:
> 
> Bernhard Reiter <bernhard@intevation.de> added the comment:
> 
> Hmm, how did you create the traceback?

I was just editing group (to add a new group)

> With which version of python on which platform?

Python 2.7.1 on Linux 32bit

> I'm trying with roundup 1.4.18+ (from SVN))
> and python 2.7.2 on MeeGo (Intel) and running the demo.py
> I could not trigger the issue yet.
> 
> CVS export worked for me, maybe it needs to be a special entry or action?

Nothing special.
Do you get a unicode string from the form?
msg4337 Author: [hidden] (ber) Date: 2011-07-15 07:01
Can you give me more specific instructions what I need to do
to recreate the issue?

With group, do you mean you have changed one of the keywords via the
webinterface?

What do you mean presicely by getting a unicode string back from the 
form?

If you tried python 2.7.1, do you have a chance to try 2.7.2
as they seems to have fixed a number of issues between 2.7.1 and 2.7.2, 
some even in the io module. But it is hard to say if this affects the 
issue.
msg4338 Author: [hidden] (ced) Date: 2011-07-15 08:27
On 15/07/11 07:01 +0000, Bernhard Reiter wrote:
> 
> Bernhard Reiter <bernhard@intevation.de> added the comment:
> 
> Can you give me more specific instructions what I need to do
> to recreate the issue?
> 
> With group, do you mean you have changed one of the keywords via the
> webinterface?

Yes, by going as admin to http://<hostname>/roundup/group
I just add a new line but even without adding line I got the issue.

> What do you mean presicely by getting a unicode string back from the 
> form?

It seems that "self.form['rows'].value" is a str and not a unicode.

> If you tried python 2.7.1, do you have a chance to try 2.7.2
> as they seems to have fixed a number of issues between 2.7.1 and 2.7.2, 
> some even in the io module. But it is hard to say if this affects the 
> issue.

It is difficult because on local machine, I don't have yet Python 2.7 and I
can right now upgrade the production server.
But I don't think it is a issue in Python because the doc of io.StringIO says
that it requires a unicode.
msg4339 Author: [hidden] (ber) Date: 2011-07-15 08:43
Hmm is "group" an object that your customization of roundup
has created? At least my http://localhost:8917/demo/group
does not have "group" as an object. Are you using some roundup
extensions?

Can you somehow trigger the issues with a clean standard install?
Just unpack roundup and run python demo.py.
msg4340 Author: [hidden] (ber) Date: 2011-07-15 12:56
I think Ralf just fixed this issue with rev4633.
msg4341 Author: [hidden] (schlatterbeck) Date: 2011-07-15 12:58
fixed in r4633 and added regression test.
Sorry I just now see the discussion here.
History
Date User Action Args
2011-07-15 12:58:50schlatterbecksetassignee: schlatterbeck
messages: + msg4341
2011-07-15 12:56:47bersetstatus: new -> closed
nosy: + schlatterbeck
resolution: fixed
messages: + msg4340
2011-07-15 08:43:16bersetmessages: + msg4339
2011-07-15 08:27:33cedsetmessages: + msg4338
2011-07-15 07:01:00bersetmessages: + msg4337
2011-07-14 19:43:57cedsetmessages: + msg4336
2011-07-14 19:33:14bersetmessages: + msg4335
2011-07-14 14:23:37cedsetmessages: + msg4334
2011-07-14 14:04:28bersetmessages: + msg4333
2011-07-14 11:28:37cedsetmessages: + msg4332
2011-07-14 11:24:23bersetnosy: + ber
messages: + msg4331
2011-07-14 10:49:55cedcreate