Breaking into descriptors

Dave Angel davea at davea.name
Thu Feb 28 19:01:23 CET 2013


On 02/28/2013 12:24 PM, Demian Brecht wrote:
> class MyDescriptor(object):
>      def __init__(self):
>          self.foo = 'bar'
>
>      def __get__(self, obj, type_):
>          import pdb; pdb.set_trace()
>          return self.do_something()
>
>      def __set__(self, obj, val):
>          self.foo = val
>
> class C(object):
>      foo = MyDescriptor()
>
> C().foo
>
> pdb doesn't break into the descriptor's __get__ method on C().foo. Is
> this a known limitation of pdb, or possibly a(n) (un)known bug?
>
>

It halts (breaks) for me, in Python 2.7.3 on Linux

  > /home/davea/temppython/demian.py(8)__get__()
  -> return self.do_something()
  (Pdb) up
  > /home/davea/temppython/demian.py(19)<module>()
  -> obj = C().foo
  (Pdb)


-- 
DaveA



More information about the Python-list mailing list