Python 2.4.4 vs. 2.3.6

2006-12-27 Thread sndive
My top priority is stability of the interpreter. With that in mind which version should I get: 2.4.4, 2.3.6 or something else. I will be using gcc 2.3.2(x86), 3.3(arm) and 3.4.3(arm) to cross compile it depending on the (embedded) platform. Thank you. -- http://mail.python.org/mailman/listinfo/

Minor problem with configure (2.4.4)

2006-12-28 Thread sndive
configure expands AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001) to #define _POSIX_C_SOURCE 200112L that causes problems because _POSIX_C_SOURCE is defined by system headers and I get hideous warnings during compilation. I tried to fix it by adding

how to print a traceback?

2007-10-15 Thread sndive
i'm struggling to get some proxy code working with liburl[2] and want to print some tracebacks in my class ProxyHTTPConnection::request(). do i have to force an exception and print a backtrace in catch or can i just print the current stack? print_tb takes an argument and short of forcing an excepti

Re: Python Interview Questions

2007-10-30 Thread sndive
Krypto wrote: > Hi, > > I have used Python for a couple of projects last year and I found it > extremely useful. I could write two middle size projects in 2-3 months > (part time). Right now I am a bit rusty and trying to catch up again > with Python. > > I am now appearing for Job Interviews thes

simple? embedding question

2007-10-30 Thread sndive
suppose i have imported two modules foo and bar with foo=PyImport_ImportModule("foo") and bar=PyImport_ImportModule("bar") respectively. Now suppose I have an artitrary python expression to evaluate. Do I need to parse that thring and check for foo. and bar. before jumping the usual PyModule_GetDi

Re: simple? embedding question

2007-10-30 Thread sndive
On Oct 30, 1:26 pm, Farshid Lashkari <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > suppose i have imported two modules foo and bar with > > foo=PyImport_ImportModule("foo") and bar=PyImport_ImportModule("bar") > > respectively. > > > Now suppose I have an artitrary python expression to

Re: simple? embedding question

2007-10-30 Thread sndive
On Oct 30, 6:47 pm, Farshid Lashkari <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > i switched to PyImport_ImportModuleEx per your suggestion but i still > > get > > > Traceback (most recent call last): > > File "", line 1, in ? > > NameError: name '__main__' is not defined > > > i tri

Re: why did these companies choose Tcl over Python

2007-10-30 Thread sndive
On Oct 30, 3:25 pm, chewie54 <[EMAIL PROTECTED]> wrote: > Hello, > > As an electronics engineer I use some very expensive EDA CAD tool > programs that are scriptable using Tcl. I was wondering why these > companies have choose to use Tcl instead of Python. Some of these > are: > >Mentor Grap

PyDict_*() refcount assumptions

2007-10-31 Thread sndive
i checked this: http://svn.python.org/projects/python/trunk/Doc/data/refcounts.dat and it seems that PyDict_SetItem incref the value being added and the key and PyDict_DelItem does not decrement any refcounts so i have to do so manually for the key and for the data( by calling PyDict_GetItem first

PyCheck for a classes defined in python and user data in PyObject_HEAD

2007-11-01 Thread sndive
q#1: in C I want to check if a given PyObject is a xml.dom.minidom.Node (or a derivative). how do i extract a PyTypeObject for such a class? issue #2 I'm in a situation when i don't really need to extend python with any classes of my own but i do have extra luggage for the python data structures s

Re: PyCheck for a classes defined in python and user data in PyObject_HEAD

2007-11-01 Thread sndive
On Nov 1, 4:14 pm, [EMAIL PROTECTED] wrote: > q#1: > in C I want to check if a given PyObject is a xml.dom.minidom.Node (or > a derivative). > how do i extract a PyTypeObject for such a class? nevermind, i found an instance object that will work for me as long as i figure out where is the document

What's the reverse of Py_BuildValue("u#" ?

2007-01-23 Thread sndive
How could I get the pointer to and the length of ucs2 array out of a PyObject representing a string? Something that works whether PyObject string is in unicode or not. Also could I replace a sequence if(PyBool_Check(obj)) { ... } if(PyString_Check(obj)) { // would this be true for any

How do I build python with debug info? (and python module load questions)

2007-01-25 Thread sndive
I want to step into PyImport_ImportModule("my_foo") that's failing despite the my_foo.py being in the current directory. (PyRun_SimpleFileEx works on the exact same file). How would I run configure to build libpython with -g? I wonder if I should just keep using PyRun_SimpleFileEx. I want to be a

Calling python function from C and import questions

2007-01-26 Thread sndive
Is there a better way to make a call from C than PyRun_SimpleString("import foo_in_python\nfoo_in_python.bar(whatever)\n"); ? I already imported the foo_in_python using PyImport_ImportModule and wonder why do I need to keep importing it every time I'm calling a python function in that module. I

instance as a sequence

2007-11-05 Thread sndive
suppose i want to make foo.childNodes[bar] available as foo[bar] (while still providing access to the printxml/printprettyxml() functions and other functionality of dom/minidom instance). What is a good way to accomplish that? -- http://mail.python.org/mailman/listinfo/python-list

Re: instance as a sequence

2007-11-05 Thread sndive
On Nov 5, 9:40 am, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Nov 5, 11:32 am, [EMAIL PROTECTED] wrote: > > > suppose i want to > > make foo.childNodes[bar] available as foo[bar] > > (while still providing access to the printxml/printprettyxml() > > functions > > and other functionality of dom/mi

is PyUnicode_Decode a part of public api

2007-11-05 Thread sndive
am i allowed to use PyUnicode_Decode or PyUnicode_DecodeUTF8 in my code or that is not advisable? QString s("foo"); // QString::unicode returns garbage unusable for PyUnicode_FromUnicode PyObject *uo = PyUnicode_Decode(s.utf8(), s.length(), "utf8", 0); -- http://mail.

supplemental data factory

2007-11-05 Thread sndive
i'm trying to import a module typeinfo that looks like so: import xml.dom import minidom var mapper = { minidom.Element.__class__ : "Element", minidom.Node.__class__ : "Node" }; then i'd write a factory method that's look roughly like this: addBaggage(PyObject *victim) { PyObject *typeinf

PyObject sanitizer (CPython 2.4.4)

2007-11-06 Thread sndive
I get this from valgrind (no suppression file but thgis probably is not covered by the suppressor anyway): ==6108== Invalid read of size 4 ==6108==at 0x48D19F4: lookdict_string (dictobject.c:359) ==6108==by 0x48D1B59: PyDict_GetItem (dictobject.c:554) ==6108==by 0x48B1657: instance_geta

private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack

2007-11-06 Thread sndive
i naively created execution context: PyObject *execcontext = PyDict_New(); stuffed a handle in it: PyObject *ih = PyCObject_FromVoidPtr(handle, NULL); int st= PyDict_SetItemString(res, "interp", ih); and later on in a function for a module that i defined expected to extract that handle

Re: private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack

2007-11-13 Thread sndive
On Nov 9, 5:36 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 06 Nov 2007 23:25:17 -0300, <[EMAIL PROTECTED]> escribió: > > > i naively created execution context: > > PyObject *execcontext = PyDict_New(); > > stuffed a handle in it: > > PyObject *ih = PyCObject_FromVoidPtr(han

Re: private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack

2007-11-13 Thread sndive
On Nov 13, 3:31 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Nov 13, 2007 3:18 PM, <[EMAIL PROTECTED]> wrote: > > > On Nov 9, 5:36 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > > En Tue, 06 Nov 2007 23:25:17 -0300, <[EMAIL PROTECTED]> escribió: > > > > One should make a lot of assum

Re: private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack

2007-11-13 Thread sndive
On Nov 9, 7:36 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 06 Nov 2007 23:25:17 -0300, <[EMAIL PROTECTED]> escribió: > > > i naively created execution context: > > PyObject *execcontext = PyDict_New(); > > stuffed a handle in it: > > PyObject *ih = PyCObject_FromVoidPtr(han

Re: private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack

2007-11-13 Thread sndive
On Nov 13, 3:31 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Nov 13, 2007 3:18 PM, <[EMAIL PROTECTED]> wrote: > > > On Nov 9, 5:36 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > > En Tue, 06 Nov 2007 23:25:17 -0300, <[EMAIL PROTECTED]> escribió: > > > > One should make a lot of assum

Re: private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack

2007-11-14 Thread sndive
On Nov 14, 12:57 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 13 Nov 2007 19:59:56 -0300, <[EMAIL PROTECTED]> escribió: > > > working on a smaller example. i could not get pyNode_root invoked yet > > and > > PyRun_String("import node\nprint node.root()\n", > > Py_fi

problem calling ElementTree._ElementInterface.find with PyObject_CallObject

2007-11-14 Thread sndive
I have a weid problem. If i do this: import elementtree.ElementTree as ET ... tree = ET.parse("whatever") root = tree.getroot() r = root.find('last') print r return root where last is not an immediate child of root node i get back None. However if i comment the r = root.find('la

no __len__ attribute in NodeList or the list base?

2007-11-14 Thread sndive
i extract class object from an instance of NodeList (minicompat.py) like so PyObject *pclass = PyObject_GetAttrString( nodelistinsance, "__class__"); but PyObject_GetAttrString(pclass, "__len__") returns NULL. i naively added __len__ = _get_length to NodeList but that ends up in endless r

Re: no __len__ attribute in NodeList or the list base?

2007-11-15 Thread sndive
On Nov 15, 3:09 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > i extract class object from an instance of NodeList (minicompat.py) > > like so > > PyObject *pclass = PyObject_GetAttrString( nodelistinsance, > > "__class__"); > > but > > PyObject_GetAttrString(pclass,

Re: PyCheck for a classes defined in python and user data in PyObject_HEAD

2007-11-15 Thread sndive
On Nov 1, 11:04 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 01 Nov 2007 22:13:35 -0300, <[EMAIL PROTECTED]> escribió: > > > On Nov 1, 4:14 pm, [EMAIL PROTECTED] wrote: > >> q#1: > >> in C I want to check if a given PyObject is a xml.dom.minidom.Node (or > >> a derivative). > >> how

Re: PyCheck for a classes defined in python and user data in PyObject_HEAD

2007-11-16 Thread sndive
On Nov 15, 10:00 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 16 Nov 2007 00:27:42 -0300, <[EMAIL PROTECTED]> escribió: > > > > > On Nov 1, 11:04 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > > wrote: > >> En Thu, 01 Nov 2007 22:13:35 -0300, <[EMAIL PROTECTED]> escribió: > >> >> I'm

getElementsByTagName in ElementTree

2007-11-19 Thread sndive
what's the equivalent of minidom's getElementsByTagName in ElementTree? -- http://mail.python.org/mailman/listinfo/python-list

Re: sockets: why doesn't my connect() block?

2007-11-19 Thread sndive
On Nov 17, 11:32 pm, 7stud <[EMAIL PROTECTED]> wrote: > According to "Python in a Nutshell(2nd)", p. 523: > > connect: s.connect((host, port)) > ... > Blocks until the server accepts or rejects the connection attempt. > > However, my client program ends immediately after the call to > connect()--

Re: PyObject_GetAttrString failing when getting a function pointer fr om PyObject* returned by Py_CompileString

2007-11-20 Thread sndive
On Nov 20, 3:27 am, "Borse, Ganesh" <[EMAIL PROTECTED]> wrote: > Hi, > > My following code is failing with an error of "isSizeSmall not function or > callable" > > //--- > char szExpr[2048]; > memset(szExpr,'\0',sizeof(szExpr)); > sprintf(szExpr,"def

twisted client.getPage threading safety

2007-11-21 Thread sndive
I found nothing better to do than to start a new thread from c and run twisted event loop there. my question is: how can i safely call client.getPage() from another thread? could i? i have compiled python without threading support and am wondering what the repercussions will be (i don't want to en

trouble selling twisted

2007-11-26 Thread sndive
i have a lot of trouble selling twisted a a client lib for network access (on embedded platform) the group i'm a member of wants to write some unmaintainable threaded blocking junk in c--. does anyone can give me an idea how many kilobytes extra would it take to have a pyqt linked in and a running

PyImport_ImportModule("foo.bar")

2007-12-06 Thread sndive
I'm trying to import foo.bar in order not to add every single directory with python files to the search path. i immediately follow the import with the PyModule_AddObject call to put the imported module to __main__ module but later on PyEval_EvalCode on Py_CompileString compiled code "foo.bar.baz()

xpath and current python xml libraries

2007-12-10 Thread sndive
PyXML seems to be long gone. Is lxml the way to go if i want to have xpath supported? -- http://mail.python.org/mailman/listinfo/python-list