Serafeim Mellos <f...@mellos.io> added the comment:

Ok, I understand your point about PyObject_New not initializing custom fields 
(although it looks like something is initializing the memory since it's not 
random, it's either 0x0 or 0x1).

However, if that's the expected behavior, it's not very clear why there's a 
difference between the default values when invoking the same commands in 
different ways or between different python versions, eg:

Python3.8
=========

Python 3.8.0a0 (heads/master-dirty:f98c1623ec, Nov  4 2018, 17:16:57) 
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import custom; custom.Custom()
weird pointer has value of: 0x0
<custom2.Custom object at 0x7f19fd456630>
>>> import custom;                
>>> custom.Custom()
weird pointer has value of: 0x1
deallocating weird pointer
<custom2.Custom object at 0x7f19fd4566f0>
>>> 
deallocating weird pointer
zsh: segmentation fault  ../cpython/python

Python 3.6
==========

Python 3.6.5 (default, Nov  4 2018, 18:20:36) 
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import custom; custom.Custom()
weird pointer has value of: 0x0
deallocating weird pointer
<custom2.Custom object at 0x7f3d627d6b40>
>>> import custom  
>>> custom.Custom()
weird pointer has value of: 0x0
deallocating weird pointer
<custom2.Custom object at 0x7f3d627d6b70>


Is there any discussions or documentation I can refer to, in order to better 
understand this behavior or why it was changed since python 3.7? 

Thanks!

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35160>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to