{"record":{"id":"518301a9ecb43225","repo":"arduino/Arduino","slug":"update-takes-at-most-2-positional-arguments-d","errorCode":null,"errorMessage":"update() takes at most 2 positional arguments (%d given)","messagePattern":"update\\(\\) takes at most 2 positional arguments \\((.+?) given\\)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/ordered_dict.py","lineNumber":153,"sourceCode":"        for k in self:\n            yield self[k]\n\n    def iteritems(self):\n        'od.iteritems -> an iterator over the (key, value) items in od'\n        for k in self:\n            yield (k, self[k])\n\n    def update(*args, **kwds):\n        '''od.update(E, **F) -> None.  Update od from dict/iterable E and F.\n\n        If E is a dict instance, does:           for k in E: od[k] = E[k]\n        If E has a .keys() method, does:         for k in E.keys(): od[k] = E[k]\n        Or if E is an iterable of items, does:   for k, v in E: od[k] = v\n        In either case, this is followed by:     for k, v in F.items(): od[k] = v\n\n        '''\n        if len(args) > 2:\n            raise TypeError('update() takes at most 2 positional '\n                            'arguments (%d given)' % (len(args),))\n        elif not args:\n            raise TypeError('update() takes at least 1 argument (0 given)')\n        self = args[0]\n        # Make progressively weaker assumptions about \"other\"\n        other = ()\n        if len(args) == 2:\n            other = args[1]\n        if isinstance(other, dict):\n            for key in other:\n                self[key] = other[key]\n        elif hasattr(other, 'keys'):\n            for key in other.keys():\n                self[key] = other[key]\n        else:\n            for key, value in other:\n                self[key] = value\n        for key, value in kwds.items():","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/ordered_dict.py#L135-L171","documentation":"The vendored OrderedDict.update() is defined with *args (unbound-style) and enforces that at most 2 positional arguments are passed: the implicit self plus one mapping/iterable source. Passing 3 or more positional arguments (e.g. two source mappings) exceeds that and raises this TypeError with the actual count interpolated.","triggerScenarios":"Calling od.update(dict_a, dict_b) to merge two mappings in one call, or any other call passing 3+ positional arguments to update(); six.moves-era Py2.6 backport of OrderedDict does not support multi-source update like dict.update in later Pythons.","commonSituations":"Migrating code written against Python 3.5+ dict.update(a, **b) multi-source semantics onto this vendored backport; chaining defaults and overrides in one update call.","solutions":["Update sequentially: od.update(a); od.update(b).","Merge into a temporary dict first: od.update({**a, **b}) (or dict(a, **b) on Py2).","Use od.update(itertools.chain(a.items(), b.items())) since an iterable of pairs is accepted."],"exampleFix":"// before\nod.update(defaults, overrides)\n// after\nod.update(defaults)\nod.update(overrides)","handlingStrategy":"validation","validationCode":"# inspect before call\nargs = (defaults, overrides)\nassert 0 < len(args) <= 1, 'this OrderedDict.update takes at most self + 1 source'","typeGuard":null,"tryCatchPattern":"try:\n    od.update(a, b)\nexcept TypeError as e:\n    if 'at most 2 positional' in str(e):\n        od.update(a); od.update(b)\n    else:\n        raise","preventionTips":["Never pass more than one source mapping/iterable to this vendored update().","Merge sources into one dict before updating.","Remember this backport predates Python 3.5 multi-source dict.update semantics."],"tags":["python","typeerror","ordered-dict","argument-count"],"backgroundTag":"missing-required-argument","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}