browse_null should have __iter__ method to prevent looping problems
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Confirmed
|
Low
|
OpenERP's Framework R&D | ||
OpenERP Community Backports (Server) |
New
|
Undecided
|
Unassigned |
Bug Description
When a method that is expecting a browse_record receives a browse_null record, a looping condition might occur, that will lead to a server becoming totally unresponsive, while CPU utilization goes to 100%.
We encountered the problem in a line like the next, where mail_message is supposed to be a browse_record:
if field in mail_message:
because mail_message is in fact a browse_null record, this will result in an endless loop. Well, theoretically not endless, but __getitem__ will be called with increasing index values, in an attempt to find the item with name 'field'.
Look at this discussion:
The fix is simple. Give browse_null the same __iter__ method as browse_record:
def __iter__(self):
raise NotImplementedE
It might be argued that modules should not have problems where browse_null objects are treated as browse_record objects. However, it is better to have a clear exception when using a specific function in a module, than a problem hanging a server with no message at all.
Related branches
- OpenERP Core Team: Pending requested
-
Diff: 13 lines (+3/-0)1 file modifiedopenerp/osv/orm.py (+3/-0)
Changed in openobject-server: | |
assignee: | nobody → OpenERP's Framework R&D (openerp-dev-framework) |
importance: | Undecided → Low |
status: | New → Confirmed |