Method hooks swallow AttributeError
See original GitHub issueIf 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:
- Created 8 years ago
- Reactions:5
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I intend to look into solutions for this in marshmallow 3.0
This is super annoying… and should at least come with a way to switch off this behaviour for debugging purposes.