Opened 12 years ago

Closed 10 years ago

Last modified 7 years ago

#4609 closed Patches (fixed)

Boost.Python: Converting from bytes object to std::string

Reported by: Haoyu Bai Owned by: Ralf W. Grosse-Kunstleve
Milestone: To Be Determined Component: python USE GITHUB
Version: Boost Development Trunk Severity: Problem
Keywords: Cc: blake@…, mistersheik@…

Description

I just realized that, in Boost.Python with Python 3, there is no way to accept a Python bytes object as function argument in C++ side. Since both std::string and char* are mapped to Python unicode object (which is the default str type in Python 3). This will cause trouble when porting existing code to Python 3.

The attached patch fix this by allow both unicode string and bytes being converted to std::string.

Attachments (1)

bytes_to_string.patch (675 bytes ) - added by Haoyu Bai 12 years ago.

Download all attachments as: .zip

Change History (20)

by Haoyu Bai, 12 years ago

Attachment: bytes_to_string.patch added

comment:1 by Haoyu Bai, 12 years ago

Summary: Converting from bytes object to std::stringBoost.Python: Converting from bytes object to std::string

comment:2 by anonymous, 12 years ago

any chance of this getting looked at soon?

comment:3 by Dave Abrahams, 12 years ago

Not very likely by me, sorry. But if you poke the C++-sig another maintainer might take a crack at it.

comment:4 by blake@…, 12 years ago

Cc: blake@… added

great, thanks for commenting, I've mentioned this issue on sig-c++ just now: http://mail.python.org/pipermail/cplusplus-sig/2011-January/015856.html

comment:5 by DRayX, 11 years ago

Any chance of this being looked at? This is a very useful patch, and it is sort of a pain to have to apply it and compile boost every time I want to update. Thanks to bhy for the great patch.

comment:6 by Dane Springmeyer <dane@…>, 11 years ago

+1, my project is also blocked by this.

comment:7 by Dane Springmeyer <dane@…>, 11 years ago

any news on this?

in reply to:  7 comment:8 by mistersheik@…, 11 years ago

Cc: mistersheik@… added

I'm also interested in this review being looked at.

comment:10 by Robert Park <rbpark@…>, 10 years ago

+1, accept this patch!

comment:11 by anonymous, 10 years ago

Why has this not yet been addressed? I think that almost everybody using boost python with python 3 uses this patch, or has to deal with the bug. Any chance this patch could be accepted?

comment:12 by anonymous, 10 years ago

Same story here. Anyone on the boost team - can you at least comment on why this patch is not getting accepted?

comment:13 by Dave Abrahams, 10 years ago

Owner: changed from Dave Abrahams to Ralf W. Grosse-Kunstleve

Speaking personally, maintenance responsibility for Boost.Python has largely passed from me to others. Unfortunately, I am not sure to whom the ticket should be reassigned. Maybe Ralf knows?

comment:14 by Ralf W. Grosse-Kunstleve, 10 years ago

svn rev. 79774 applies this patch to the boost trunk

if there are no problems I plan to merge to the release branch in about a week

comment:15 by anonymous, 10 years ago

rwgk, thank you!

comment:16 by DRayX, 10 years ago

Thanks for committing this rwgk, but this fix still hasn't showed up in either of the two releases since then. Is there any chance we can get this merged to the release branch?

comment:17 by Ralf W. Grosse-Kunstleve, 10 years ago

Resolution: fixed
Status: newclosed

I merged the change into the release branch about six days ago.

comment:18 by anonymous, 10 years ago

Thank you!

comment:19 by frolvlad@…, 7 years ago

Emm, I'm sorry to poke this old issue, but doesn't it solve only half of the problem? How do I return bytes string? It seems that it always returns Unicode string in Python 3...

Note: See TracTickets for help on using tickets.