[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [PATCH] don't dump private data members
- From: Chris Lumens <clumens redhat com>
- To: anaconda-devel-list redhat com
- Subject: Re: [PATCH] don't dump private data members
- Date: Fri, 7 Nov 2008 16:13:57 -0500
> diff --git a/exception.py b/exception.py
> index e4e7c08..b146315 100644
> --- a/exception.py
> +++ b/exception.py
> @@ -89,6 +89,9 @@ class AnacondaExceptionDump:
> pad = ' ' * ((level) * 2)
>
> for key, value in instance.__dict__.items():
> + if key.startswith("_%s__" % instance.__class__.__name__):
> + continue
> +
> if parentkey != "":
> curkey = parentkey + "." + key
> else:
>
> This is beyond my python skills, so no comment on this.
Python has some funny ideas about how to make something a private member
of a class. It mangles the name to be _ClassName__MemberName. So if
you have the following class:
class A:
def __init__(self):
self.__blah = None
Then you really have class A with member _A__blah in any instances.
Kind of silly, really.
This part of the patch looks through all the members in an instance of a
class and skips over any that have been mangled into being private.
- Chris
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]