Change in pysim[master]: pySim/filesystem: fix mutable default list/dict arguments

fixeria gerrit-no-reply at lists.osmocom.org
Sat Mar 27 00:43:20 UTC 2021


Hello Jenkins Builder, laforge, dexter, 

I'd like you to reexamine a change. Please visit

    https://gerrit.osmocom.org/c/pysim/+/23513

to look at the new patch set (#2).

Change subject: pySim/filesystem: fix mutable default list/dict arguments
......................................................................

pySim/filesystem: fix mutable default list/dict arguments

Having lists and dictionaries as default argument values is a bad
idea, because the same instance of list/dict will be used by all
objects instanuated using such constructor:

  def appendItem(itemName, itemList=[]):
      itemList.append(itemName)
      return itemList

  print(appendItem('notebook'))
  print(appendItem('pencil'))
  print(appendItem('eraser'))

Output:

  ['notebook']
  ['notebook', 'pencil']
  ['notebook', 'pencil', 'eraser']

Change-Id: I83d718ff9c3ff6aef47930f38d7f50424f9b880f
---
M pySim/filesystem.py
1 file changed, 8 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/13/23513/2
-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23513
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I83d718ff9c3ff6aef47930f38d7f50424f9b880f
Gerrit-Change-Number: 23513
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: newpatchset
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210327/36f2dd93/attachment.htm>


More information about the gerrit-log mailing list