yum reports bad marshal data

I’ve been trying to check for updates on one of my CentOS machines using yum and got the following error.
root:~# yum upgrade
Loading “installonlyn” plugin
Options Error: bad marshal data


Having tried various things like removing the yum cache (/var/cache/yum), I finally found a forum post that hinted at Python versions being the culprit, and another one that suggested verifying the yum rpm.
root:~# rpm -V yum
..5….. /usr/lib/python2.4/site-packages/yum/sqlitesack.pyc
One of the last things I updated was sqlite, and even though I’ve never used Python (so take this explanation with a pinch of salt) it sounds like the updated version of sqlite had broken the compiled python module that yum uses.
The fix was easy.. simply remove the .pyc file and next time you run yum it will be recompiled.
root:~# rm /usr/lib/python2.4/site-packages/yum/sqlitesack.pyc
It worked for me but obviously your mileage may vary.