Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-22 Thread dieter
dl l writes: > I understood call PyGC_collect to release object cycles. But in my python > test code, seems there is NO reference cycle on the Simple object in the > python test code. Why needs to call PyGC_Collect() here? > >

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-21 Thread dl l
I understood call PyGC_collect to release object cycles. But in my python test code, seems there is NO reference cycle on the Simple object in the python test code. Why needs to call PyGC_Collect() here? = class Simple: def __init__(

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread dieter
dl l writes: > I found the problem is resolved if call PyGC_Collect() after > PyDict_DelItemString(). Is it expected to call PyGC_Collect() here for > Python 3.5 which is not needed for Python 3.3? Usually, Python uses reference counting to determine when an object can be

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread dl l
Thank you all for the help. I found the problem is resolved if call PyGC_Collect() after PyDict_DelItemString(). Is it expected to call PyGC_Collect() here for Python 3.5 which is not needed for Python 3.3? 2016-09-20 16:01 GMT+08:00 Chris Angelico : > On Tue, Sep 20, 2016 at

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread Chris Angelico
On Tue, Sep 20, 2016 at 4:19 PM, dl l wrote: > Yes, it's a workaround to set the global variables to None. But My app just > provide a framework for my customers to run python scripts. That's means > the workaround requires my customers to update their python scripts. That >

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread Steven D'Aprano
On Tuesday 20 September 2016 16:19, dl l wrote: > Hi Steven, > > Thanks for reply. > > I logged bug https://bugs.python.org/issue28202. I added more info in this > bug :). > > Yes, it's a workaround to set the global variables to None. But My app just > provide a framework for my customers to

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread dl l
Hi Steven, Thanks for reply. I logged bug https://bugs.python.org/issue28202. I added more info in this bug :). Yes, it's a workaround to set the global variables to None. But My app just provide a framework for my customers to run python scripts. That's means the workaround requires my

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-19 Thread Steven D'Aprano
On Monday 19 September 2016 16:47, dl l wrote: > Hi, > > I have a app loading python35.dll. Use python API PyImport_AddModule > to run a py file. And use PyDict_DelItemString to delete the module. > There is a global vailable in the py file. The global variable is not > destroyed when calling

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-19 Thread dl l
Thanks for the replay. I run this script as __main__ module, this module is removed from sys.modules, and the ref count becomes 0. 2016-09-20 0:00 GMT+08:00 Chris Angelico : > On Mon, Sep 19, 2016 at 4:47 PM, dl l wrote: > > I have a app loading

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-19 Thread Chris Angelico
On Mon, Sep 19, 2016 at 4:47 PM, dl l wrote: > I have a app loading python35.dll. Use python API PyImport_AddModule > to run a py file. And use PyDict_DelItemString to delete the module. > There is a global vailable in the py file. The global variable is not > destroyed when

Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-19 Thread dl l
Hi, I have a app loading python35.dll. Use python API PyImport_AddModule to run a py file. And use PyDict_DelItemString to delete the module. There is a global vailable in the py file. The global variable is not destroyed when calling PyDict_DelItemString to delete the module. That cause the

[issue28202] Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-18 Thread Jack Liu
New submission from Jack Liu: 0 down vote favorite I have a app loading python35.dll. Use python API PyImport_AddModule to run a py file. And use PyDict_DelItemString to delete the module. There is a global vailable in the py file. The global variable is not destroyed when calling