Repository navigation
Conversation
LazyProxy had no __format__, so f"{proxy:>8}" raised TypeError, and
unpickling one recursed in __getattr__ on the unset slots. Delegate
__format__ to the value and rebuild through __init__ in __reduce__.
Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1499 +/- ##
=======================================
Coverage 94.09% 94.09%
=======================================
Files 27 27
Lines 5077 5083 +6
=======================================
+ Hits 4777 4783 +6
Misses 300 300
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Sorry, are these actual issues for some use cases? |
chrikrah
left a comment
There was a problem hiding this comment.
No user report behind it. The class docstring says the lazy objects "should mostly work as expected" (support.py#L270-L271), and its doctests show + and %. On master (b778b94) f"{p:<5}" is where that stops:
$ python3 -c "from babel.support import LazyProxy; p = LazyProxy(lambda: 'Hi'); print(repr(' ' + p), repr('(%s)' % p)); f'{p:<5}'"
' Hi' '(Hi)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: unsupported format string passed to LazyProxy.__format__Pickling has no caller I can point to. If the format spec is worth keeping I'll cut the PR down to __format__; if not, I'll close it. Either is fine with me.
A format spec on
LazyProxyraises, though'(%s)' % lazy_greetingworks. Unpickling recurses. No issue exists. At b778b94:__format__delegates;__reduce__rebuilds through__init__, as__copy__has since #100. Proxies overTranslations().gettextstill won't pickle.@akx, I'd re-evaluate on load, since the locale may differ. If pickling is out of scope, shall I drop
__reduce__?