diff --git a/src/dynamic-srv.py b/src/dynamic-srv.py
index ab95fd3c8679280e105d311b589a91a5db97e58d..4af5955ceb6b3e675834b8a62c85af1b7318bf42 100755
--- a/src/dynamic-srv.py
+++ b/src/dynamic-srv.py
@@ -545,7 +545,7 @@ class Dynamic(PyTango.Device_4Impl):
     def read_dynamic_attribute(self, attr_name):
         if self.read_functions[attr_name]:
             read_method = getattr(self.module,self.read_functions[attr_name])
-            num_of_args = read_method.func_code.co_argcount
+            num_of_args = read_method.__code__.co_argcount
             if num_of_args == 1:
                 # If method allows an input parameter,
                 # it's a reference to this class
@@ -563,7 +563,7 @@ class Dynamic(PyTango.Device_4Impl):
     def write_dynamic_attribute(self, attr_name, value_in):
         if self.write_functions[attr_name]:
             write_method = getattr(self.module,self.write_functions[attr_name])
-            num_of_args = write_method.func_code.co_argcount
+            num_of_args = write_method.__code__.co_argcount
             if num_of_args == 2:
                 # If method allows two input parameter,
                 # the first is a reference to this class