hr_timesheet_reminder: {}.fromkeys with a mutable argument in second position

Bug #1089390 reported by Guewen Baconnier @ Camptocamp
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Camptocamp Addons
Confirmed
Undecided
Unassigned
HR - Timesheet Management
Fix Released
Undecided
Unassigned

Bug Description

hr_timesheet_reminder/company.py

    def get_reminder_recipients(self, cr, uid, ids, context=None):
        """Return the list of users that must receive the email"""
        res = {}.fromkeys(ids, [])

Never use a mutable second argument in fromkeys!

The keys are linked with the same list instance.

Related branches

description: updated
summary: - {}.fromkeys with a mutable argument in second position
+ hr_timesheet_reminder: {}.fromkeys with a mutable argument in second
+ position
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

the fix is to write:

    def get_reminder_recipients(self, cr, uid, ids, context=None):
        """Return the list of users that must receive the email"""
        res = {}
        for id in ids:
             res[id] = []

or given a sufficiently recent python version:
    res = {id: [] for id in ids}

Changed in hr-timesheet:
status: New → Confirmed
status: Confirmed → Fix Released
Changed in c2c-addons:
status: New → Confirmed
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.