0

Here's the top of my function (which is part of a class that wraps an existing python implementation of the Bill.com API):

def _get_objects(self,
                 bdco, 
                 refresh=False,
                 sort=[],
                 filters=[],
                 start=0, max=999,
                 include_inactive=False):
    """
    Retrieve (either from cache or the service directly) all of the object
     in question (e.g. Vendor, Customer, etc.)
    """

    if ('isActive','=','1') in filters \
       and bdco in ["MoneyMovement", "ReceivedPay"]:
        print bdco, filters
        import ipdb;ipdb.set_trace()
        raise Exception("Huh!?")

The function that calls this one is definitely NOT passing any 'filters' parameter or **kwargs that might include one. Still:

ReceivedPay [('isActive', '=', '1')]
> /my_dir/simple_bdc.py(367)_get_objects()
    366             import ipdb;ipdb.set_trace()
--> 367             raise Exception("huh!?")
    368 

ipdb> 

Many other classes in my stack call this function, so I'm wondering if a different caller is somehow setting something persistent here, but I'm totally stumped. Any ideas for how to even troubleshoot it?

Thank you!

agf
  • 171,228
  • 44
  • 289
  • 238
HaPsantran
  • 5,581
  • 6
  • 24
  • 39
  • 3
    http://stackoverflow.com/questions/1132941/least-astonishment-in-python-the-mutable-default-argument should explain it. Don't use mutable objects as defaults unless you're sure what you're doing. – agf Oct 27 '14 at 04:13
  • Yup, that was it. Thanks! – HaPsantran Jan 10 '15 at 14:17

0 Answers0