473,412 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

a bug when developing extension module with boost.python

1. We need a trace class CLog like:
....
CLog()<<"err msg"<<"anything you like"<<endl;
....

2. A programmer's design:
CLog:public ostringstream{
~CLog()
{
cout<<str().c_str()<<endl;
}
}
It crashes when python use this module. The key point is that in
CLog's destructor str().c_str() is kind of rubbish data.

3. Another programmer's design:
CLog:public ostringstream{
template<typename T>
ostream& operator<<(T &userdefined)
{
return _temp<<userdefined<<endl;
}

~CLog()
{
cout<<str().c_str()<<endl;
}

private:
ostringstream _temp;
}

This version works well.

3. My quesition
how could solution in .2 fail?

I have googled and got nothing helpful

BTW:
My development environment is

Win2000Pro
VC6 SP5
VC7.1
Python2.3(windows)
Jul 18 '05 #1
0 883

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gouda Man | last post by:
I'm planning to write a large program that will have advanced scripting in python in which the scripter will subclass c++ objects to add functionality. this leads me to boost.python (if you dont...
1
by: Craig Ringer | last post by:
Hi folks I'm a bit of a newbie here, though I've tried to appropriately research this issue before posting. I've found a lot of questions, a few answers that don't really answer quite what I'm...
0
by: Mark English | last post by:
Basic problem: If there is a C-extension module in a package and it tries to import another python module in the same package without using the fully qualified path, the import fails. Config:...
10
by: Java and Swing | last post by:
I need to write an extension for a C function so that I can call it from python. C code (myapp.c) ====== typedef unsigned long MY_LONG; char *DoStuff(char *input, MY_LONG *x) { ... } so...
12
by: Laszlo Zsolt Nagy | last post by:
Hello, I would like to develop a new network protocol, where the server and the clients are Python programs. I think to be effective, I need to use TCP_NODELAY, and manually buffered transfers....
0
by: Peter Bienstman | last post by:
Hi, I'm having some problems with scripts using Python extension modules compiled using mingw. * Some of them work fine if I run them from a command prompt. However, if I double click on...
3
by: Bo Peng | last post by:
Dear list, I have been using mingw to build a python extension module. I had to jump through a number of hooks like the _ctype problem caused by the use of msvcr71.dll, but the module was mostly...
0
by: MarkE | last post by:
I'm just getting started on Boost Python and may have missed this obvious looking problem somewhere. Given a c-extension "testext" written using Boost Python containing a base class "Base", a...
2
by: Robert Dailey | last post by:
Hi, I'm currently using boost::python::import() to import Python modules, so I'm not sure exactly which Python API function it is calling to import these files. I posted to the Boost.Python...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.