fix: conversion to string in python bindings#19137
Conversation
|
So limited API prevents us from getting type name directly and we can't access slot with allowed functions prior to Python 3.4... |
If provided `PyObject` can't be converted to string `TypeError` is reported instead of `SytemError` without any message.
ef3eb89 to
7b0d7d0
Compare
|
|
||
| def test_parse_to_string_convertible(self): | ||
| try_to_convert = partial(self._try_to_convert, cv.utils.dumpString) | ||
| for convertible in (None, '', 's', 'str', str(123), np.str('test1'), np.str_('test2')): |
There was a problem hiding this comment.
All existed conversion functions are (even for trivial types such as int, float and etc.) very tolerant to None values in Python - treating them as "use default". In this test I wanted to explicitly notice this in test, because if this behaviour will be changed sometimes - it will be clear for API users - tests will document this.
There was a problem hiding this comment.
"tested" usually means that feature is supported without future regressions.
"non-tested" - undocumented behavior, it may work for now, use it at own risk.
None handling is still not complete in Python binding implementation. See this comment from previous PR.
So this None case should go away after implementation got fixed.
"use default"
It should be for args with "defaults" only.
If provided
PyObjectcan't be converted to stringTypeErroris reported instead ofSytemErrorwithout any message.Partially resolves #18835. but doesn't resolve problem with overload selection in general.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.