[elbe-devel] [PATCH v3] py3: annotations - __code__ instead of func_code

Manuel Traut manut at linutronix.de
Mon Dec 18 15:58:22 CET 2017


func_code was renamed to __code__ in py3 for consistency
with other attributes. It also works with py2.6

Signed-off-by: Manuel Traut <manut at linutronix.de>
---
 elbepack/daemons/soap/authentication.py | 22 +++++++++++-----------
 elbepack/daemons/soap/faults.py         | 16 ++++++++--------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/elbepack/daemons/soap/authentication.py b/elbepack/daemons/soap/authentication.py
index 9cb14440..68dcd6c2 100644
--- a/elbepack/daemons/soap/authentication.py
+++ b/elbepack/daemons/soap/authentication.py
@@ -32,7 +32,7 @@ def authenticated_uid(func):
             @authenticated_uid
             def get_files (self, uid, builddir): 
     """
-    if func.func_code.co_argcount == 2:
+    if func.__code__.co_argcount == 2:
         @wraps(func)
         def wrapped(self):
             s = self.transport.req_env['beaker.session']
@@ -43,7 +43,7 @@ def authenticated_uid(func):
 
             return func(self,uid)
         return wrapped
-    elif func.func_code.co_argcount == 3:
+    elif func.__code__.co_argcount == 3:
         @wraps(func)
         def wrapped(self, arg1):
             s = self.transport.req_env['beaker.session']
@@ -54,7 +54,7 @@ def authenticated_uid(func):
 
             return func(self,uid,arg1)
         return wrapped
-    elif func.func_code.co_argcount == 4:
+    elif func.__code__.co_argcount == 4:
         @wraps(func)
         def wrapped(self, arg1, arg2):
             s = self.transport.req_env['beaker.session']
@@ -65,7 +65,7 @@ def authenticated_uid(func):
 
             return func(self,uid,arg1,arg2)
         return wrapped
-    elif func.func_code.co_argcount == 5:
+    elif func.__code__.co_argcount == 5:
         @wraps(func)
         def wrapped(self, arg1, arg2, arg3):
             s = self.transport.req_env['beaker.session']
@@ -76,7 +76,7 @@ def authenticated_uid(func):
 
             return func(self,uid,arg1,arg2,arg3)
         return wrapped
-    elif func.func_code.co_argcount == 6:
+    elif func.__code__.co_argcount == 6:
         @wraps(func)
         def wrapped(self, arg1, arg2, arg3, arg4):
             s = self.transport.req_env['beaker.session']
@@ -87,7 +87,7 @@ def authenticated_uid(func):
 
             return func(self,uid,arg1,arg2,arg3,arg4)
         return wrapped
-    elif func.func_code.co_argcount == 7:
+    elif func.__code__.co_argcount == 7:
         @wraps(func)
         def wrapped(self, arg1, arg2, arg3, arg4, arg5):
             s = self.transport.req_env['beaker.session']
@@ -99,7 +99,7 @@ def authenticated_uid(func):
             return func(self,uid,arg1,arg2,arg3,arg4,arg5)
         return wrapped
     else:
-        raise Exception( "arg count %d not implemented" % func.func_code.co_argcount )
+        raise Exception( "arg count %d not implemented" % func.__code__.co_argcount )
 
 
 
@@ -114,7 +114,7 @@ def authenticated_admin(func):
             @authenticated_uid
             def get_files (self, uid, builddir): 
     """
-    if func.func_code.co_argcount == 1:
+    if func.__code__.co_argcount == 1:
         @wraps(func)
         def wrapped(self):
             s = self.transport.req_env['beaker.session']
@@ -127,7 +127,7 @@ def authenticated_admin(func):
                 raise SoapElbeNotAuthorized()
             return func(self)
         return wrapped
-    elif func.func_code.co_argcount == 2:
+    elif func.__code__.co_argcount == 2:
         @wraps(func)
         def wrapped(self, arg1):
             s = self.transport.req_env['beaker.session']
@@ -141,7 +141,7 @@ def authenticated_admin(func):
 
             return func(self,arg1)
         return wrapped
-    elif func.func_code.co_argcount == 3:
+    elif func.__code__.co_argcount == 3:
         @wraps(func)
         def wrapped(self, arg1, arg2):
             s = self.transport.req_env['beaker.session']
@@ -155,4 +155,4 @@ def authenticated_admin(func):
             return func(self,arg1,arg2)
         return wrapped
     else:
-        raise Exception( "arg count %d not implemented" % func.func_code.co_argcount )
+        raise Exception( "arg count %d not implemented" % func.__code__.co_argcount )
diff --git a/elbepack/daemons/soap/faults.py b/elbepack/daemons/soap/faults.py
index ee80bfbe..1a69e0f5 100644
--- a/elbepack/daemons/soap/faults.py
+++ b/elbepack/daemons/soap/faults.py
@@ -61,7 +61,7 @@ def soap_faults(func):
     """ decorator, which wraps Exceptions to the proper
         Soap Faults, and raises these.
     """
-    if func.func_code.co_argcount == 1:
+    if func.__code__.co_argcount == 1:
         @wraps(func)
         def wrapped(self):
             try:
@@ -81,7 +81,7 @@ def soap_faults(func):
             except Exception as e:
                 raise SoapElbeProjectError (format_exc ())
         return wrapped
-    if func.func_code.co_argcount == 2:
+    if func.__code__.co_argcount == 2:
         @wraps (func)
         def wrapped (self, arg1):
             try:
@@ -101,7 +101,7 @@ def soap_faults(func):
             except Exception as e:
                 raise SoapElbeProjectError (format_exc ())
         return wrapped
-    if func.func_code.co_argcount == 3:
+    if func.__code__.co_argcount == 3:
         @wraps (func)
         def wrapped (self, arg1, arg2):
             try:
@@ -121,7 +121,7 @@ def soap_faults(func):
             except Exception as e:
                 raise SoapElbeProjectError (format_exc ())
         return wrapped
-    if func.func_code.co_argcount == 4:
+    if func.__code__.co_argcount == 4:
         @wraps (func)
         def wrapped (self, arg1, arg2, arg3):
             try:
@@ -141,7 +141,7 @@ def soap_faults(func):
             except Exception as e:
                 raise SoapElbeProjectError (format_exc ())
         return wrapped
-    if func.func_code.co_argcount == 5:
+    if func.__code__.co_argcount == 5:
         @wraps (func)
         def wrapped (self, arg1, arg2, arg3, arg4):
             try:
@@ -161,7 +161,7 @@ def soap_faults(func):
             except Exception as e:
                 raise SoapElbeProjectError (format_exc ())
         return wrapped
-    if func.func_code.co_argcount == 6:
+    if func.__code__.co_argcount == 6:
         @wraps (func)
         def wrapped (self, arg1, arg2, arg3, arg4, arg5):
             try:
@@ -181,7 +181,7 @@ def soap_faults(func):
             except Exception as e:
                 raise SoapElbeProjectError (format_exc ())
         return wrapped
-    if func.func_code.co_argcount == 7:
+    if func.__code__.co_argcount == 7:
         @wraps (func)
         def wrapped (self, arg1, arg2, arg3, arg4, arg5, arg6):
             try:
@@ -202,5 +202,5 @@ def soap_faults(func):
                 raise SoapElbeProjectError (format_exc ())
         return wrapped
     else:
-        raise Exception( "arg count %d not implemented" % func.func_code.co_argcount )
+        raise Exception( "arg count %d not implemented" % func.__code__.co_argcount )
 
-- 
2.15.1




More information about the elbe-devel mailing list