This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author YannickSchmetz
Recipients YannickSchmetz
Date 2019-12-20.12:33:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576845195.58.0.163622932603.issue39109@roundup.psfhosted.org>
In-reply-to
Content
Python version: 3.5
Tested with VS Studio 2017 in an C-API extension.

When you have a UTF-8 encoded char buffer which is filled with a 0 or empty, and you youse the PyUnicode_FromString() method on this buffer, you will get a PyObject*. The content looks good, but the refence counter looks strange. 

In case of an 0 as char in the buffer, the ob_refcnt Field is set to 100 and in case of an empty buffer, the ob_refcnt Field is set to something around 9xx. 

Example Code: 
      string s1 = u8"";
      string s2 = u8"0";

      PyObject *o1 = PyUnicode_FromString(s1.c_str());
      //o1->ob_refcnt = 9xx
      PyObject *o2 = PyUnicode_FromString(s2.c_str());
      //o2->ob_refcnt = 100

I think the ob_refcnt Field should be 1 in both cases. Or why is the refcnt here so high?
History
Date User Action Args
2019-12-20 12:33:15YannickSchmetzsetrecipients: + YannickSchmetz
2019-12-20 12:33:15YannickSchmetzsetmessageid: <1576845195.58.0.163622932603.issue39109@roundup.psfhosted.org>
2019-12-20 12:33:15YannickSchmetzlinkissue39109 messages
2019-12-20 12:33:15YannickSchmetzcreate