L3_NAT_dbonly_mixin __new__ method has wrong signature
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Fix Released
|
Wishlist
|
Brian Haley |
Bug Description
Since stable/newton, there is this code: https:/
master link: https:/
Python doc says: https:/
"...that takes the class of which an instance was requested as its first argument. The remaining arguments are those passed to the object constructor expression..."
Because the __new__ method is overridden in L3_NAT_dbonly_mixin without accepting extra arguments. This forces all subclasses to have either no arguments to the __init__ method, or they have to override __new__ themselves to workaround this.
The following code fails to run:
from neutron.db import l3_db
class Test(l3_
def __init__(self, arg1):
self.arg1 = arg1
Test(1)
--TypeError: __new__() takes exactly 1 argument (2 given)
The, hacky imo, workaround:
from neutron.db import l3_db
class Test(l3_
@staticmethod
def __new__(cls, *args, **kwargs):
return super(Test, cls).__new__(cls)
def __init__(self, arg1):
self.arg1 = arg1
Test(1)
description: | updated |
description: | updated |
Changed in neutron: | |
importance: | Undecided → Wishlist |
Changed in neutron: | |
assignee: | aditya_reddy.nagaram@nuagenetworks.net (adityarn) → Kevin Benton (kevinbenton) |
Changed in neutron: | |
assignee: | Kevin Benton (kevinbenton) → Brian Haley (brian-haley) |
Fix proposed to branch: master /review. openstack. org/422088
Review: https:/