[C++-sig] [python] Fix for boost::python::import
David Abrahams
dave at boost-consulting.com
Wed Mar 28 19:51:16 CEST 2007
on Wed Mar 28 2007, Thomas Witt <witt-AT-acm.org> wrote:
> On Mar 28, 2007, at 9:39 AM, Stefan Seefeld wrote:
>
>> Hans Meine wrote:
>>> Hi!
>>>
>>> Am Donnerstag, 01. März 2007 03:33:40 schrieb Stefan Seefeld:
>>>> --- libs/python/src/import.cpp 27 Oct 2006 21:17:25 -0000 1.2
>>>> +++ libs/python/src/import.cpp 1 Mar 2007 02:00:47 -0000
>>>> @@ -17,7 +17,7 @@
>>>> {
>>>> // should be 'char const *' but older python versions don't
>>>> use 'const'
>>>> yet. char *n = python::extract<char *>(name);
>>>> - python::handle<> module(python::borrowed(PyImport_AddModule(n)));
>>>> + python::handle<> module(python::borrowed(PyImport_ImportModule
>>>> (n)));
>>>> return python::object(module);
>>>> }
>>>
>>> I just saw your patch and looked at the docs.. isn't there a
>>> borrowed() too
>>> much now? In contrast to AddModule, ImportModule returns a new
>>> reference
>>> according to http://docs.python.org/api/importing.html
>>
>> Oh, duh ! (Why isn't Python written in a nicer and more convenient
>> language
>> that didn't require users to think about ref counting on each call ?!)
>>
>> Dave, Thomas,
>>
>> may I remove that extra python::borrowed in HEAD as well as
>> RC_1_34_0 ?
>
> Unless Dave objects, please go ahead
import is out of the tests for 1.34, so it's fine with me.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
Don't Miss BoostCon 2007! ==> http://www.boostcon.com
More information about the Cplusplus-sig
mailing list