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
Undecided
Unassigned
HR - Timesheet Management
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  Edit
Everyone can see this information.

Other bug subscribers