Merge "Fix 'method object has no attribute __yaql_function__' on py3"
This commit is contained in:
commit
1558b8dc52
|
@ -613,8 +613,8 @@ def assemble_object_definition(parsed, model_format=dsl_types.DumpTypes.Mixed):
|
|||
|
||||
|
||||
def function(c):
|
||||
if hasattr(c, 'im_func'):
|
||||
return c.im_func
|
||||
if hasattr(c, '__func__'):
|
||||
return c.__func__
|
||||
return c
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
import copy
|
||||
import semantic_version
|
||||
import types
|
||||
from unittest import mock
|
||||
import weakref
|
||||
|
||||
|
@ -232,6 +233,18 @@ class TestDSLHelpers(base.MuranoTestCase):
|
|||
test_parsed, None)
|
||||
self.assertEqual('Invalid Serialization Type', str(e))
|
||||
|
||||
def test_function(self):
|
||||
def f():
|
||||
return
|
||||
self.assertTrue(isinstance(helpers.function(f), types.FunctionType))
|
||||
|
||||
def test_function_from_method(self):
|
||||
class C:
|
||||
def m(self):
|
||||
return
|
||||
c = C()
|
||||
self.assertTrue(isinstance(helpers.function(c.m), types.FunctionType))
|
||||
|
||||
def test_weak_proxy(self):
|
||||
self.assertIsNone(helpers.weak_proxy(None))
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
fixes:
|
||||
- Avoid the `'method' object has no attribute '__yaql_function__'` error
|
||||
when calling some YAQL functions with Python 3
|
Loading…
Reference in New Issue