UnicodeEncodeError in ir_cron code due to jobs name

Bug #992610 reported by Valentin Lab
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Confirmed
Low
OpenERP's Framework R&D

Bug Description

Hello,

This bug was reproduced on the last commit of openerp-6.1 branch of this morning (2012-05-01).

Yet another unicode error. 'threading.Thread' await a 'name' argument that should be already encoded (or convertible to ascii). Bad luck, it's job["name"] we are feeding in and this is unicode.

And this will silently pass until you provide a unicode string that contains devils characters.

2012-05-01 13:22:00,029 6775 WARNING ? openerp.addons.base.ir.ir_cron: Exception in cron:
Traceback (most recent call last):
  File "/home/vaab/dev/python/openobject-server/openerp/addons/base/ir/ir_cron.py", line 237, in _run_jobs_multithread
    task_thread = threading.Thread(target=self._run_job, name=job['name'], args=(task_cr, job, now))
  File "/opt/apps/python-2.7/lib/python2.7/threading.py", line 433, in __init__
    self.__name = str(name or _newname())
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 18: ordinal not in range(128)

Solution seems easy here:

job['name'].encode("utf-8")

is better than job['name'].

To reproduce, install subscription module, and account, create a subscription type on account.invoice, then a subscription, and put an accentuated character in the name of the subscription: it'll be copied as the name of the ir_cron job.
Put the according date in ir_cron so that it'll be triggered soon. Then switch watch your openobject-server logs.

Related branches

Valentin Lab (vaab)
summary: - UnicodeEncodeError cron
+ UnicodeEncodeError in ir_cron code due to jobs name
Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Valentin Lab (vaab) wrote :

Well, I guess this shows my lack of knowledge of the functional part of openerp...

Here is a much simpler way to reproduce:

Install a clean empty database, get the extended interface, and go in Settings / Configuration / Scheduler / Scheduled Actions
Edit one of them and add an UTF-8 char as "é" in the name of the Scheduled Action. Change time of next execution to match a near future. Wait. And Bang.

Revision history for this message
Steffen Hofmann (sth-6) wrote :

The proposed fix for ir_cron.py fixed the issue for us. Seems to work now.

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) wrote :

Nice catch!

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.