thelastbackspace opened a new pull request, #41003:
URL: https://github.com/apache/beam/pull/41003

   Fixes #41002
   
   With stable code identifier pickling enabled, `_search_module_or_class` 
walks `dir(node)` and calls `getattr` on every name while looking for a lambda. 
If some unrelated attribute raises when read (a descriptor that only works on 
instances, or a PEP 562 lazy module attribute whose optional dependency is 
missing), that exception escaped `get_code_object_identifier` and 
`cloudpickle_pickler.dumps` failed, even though plain pickling of the same 
lambda works.
   
   An attribute that can't be read can't be the lambda we're looking for, so 
the search now just skips it and keeps going. If nothing matches, it still 
returns None as before and cloudpickle falls back to pickling by value.
   
   Testing:
   - Added `test_lambda_search_skips_attributes_that_raise` in 
`code_object_pickler_test.py`, using a class with an instance-only descriptor 
that sorts before the lambda in `dir()`. It fails with `TypeError: only valid 
on instances` without the change and passes with it.
   - `pytest apache_beam/internal/code_object_pickler_test.py`
   
   Note: #40711 also touches this file; happy to rebase if that lands first.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to