Problems with statements using Decimal class

Bug #713372 reported by Carlos Flores on 2011-02-04
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oursql
Undecided
Unassigned

Bug Description

I am using Ubuntu Linux 10.10 and using the binary packages of MySQL included in the distro.
Also using python 2.6.6 with oursql 0.9.2.

And this is the stuff that resulted as a traceback, please notice since this is a web project it was extracted from Apache error logs:

Traceback (most recent call last):
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/cherrypy/_cphttptools.py", line 121, in _run
[Fri Feb 04 15:30:34 2011] [error] self.main()
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/cherrypy/_cphttptools.py", line 273, in main
[Fri Feb 04 15:30:34 2011] [error] body = page_handler(*virtual_path, **self.params)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/turbogears/identity/conditions.py", line 282, in _wrapper
[Fri Feb 04 15:30:34 2011] [error] return fn(*args, **kw)
[Fri Feb 04 15:30:34 2011] [error] File "<string>", line 3, in agregar
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/turbogears/controllers.py", line 360, in expose
[Fri Feb 04 15:30:34 2011] [error] *args, **kw)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/turbogears/database.py", line 393, in run_with_transaction
[Fri Feb 04 15:30:34 2011] [error] @abstract()
[Fri Feb 04 15:30:34 2011] [error] File "<generated code>", line 0, in run_with_transaction
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/peak/rules/core.py", line 153, in __call__
[Fri Feb 04 15:30:34 2011] [error] return self.body(*args, **kw)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/turbogears/database.py", line 458, in sa_rwt
[Fri Feb 04 15:30:34 2011] [error] retval = func(*args, **kw)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/turbogears/controllers.py", line 243, in _expose
[Fri Feb 04 15:30:34 2011] [error] @abstract()
[Fri Feb 04 15:30:34 2011] [error] File "<generated code>", line 0, in _expose
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/peak/rules/core.py", line 153, in __call__
[Fri Feb 04 15:30:34 2011] [error] return self.body(*args, **kw)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/turbogears/controllers.py", line 389, in <lambda>
[Fri Feb 04 15:30:34 2011] [error] fragment, options, args, kw)))
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/turbogears/controllers.py", line 424, in _execute_func
[Fri Feb 04 15:30:34 2011] [error] output = errorhandling.try_call(func, *args, **kw)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/turbogears/errorhandling.py", line 73, in try_call
[Fri Feb 04 15:30:34 2011] [error] return func(self, *args, **kw)
[Fri Feb 04 15:30:34 2011] [error] File "<string>", line 3, in agregar
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/turbogears/controllers.py", line 206, in validate
[Fri Feb 04 15:30:34 2011] [error] return errorhandling.run_with_errors(errors, func, *args, **kw)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/lib/pymodules/python2.6/turbogears/errorhandling.py", line 114, in run_with_errors
[Fri Feb 04 15:30:34 2011] [error] return func(self, *args, **kw)
[Fri Feb 04 15:30:34 2011] [error] File "/home/asura/servidor/Sistemas/Egresos/egresos/controllers/devolucion.py", line 66, in agregar
[Fri Feb 04 15:30:34 2011] [error] devolucion.flush()
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/Elixir-0.7.1-py2.6.egg/elixir/entity.py", line 1092, in flush
[Fri Feb 04 15:30:34 2011] [error] return object_session(self).flush([self], *args, **kwargs)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/orm/session.py", line 1388, in flush
[Fri Feb 04 15:30:34 2011] [error] self._flush(objects)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/orm/session.py", line 1469, in _flush
[Fri Feb 04 15:30:34 2011] [error] flush_context.execute()
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/orm/unitofwork.py", line 302, in execute
[Fri Feb 04 15:30:34 2011] [error] rec.execute(self)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/orm/unitofwork.py", line 446, in execute
[Fri Feb 04 15:30:34 2011] [error] uow
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/orm/mapper.py", line 1878, in _save_obj
[Fri Feb 04 15:30:34 2011] [error] execute(statement, params)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/engine/base.py", line 1191, in execute
[Fri Feb 04 15:30:34 2011] [error] params)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/engine/base.py", line 1271, in _execute_clauseelement
[Fri Feb 04 15:30:34 2011] [error] return self.__execute_context(context)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/engine/base.py", line 1302, in __execute_context
[Fri Feb 04 15:30:34 2011] [error] context.parameters[0], context=context)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/engine/base.py", line 1394, in _cursor_execute
[Fri Feb 04 15:30:34 2011] [error] context)
[Fri Feb 04 15:30:34 2011] [error] File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/dialects/mysql/oursql.py", line 98, in do_execute
[Fri Feb 04 15:30:34 2011] [error] cursor.execute(statement, parameters)
[Fri Feb 04 15:30:34 2011] [error] File "cursor.pyx", line 122, in oursql.Cursor.execute (oursqlx/oursql.c:15820)
[Fri Feb 04 15:30:34 2011] [error] File "statement.pyx", line 382, in oursql._Statement.execute (oursqlx/oursql.c:10025)
[Fri Feb 04 15:30:34 2011] [error] TypeError: cannot bind <class 'decimal.Decimal'> object

The problem is that this is raised just sometimes, at other moments it all goes normally

Stephen Thorne (jerub) wrote :

I don't see how this can be possible. The code is literally:

                    elif isinstance(o, decimal.Decimal):
                        b.buffer_type = MYSQL_TYPE_NEWDECIMAL
                        o = str(o)
                        temp_strings.append(o)
                        b.buffer = PyString_AS_STRING(o)
                        c.ul = PyString_GET_SIZE(o)
                        b.length = &c.ul
                    elif isinstance(o, _AbstractIterWrapper):
                        b.buffer_type = MYSQL_TYPE_STRING
                        b.length = &c.ul
                        long_strings.append((i, o))
                    else:
                        raise TypeError('cannot bind %r object' % o.__class__)

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers