2008-10-10 13:39:08

PyException P-p-p-p-panic

Python as a programming language features exceptions, as most modern languages do nowadays. However, since it is Python, these exceptions of course have to be named slightly differently from the way it is done everywhere else.

Usually, exceptions are thrown using throw new Exception(); and the construction to catch them is usually:

try {
    RunSomeCode();
}
catch (SomeException se)
{
    HandleErrorInSomeWay(se);
}

In Python, the construct does not deviate all that much logically, but the terminology is entirely different. Instead of throwing exceptions, Python raises them like signals (raise SomeException()). Also, they are not caught but excepted:

try:
    RunSomeCode()
except SomeException, se:
    HandleErrorInSomeWay(se)

Funnily, the indentation varies between the version. If a finally is added in Python 2.4, it cannot coexist in the same indentation level with except:

>>> try:
...     raise Exception()
... except:
...     print('Ugh')
... finally:
File "<stdin>", line 5
 finally:
SyntaxError: invalid syntax

This is of course fixed in Python 2.5, but since large amounts of wide-spread Python applications such as Zope still depend on Python 2.4, compatibility is a rather delicate problem here.

Moreover, however, exceptions don't seem to work stably even in the latest versions of Python. I have experienced various cases where Python would simply segfault when an exception is thrown:

$ python __init__.py
2008-10-10 13:34:25,572│__init__.py[37]: INFO: Initializing communication server
Segmentation fault (core dumped)
$

The corresponding code:

log.info("Initializing communication server")
try:
    (some code)
except Exception, e: # This is where the core dump occurrs
    log.critical('unable to unregister original servant')

One has to wonder how to handle this case from within Python; probably not at all. All one can do is to guess what the problem was and try to fix it.


Posted by Tonnerre Lombard | Permanent link | File under: broken

2008-10-09 12:06:00

Partial results are valid but processing is subverted

People keep wondering why I changed to git-svn as a subversion client, even though I tend to dislike git. The answer is simple: it is the only usable Subversion client.

Hearing the protests in my ears already, I think I'll simply paste some of the sessions I recently had with Subversions “svn” client. All of these appear to occur regularly.

Of course, the proper procedure would be to debug these, but after a short visit to the code I had to decide that I should concentrate on getting my work done rather than to fix this bunch of, well, code.

svn update me to fail

$ svn up
U src/toolbox/peersarray.py
svn: In directory 'src/toolbox/pypath'
svn: Error processing command 'delete-entry' in 'src/toolbox/pypath'
svn: Can't read directory 'src/toolbox/pypath/idl/.svn/tmp': Partial results are valid but processing is incomplete
Segmentation fault (core dumped)
$ svn up
svn: Working copy '.' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
Segmentation fault (core dumped)
$ svn cleanup
svn: Can't read directory 'tests/t/.svn/tmp': Partial results are valid but processing is incomplete
Segmentation fault (core dumped)
$

More svn update woes

$ svn up
svn: Directory 'src/toolbox/trunk/idl/.svn' containing working copy admin area is missing
$

svn check this out!

$ svn co svn+ssh://… test
A test/testfile
Segmentation fault (core dumped)
$ cd test
$ svn cleanup
svn: Can't read directory '.svn/tmp': Partial results are valid but processing is incomplete
Segmentation fault (core dumped)
$

One has to wonder how these people actually get any work done.


Posted by Tonnerre Lombard | Permanent link | File under: broken

2008-10-09 11:58:34

Helpless MySQL

Trying to set up a MySQL instance to test a backup script against, I encountered a nice endless social engineering loop:

mysql> help contents

Nothing found
Please try to run 'help contents' for a list of all accessible topics

mysql>

Funnily, this fits nicely with the commercial support I'm used to from MySQL A/B.


Posted by Tonnerre Lombard | Permanent link | File under: broken

2008-10-04 01:14:57

courier-authlib: how not to use libtool

Due to security issues with the old version, I upgraded courier-authlib to version 0.61.0. In the course of the upgrade, I discovered a number of library related weirdlesses, though.

The symptom was that /usr/pksrc/lib/courier-authlib/libcourierauth.so.0 was a symlink on libcourier.auth.so rather than the other way around. Closer inspection of the Makefile showed that evidently someone had a very weird understanding of libtool.

The .la rules all contianed the flag -avoid-version, removing the .0.0 version suffix from the library version. However, it seems that the authors nevertheless wanted these suffixes, so they re-added them using the for loop:

for f in $(pkglib_LTLIBRARIES); do . $$f; rm -f $(DESTDIR)$(pkglibdir)/$$dlname.0 $(DESTDIR)$(pkglibdir)/$$dlname.0.0; ln -s $$dlname $(DESTDIR)$(pkglibdir)/$$dlname.0; done

This line reads every .la file as a shell script and tries to symlink the unversioned library to the versioned one, since the addition of -avoid-version prevents libtool --mode=install from taking care of the symlinks themselves. Even worse, on some platforms these versioned files should not even exist. It only ever works by pure chance.

This is just one of the countless ways people found to abuse libtool in horrible ways to break portability. It seems that the funniest part about libtool is the number of ways in which people don't understand it.


Posted by Tonnerre Lombard | Permanent link | File under: programming

2008-09-21 14:30:36

bouml is behind on NetBSD

On their web site, bouml claims that NetBSD lags behind significantly, having bouml 2.27 packaged.

bouml web site screenshot

This is wrong in two ways. Firstly, NetBSD does not have any packages at all, packages for NetBSD are usually created through the OS independent pkgsrc tree, which, while being developed by the NetBSD foundation, is not especially related to NetBSD.

But more than this, having a short look at pkgsrc reveals the following:

$ pwd
/usr/pkgsrc/devel/bouml
$ make show-var VARNAME=PKGNAME
bouml-4.5
$

Evidently, the bouml site is lagging behind significantly? If so, maybe the two sleeping smileys on the site mean just that.

Audit trail

  • 04 Oct 2008 01:20:05: The bouml site has been updated in that respect with the release of bouml 4.6.1, which will however only ship in pkgsrc after the 2008Q3 branch.

Posted by Tonnerre Lombard | Permanent link | File under: programming