-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Tracking PR: intermediate state of completed str
/bytes
cleaning up PRs
#2348
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
60cba1c
to
3c8dbc2
Compare
(Rebased onto master, so watch out when using this branch locally, without updating.) |
65130b7
to
dcc41ef
Compare
1d553e4
to
0b49467
Compare
0b49467
to
0ab4b97
Compare
…bytes type to test_constructors(). (#2340)
* Rolling back PR #2340 change to tests/test_pytypes.py (only this one file). The two other files changed with PR #2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR #2380. * test_constructors() fix for Python 2. Preparation for changing `pybind11::str` to only hold `PyUnicodeObject` (NOT also `bytes`). Currently test_constructors passes with Python 2 only because `pybind11::str` can also hold a Python 2 `PyStringObject` (or the equivalent `PyBytesObject` in Python 3). Changing the test to exercise conversions for `PyUnicodeObject` makes it consistent between Python 2 and 3, and removes this small obstacle to the planned `pybind11::str` change. Tests for `bytes` conversions will be added separately. * Adding test_constructors test for bytes, on top of cherry-picked commit from PR #2380.
…old `PyUnicodeObject` (NOT also `bytes`). NO change in behavior. These additional tests are designed to clearly bring out behavior changes related to planned `pybind11::str` changes.
…tes`). The corresponding behavior changes are captured by changes in the tests. A significant effort was made to keep the test diffs minimal but also comprehensive and easy to read. Note: Unlike PR #2256 (dropped), this PR only changes exactly one behavior. The two other behavior changes discussed under PR #2256 are avoided here (1. disabling implicit decoding from bytes to unicode; 2. list_caster behavior change). Based on this PR, those can be easily implemented if and when desired.
…py::error_already_set if not
7ae6bb2
to
4fc3b1b
Compare
I'm really sorry, but I have to abandon this branch due to severe lack of progress. For context, I added my first comment on #2198 on Jun 13. Following @YannickJadoul guidance, I spent an inordinate amount of time shifting the same small code fragments between branches and PRs. More than two months after I first picked up #2198, and >2 weeks of net effort, @YannickJadoul doesn't even support merging the small test additions into master, to simply add missing coverage for existing behavior, that is meant to serve as a baseline for behavior changes. — I really have to pull the emergency brake now. The full conversation leading me to this decision is pasted below, with Yannick's permission. Obviously, I need this work, or at least part of it, on Full conversation pasted here, as first suggested by me, then after some more back-and-forth requested by Yannick: Full conversationRalf Grosse-Kunstleve 7:34 AM August 17, 2020 Yannick Jadoul 7:35 AM Ralf Grosse-Kunstleve 9:09 AM
9:10 Ralf Grosse-Kunstleve 10:55 AM Ralf Grosse-Kunstleve 12:54 PM Yannick Jadoul 2:03 PM
Ralf Grosse-Kunstleve 2:07 PM Ralf Grosse-Kunstleve 2:15 PM Slackbot 2:15 PM Yannick Jadoul 2:17 PM Ralf Grosse-Kunstleve 2:19 PM Yannick Jadoul 2:20 PM Ralf Grosse-Kunstleve 2:22 PM Yannick Jadoul 2:27 PM Ralf Grosse-Kunstleve 2:29 PM Yannick Jadoul 3:19 PM Ralf Grosse-Kunstleve 3:23 PM Yannick Jadoul 3:29 PM Ralf Grosse-Kunstleve 3:32 PM Yannick Jadoul 3:35 PM Ralf Grosse-Kunstleve 11:40 AM August 18, 2020 Yannick Jadoul 12:13 PM Ralf Grosse-Kunstleve 12:14 PM Ralf Grosse-Kunstleve 12:46 PM Yannick Jadoul 1:42 PM Ralf Grosse-Kunstleve 1:47 PM Yannick Jadoul 1:51 PM EDIT (@YannickJadoul): put in |
Cleanup in passing: This PR is completely stale, and I think all work was actually completed a long time ago. |
Merged
py::bytes(dict["foo"])
, no breaking changes. Can/should go into patch release.py::str
always contains a true unicode string object (unicode
in Python 2/str
in Python 3). Potentially changing old usage, but probably only undocumented/unexpected behavior. Conversion from a bytes-object topy::str
is still provided (given that a valid UTF-8 encoding is used), so onlypy::isinstance
and the actual internal representation is changed. Can probably go into a patch release (though further work to increase consistency is advisable on the long term).str(handle)
correctly converted the object, and throw py::error_already_set if not #2392 & Add check ifstr(handle)
correctly converted the object, and throw py::error_already_set if not (bis) #2477 - Minor bug fix callingpy::str
on apy::handle
with an invalid/non-UTF-8-encoded Python 2str
. (Depends on Changing pybind11::str to only hold PyUnicodeObject (NOT also bytes). #2380)Pending
py::object
argument when constructingpy::bytes
,py::ellipsis
, andpy::none
. AFAICT, only breaking when users e.g. relied on having apy::bytes
object that contained another type. So in principle, this should only bring out currently silent errors.Merged separately to
master
pytest.PY2
instead ofstr is bytes
. #2396 - Extra tests on current conversion behaviour ofpy::str(py::object)
.Discarded
TODO
py::bytes
a converting constructor (PYBIND11_OBJECT_CVT
instead ofPYBIND11_OBJECT
) (@YannickJadoul)PYBIND11_OBJECT
could callcheck_
(@YannickJadoul)test_constructors()
to check the changes in constructors (either converting or throwing an error on a non-bytes
object)PYBIND11_DISABLE_IMPLICIT_STR_FROM_BYTES
(Changing pybind11::str to only hold PyUnicodeObject (NOT also bytes). #2380): do we a) discard it (keeping current behaviour), b) keep it (undocumented), c) document it (as opt-in), d) deprecate not using it?