question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Method hooks swallow AttributeError

See original GitHub issue

If AttributeError is raised by a Method/Function hook, it is silently swallowed:

class C(Schema):
    f = fields.Method('_bad_serialize')
    def _bad_serialize(self, obj):
        return self._do_something_else(obj)  # raises AttributeError

test_type = namedtuple('test_type', 'f')
C(strict=True).dump(test_type(123))  # returns empty list

This makes finding the bugs harder. I understand the rationale and I guess fixing it might make some code backward incompatible, but is there a way to add at least some warning mode?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:5
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
sloriacommented, May 24, 2016

I intend to look into solutions for this in marshmallow 3.0

2reactions
hanselpazecommented, Apr 7, 2016

This is super annoying… and should at least come with a way to switch off this behaviour for debugging purposes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError using hooks in Requests Python package
I am sending requests and receiving their response objects into a hooked function. Sometimes, I'm sending a new request out of that same ......
Read more >
Upgrading to Newer Releases — marshmallow 3.19.0 ...
The Method and Function fields no longer swallow AttributeErrors . Therefore, your methods and functions are responsible for handling inputs such as None...
Read more >
Issue 7559: TestLoader.loadTestsFromName swallows import ...
Say I have a test module test_foo, which fails to import with ImportError. A reason for this might be a misspelt import in...
Read more >
Surprising __getattr__ recursion - Ned Batchelder
When it copies an object, it doesn't invoke its __init__ method. ... So hasattr swallows the exception, and we never hear about it....
Read more >
attributeerror: 'timedelta' object has no attribute 'hours' - You.com
self.control should be a dictionary, yet you are setting it to the output of json.dumps which will be a string. So if you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found