<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 31 December 2016 at 08:24, Masayuki YAMAMOTO <span dir="ltr"><<a href="mailto:ma3yuki.8mamo10@gmail.com" target="_blank">ma3yuki.8mamo10@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I have read the discussion and I'm sure that use structure as Py_tss_t instead of platform-specific data type. Just as Steve said that Py_tss_t should be genuinely treated as an opaque type, the key state checking should provide macros or inline functions with name like PyThread_tss_is_created. Well, I'd resolve the specification a bit more :)<br><br>If PyThread_tss_create is called with the created key, it is no-op but which the function should succeed or fail? In my opinion, It is better to return a failure because it is a high possibility that the code is incorrect for multiple callings of PyThread_tss_create for One key.<br></div></div></blockquote><div><br></div><div>That's not what we currently do for the EnsureGIL autoTLS key and the tracemalloc key though - the reentrant key creation is part of "create-if-needed" flows where the key creation is silently skipped if the key already exists.<br><br>Changing that would require some further research into how we ended up with the current approach, while carrying it over into the new API design would be the default option.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>In this opinion PyThread_tss_is_created should return a value as follows:<br>(A) False while from after defining with Py_tss_NEED_INIT to before calling PyThread_tss_create<br>(B) True after calling PyThread_tss_create succeeded<br>(C) Unchanging before and after calling PyThread_tss_create failed<br>(D) False after calling PyThread_tss_delete regardless of timing<br>(E) For other functions, the return value of PyThread_tss_is_created does not change before and after calling<br><br>I think that it is better to write a test about the state of the Py_tss_t.<br></div></div></blockquote><div><br></div></div>I agree it would be good to add more test cases for this scenario to the test suite.<br><br></div><div class="gmail_extra">Cheers,<br></div><div class="gmail_extra">Nick.<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>   |   Brisbane, Australia</div>
</div></div>