[elbe-devel] [PATCH 17/25] py3: annotations - use func instead of func.func
Torben Hohn
torben.hohn at linutronix.de
Fri Dec 15 18:00:30 CET 2017
On Mon, Dec 11, 2017 at 10:11:11AM +0100, Manuel Traut wrote:
> func.func is not available in py3 but using only
> func works in py2 and py3.
this is not func.func its about: func.func_code
the __code__ thing was introduced in py2.6
but sure... we should do this changed.
commitmessage does not get reviewed-by.
code does.
>
> I don't have an idea, why func.func was used.
>
> 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 65c6cf89..08909c71 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 54a1affe..3a0e64c0 100644
> --- a/elbepack/daemons/soap/faults.py
> +++ b/elbepack/daemons/soap/faults.py
> @@ -71,7 +71,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:
> @@ -91,7 +91,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:
> @@ -111,7 +111,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:
> @@ -131,7 +131,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:
> @@ -151,7 +151,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:
> @@ -171,7 +171,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:
> @@ -191,7 +191,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:
> @@ -212,5 +212,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
>
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
--
Mit freundlichen Grüßen
Torben Hohn
Linutronix GmbH
Standort: Bremen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806
Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner
Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20171215/62aa5a40/attachment-0001.sig>
More information about the elbe-devel
mailing list