Modify

Opened 9 years ago

Closed 9 years ago

#2794 closed Patches (invalid)

boost::python::handle constructor problem

Reported by: Rick Yang <rick68@…> Owned by: Dave Abrahams
Milestone: Boost 1.39.0 Component: python USE GITHUB
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:

Description

Hi,

I tried my test code:

#include <iostream>                                                                               
                                                                                                  
#include <boost/cstdlib.hpp>                                                                      
                                                                                                  
#include <boost/python/refcount.hpp>                                                              
#include <boost/python/handle.hpp>                                                                
                                                                                                  
int main(void)                                                                                    
{                                                                                                 
    using boost::python::allow_null;                                                              
    using boost::python::handle;                                                                  
                                                                                                  
    Py_Initialize();                                                                              
                                                                                                  
    PyObject* py_int = PyInt_FromLong(68);                                                        
                                                                                                  
    std::cout << "py_int->ob_refcnt = ["                                                          
        << py_int->ob_refcnt << ']' << std::endl;                                                 
                                                                                                  
                                                                                                  
    {                                                                                             
        handle<PyObject> h1(allow_null(py_int));                                                  
        handle<PyObject> h2(py_int);                                                              
    }                                                                                             
    std::cout << "py_int->ob_refcnt = ["                                                          
        << py_int->ob_refcnt << ']' << std::endl;                                                 
                                                                                                  
    boost::python::decref(py_int);                                                                
    Py_Finalize();                                                                                
                                                                                                  
                                                                                                  
    return boost::exit_success;                                                                   
}

and this is my result:

py_int->ob_refcnt = [9]
py_int->ob_refcnt = [7]

the reference counter not keep to1 9.

Attachments (0)

Change History (1)

comment:1 Changed 9 years ago by Rick Yang <rick68@…>

Resolution: invalid
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Dave Abrahams.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.