<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><pre>&gt;<i> Hi Roman,<br></i>&gt;<i> What do you mean by &quot;the code generated by Py++ just works&quot;?  Do you mean
<br></i>&gt;<i> you created a class<br></i>&gt;<i> MyClass {<br></i>&gt;<i> public:<br></i>&gt;<i>    MyClass(char const*) ;<br></i>&gt;<i> }<br></i>&gt;<i> and you had successfully initialized it in Python?  I tried a similar
<br></i>&gt;<i> example class and had no problem with it.<br></i><br>That what you described :-).<br><br>&gt;<i> The real problem  I had was with this specific class NiString in Gamebryo<br></i>&gt;<i> game engine, is it possible that something
<br></i>&gt;<i> going on inside Gamebryo might cause the problem?  Or the game engine is<br></i>&gt;<i> irrelevant to this problem?<br></i><br>I think that NiString is relevant. Take a look on this FAQ:<br><a href="http://www.boost.org/libs/python/doc/v2/faq.html#custom_string">
http://www.boost.org/libs/python/doc/v2/faq.html#custom_string</a></pre></blockquote><div>Hi Roman, <br>Thanks for you suggestions. <br>I looked into the custom_string code, it is a nice example but different with my problem.&nbsp; I don't want python automatically convert my NiFixedString to python string, all I want is a way to use the constructor of NiFixedString class to create a python object.&nbsp; 
<br>&nbsp;a = NiFixedString(&quot;test&quot;)<br><br>Theoretically this is no different than wrapping any other class with a constructor that takes a string/char const*, and this code should do it, right? <br>BOOST_PYTHON_MODULE(NiStringTest)
<br>{&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; class_&lt;NiFixedString,boost::noncopyable&gt;(&quot;pNiFixedString&quot;, init&lt;char const*&gt;()); <br>}<br><br>Btw, NiFixedString encapsulates a memory efficient implementation of reference-counted 
ASCII strings, here is the header file, is there any thing that potentially cause the exception?&nbsp; Also, from my understanding, PY++ simplifies the process of generating the wrapper code, could adopting PY++ possibly help with this problem? 
<br><br>#ifndef NIFIXEDSTRINGTABLE_H<br>#define NIFIXEDSTRINGTABLE_H<br><br>#include &quot;NiRTLib.h&quot;<br>#include &quot;NiGlobalStringTable.h&quot;<br>#include &quot;NiPath.h&quot;<br><br>class NIMAIN_ENTRY NiFixedString : public NiMemObject
<br>{<br>public:<br>&nbsp;&nbsp;&nbsp; NiFixedString();<br>&nbsp;&nbsp;&nbsp; NiFixedString(const char* pcString);<br>&nbsp;&nbsp;&nbsp; NiFixedString(const NiFixedString&amp; kString);<br>&nbsp;&nbsp;&nbsp; ~NiFixedString();<br><br>&nbsp;&nbsp;&nbsp; operator const char*() const;<br><br>&nbsp;&nbsp;&nbsp; bool Exists() const;
<br><br>&nbsp;&nbsp;&nbsp; NiFixedString&amp; operator=(const NiFixedString&amp; kString);<br>&nbsp;&nbsp;&nbsp; NiFixedString&amp; operator=(const char* pcString);<br><br>&nbsp;&nbsp;&nbsp; size_t GetLength() const;<br>&nbsp;&nbsp;&nbsp; unsigned int GetRefCount() const;<br><br>&nbsp;&nbsp;&nbsp; bool Equals(const char* pcStr) const;
<br>&nbsp;&nbsp;&nbsp; bool EqualsNoCase(const char* pcStr) const;<br><br>&nbsp;&nbsp;&nbsp; bool Contains(const char* pcStr) const;<br>&nbsp;&nbsp;&nbsp; bool ContainsNoCase(const char* pcStr) const;<br><br>&nbsp;&nbsp;&nbsp; friend bool operator==(const NiFixedString&amp; s1, const NiFixedString&amp; s2);
<br>&nbsp;&nbsp;&nbsp; friend bool operator!=(const NiFixedString&amp; s1, const NiFixedString&amp; s2);<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; friend bool operator==(const NiFixedString&amp; s1, const char* s2);<br>&nbsp;&nbsp;&nbsp; friend bool operator!=(const NiFixedString&amp; s1, const char* s2);
<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; friend bool operator==(const char* s1, const NiFixedString&amp; s2);<br>&nbsp;&nbsp;&nbsp; friend bool operator!=(const char* s1, const NiFixedString&amp; s2);<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; // Begin Emergent internal use only<br>&nbsp;&nbsp;&nbsp; // End Emergent internal use only
<br>protected:<br>&nbsp;&nbsp;&nbsp; NiGlobalStringTable::GlobalStringHandle m_kHandle;<br>};<br><br>NIMAIN_ENTRY void NiStandardizeFilePath(NiFixedString&amp; kString);<br><br>#include &quot;NiFixedString.inl&quot;<br><br>#endif<br><br>
Excerpt from NifixedString.inl<br><br>inline NiFixedString::NiFixedString(const char* pcString)<br>{<br>&nbsp;&nbsp;&nbsp; if (pcString == NULL)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_kHandle = NiGlobalStringTable::NULL_STRING;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_kHandle = NiGlobalStringTable::AddString(pcString);<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br><br><br><br><br><br><br><br>&nbsp;<br>&nbsp;</div><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<pre>&gt;<i> And still, what the &quot;unidentifiable C++ exception&quot; is really saying?<br></i><br>Boost.Python has next code:<br><br>try{<br>    run you C++ code<br>}<br>catch( registered exceptions ){<br>     convert them to Python exception
<br>}<br>catch( ... ){<br>    throw Python RuntimeError( &quot;unidentifiable C++ exception&quot; )<br>}<br><br>So or you forgot to register your exception or ... something really<br>bad happened.</pre></blockquote><div><br>
<br><br></div><br>