Re: attaching debugger to runinng python program
You may try winpdb. I find it to be a comfortable debugger that also can attach to running programs. (You need to add a line in your code where the program should stop and wait for the debugger to attach.) I am satisfied with it, but I did not debug a multi theaded app. However, it can handle threads. I'd be glad to later hear whether it did what you need, or not: http://www.digitalpeers.com/pythondebugger/threads.htm Regards, Ruben -- http://mail.python.org/mailman/listinfo/python-list
AdaptionFailure: How to use Interfaces with PyProtocols ?
Hi, I tried to understand the docs of Peak's PyProtocols, and failed. I use PyProtocols v0.93 final. I fetched the ...tar.gz file for Linux and installed it using the setup.py. Here's my Hello-World-like example, that defines a Duck, which "implements" the given Interface: from protocols import Interface,adapt,advise class Quackable(Interface): def quack(loudness): """ print how loud to quack """ class Duck: advise(instancesProvide=[Quackable,]) def quack(self, loudness): print "quack! %s loud"%(loudness) if __name__ == "__main__": d = adapt(Duck, Quackable) # this line raises the failure d.quack(3) But it does not work that way. It get this "AdaptionFailure" : File "...interfaces.py", line 14, in ? d = adapt(Duck, Quackable) File "C:\cygwin\home\pje\PyProtocols\src/protocols/_speedups.pyx", line 199, in _speedups.adapt File "C:\cygwin\home\pje\PyProtocols\src/protocols/_speedups.pyx", line 188, in _speedups._adapt protocols.adapters.AdaptationFailure: ("Can't adapt", , ) *** Or is my Duck code wrong ? Anybody knowing how to use an Interface ? Thank you very much- Nebur Remark:There seems to be some windows stuff in PyProtocols ("C:\...") - a bug ? (I re-installed PyProtocols with option --without-speedups but nothing changed.) -- http://mail.python.org/mailman/listinfo/python-list
Re: AdaptionFailure: How to use Interfaces with PyProtocols ?
Yes, I adapted the instance, and it's working.That's it. Thank you ! Nebur -- http://mail.python.org/mailman/listinfo/python-list
How can an Exception pass over an "except" clause ?
I'm using the contract.py library, running Python 2.4.4. Now I'm confronted with the following exception backtrace: (...) File "/usr/lib/python2.4/site-packages/contract.py", line 1265, in _check_preconditions p = f.__assert_pre AttributeError: 'function' object has no attribute '__assert_pre' For my surprise, I found that the code of contract.py around line 1265 looks like: 1264: try: 1265: p = f.__assert_pre 1266: except AttributeError: 1267: pass I'd expect line 1267 to "swallow" the AttributeError siliently. But the application stops with the above backtrace. Someone familiar enough with the Python innards ? How can one manage that an "except" seems to be ignored ? Ruben -- http://mail.python.org/mailman/listinfo/python-list
Re: How can an Exception pass over an "except" clause ?
> However by being *VERY* perverse, I was able to reproduce the above > error by overwriting AttributeError with some other exception class (say > SyntaxError): > AttributeError = SyntaxError > Then your code will be will produce a real AttributeError, but miss it > because (despite the spelling) it checks for a SyntaxError, Yes ... this would be some kind of criminal joke > > Question... I don't know what contract.py is, but could it be doing > something that *bad*? No. I've searched the source for "AttributeError" and it appears only in except clauses. contracty.py is a library that adds Eiffel-like "design-by- contract" (DBC) to Python. Precisely, I can add preconditions (and postconditions) about the arguments into the methods docstring. These are checked at runtime (and appear in the epydoc docu.) This is a great thing I never want to miss anymore (and it was working fine for some months now.) (See http://www.wayforward.net/pycontract/ ) When the problem appears, contract.py is doing a pre-condition check. > You could check py printing AttributeError and see what it really is. > In my case it's: > >>> print AttributeError > exceptions.SyntaxError > > Gary Herron > > P.S.: Anyone who does this kind of thing is a danger to society. May > their finger fall off before they get a chance to distribute such a program. :-) @Tijs: I think when re-raising, the backtrace will always point to the line where it was re-raised but not to line 1265. (Or can we re-raise an exception so that it preserves the backtrace of the "original" exception?) --- I'm speculating about there's a misleading backtrace. Maybe another exception happens, but somehow using the obsolete exc_info of the last exception (the AttributeError). I remember about some way to clear the exc_info, maybe this must be added into contract.py? I'll find it out, or a debugger session this night will help (I'll post again) Ruben -- http://mail.python.org/mailman/listinfo/python-list
Re: How can an Exception pass over an "except" clause ?
> > @Tijs: I think when re-raising, the backtrace will always point to the > line where it was re-raised but not to line 1265. (Or can we re-raise > an exception so that it preserves the backtrace of the "original" > exception?) @Tijs: Because of distrusting my own text above, I've checked re- raising ... and indeed, you've been right. "raise" does _not_ produce a new backtrace but uses the old one. Learned something new about Python now... I think that clearifies all the "magic" behaviour. Thank you, Ruben -- http://mail.python.org/mailman/listinfo/python-list
Pydev/Eclipse: How to add filters for the navigator ?
Running the latest version of pydev (1.3.13). I failed to figure out how to add a filter that excludes stuff like *.pyc from the file navigator. The "Filters..." dialogue allows to "Select All" and "Deselect All", but from an empty list :-( What's the trick ? Thanks ... -- http://mail.python.org/mailman/listinfo/python-list
Re: redirecting stdout/err to mysql table
I've had a similar requiredment and made a small tool for direct logging into databases (see: http://sourceforge.net/projects/rrlog/ ) It's origins are somewhat older than the Python 2.3 standard logging framework, so it can be used without that (but can also be simply integrated with it.) It even does some more than you currently need (log rotation and remote logging). Ratsberg -- http://mail.python.org/mailman/listinfo/python-list
Importer / module loader for filelike objects produces ugly stacktraces
I've made an importer (experimental status) to load python modules from archives, especially from AES encrypted ones. ( http://sourceforge.net/projects/py-archimporter ) I've followed the PEP 302 recipe (http://www.python.org/dev/peps/ pep-0302/). The loader does set each modules __file__ attribute to a meaningful string, similar to a real file name. Still, any stacktrace of the application looks like that: (...) File "", line 1530, in File "", line 225, in __init__ File "", line 423, in _ (...) Filenames are "" all over. Does someone know what am importer has to do for better tracebacks ? Ruben -- http://mail.python.org/mailman/listinfo/python-list
*.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ?
Hi folks developing with Pydev/Eclipse, this is the second time in about half a year that the following surprise bites me: I've switched between some files in Pydev/Eclipse using the FileNavigator, and when I want to go back to my last-edited *.py file, it is missing. No more in the FileNavigator, no more in the OpenFiles-List of the Editor. Removed anywhere. Erased from the file system. Restorable from the version control only. Only a young orphan *.pyc file is sitting around, showing me I haven't dreamed of editing the file two minutes before. I'm sure I did no delete operations with eclipse, and I'm sure I did not use another application than eclipse in the meantime. No, I can't reproduce it, and I don't know whom to blame (Pydev? Eclipse ? The File System ? A Virus that only 2 times in half a year deletes a single file I'm busy working with, and seems to do nothing else? Myself beeing schizophrenic ??) Someone else already had this effect ? Nebur PS: Debian Etch 64Bit/JFS,Eclipse3.3,Pydev1.3.14. -- http://mail.python.org/mailman/listinfo/python-list
Re: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ?
> Are you using svn? I did have a problem once related to that (but it's Hi Fabio, No, there's no version control plugin. I use Mercurial, but externally only. I've considered a problem with version control, too. But all external reasons (file sytem, virus, version control) seem unplausible because when simply removing the file from file system, Eclipse would complain about the missing ressource. So I have 2 ideas only: A _very_ strange bug inside the Eclipse/Plugin process, or something with my brain ;-) Nebur -- http://mail.python.org/mailman/listinfo/python-list
Re: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ?
Yes. Linux viruses are rare but useful :-) Well, I don't think the problem a very dangerous one. The Pydev/ Eclipse was used for much more than a year nearly daily and intensively. The strange effect is very rare,obviously (plus the chance that it's in my brain, as I mentioned ;-D ) so you probably can lean back. Anyway, I'd be glad to get an even faint idea of the problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ?
> So, just wanted to point out that eclipse saves your file history > (even if you do not have a vcs)... that operation can be selected by > right clicking a parent folder and selecting 'restore from local > history'. Fabio, you are right; this feature should help to compensate ... but in my case, the Eclipse said "No deleted ressources in local history for selected container". I'm not familiar with the Local-History feature (since using a vcs), so it may be misconfigured. (The setting in Preferences/Workspace/ LocalHistore are at default: 7 days to keep files, 50 maximum entries per file, max.file size 1MB - which should be enough. ). Hm. Anyway, I don't see any idea how to track down what happened. So lets close the thread and simply continue working. * This is a good occasion to state that Pydev/Eclipse still is a very efficient IDE in my opinion, and (aside from this mystery here) it is perfectly stable for >>1 year now! This must be said, to correct any potential misimpression. Ciao, Nebur -- http://mail.python.org/mailman/listinfo/python-list
Re: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ?
> Implement what? The virus? I haven't said that I'm interested in virus, > I meant I'd like to know WHAT is this No, this was a misunderstanding. What we meant was: when you want to implement a virus, you should use a version control :- D Nebur -- http://mail.python.org/mailman/listinfo/python-list
PEP 343 == small-sized aspect orientation ?
I started learning PEP 343 , and it made me feel unsure how much I really comprehend. Can somebody explain which benefit it provides, compared with usual Aspect Orientation ? The latter looks more generic to me (and doesn't need the "with" keyword). Do I miss something apparent ? Nebur -- http://mail.python.org/mailman/listinfo/python-list
Re: DBHandler class for logging?
With a similar requirement, I made a small logging tool (usable as handler) which logs into nearly every DB (including Postgres - thanks to the SQLAlchemy library.) It has BSD license. You may use it (or parts of the code): http://www.reifenberg.de/rrlog/ (It does some more things you may not need, like rotation handling.) Regards, Nebur -- http://mail.python.org/mailman/listinfo/python-list