mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-07 03:21:34 +02:00
Fixed the core issue (nil was not working as return value of a factory method)
This commit is contained in:
Vendored
+11
@@ -146,6 +146,13 @@ class PyGFactory(pya.GFactory):
|
||||
def f(self, z):
|
||||
return PyGObject(z)
|
||||
|
||||
class PyNilGFactory(pya.GFactory):
|
||||
def __init__(self):
|
||||
super(PyNilGFactory, self).__init__()
|
||||
# reimplementation of "virtual GObject *f(int)"
|
||||
def f(self, z):
|
||||
return None
|
||||
|
||||
class BasicTest(unittest.TestCase):
|
||||
|
||||
def test_00(self):
|
||||
@@ -3255,6 +3262,10 @@ class BasicTest(unittest.TestCase):
|
||||
go = None
|
||||
self.assertEqual(pya.GObject.g_inst_count(), gc)
|
||||
|
||||
gf = PyNilGFactory()
|
||||
go = pya.GFactory.create_f(gf, 17)
|
||||
self.assertEqual(go is None, True)
|
||||
|
||||
# fallback to __rmul__ for not implemented __mul__
|
||||
|
||||
def test_90(self):
|
||||
|
||||
Vendored
+4
@@ -3252,6 +3252,10 @@ class Basic_TestClass < TestBase
|
||||
GC.start
|
||||
assert_equal(RBA::GObject.g_inst_count, gc)
|
||||
|
||||
gf = RBANilGFactory::new
|
||||
go = RBA::GFactory.create_f(gf, 17)
|
||||
assert_equal(go, nil)
|
||||
|
||||
end
|
||||
|
||||
# keyword arguments, enums and error messages
|
||||
|
||||
Vendored
+10
@@ -76,3 +76,13 @@ class RBAGFactory < RBA::GFactory
|
||||
end
|
||||
end
|
||||
|
||||
class RBANilGFactory < RBA::GFactory
|
||||
def initialize
|
||||
super()
|
||||
end
|
||||
# reimplementation of "virtual GObject *f(int)"
|
||||
def f(z)
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user