UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
yumdb corruption.
The error message and python stack trace is produced when updating packages using yum. This is due to the yum database having unexpected (corrupt) information.
Find the corrupt yum database entry with the command 'yumdb info' command. In this specific case the file that was inconsistent is for the 'samba-client' package:
# cat /var/lib/yum/yumdb/s/40adb37f6d058e193fd4af10beb86bff9b5ae44d-samba-client-3.5.8-74.fc14-x86_64/checksum_data gqmP ▒▒.,6▒▒▒MK)6▒rNUW▒*▒
Note: Running 'rpm --rebuilddb' does not fix this yum database corruption, as it is not an rpm issue.
Workaround
The yum database is a flat file database in the 'var/lib/yum/yumdb' directory. Use the yumdb command to manipulate the database. Force the database to resync the information from the rpm database for the given rpm.
If you have a modern yum-utils package then the workaround is as simple as:
# yumdb sync-force samba-client
However at the time of writing Fedora 14 doesn't support this feature (where asFedora 15 has 'yum-utils-1.1.30-2.fc15.noarch' which does). So provide a checksum file that has well formatted data (but not neccessarily valid data).
# cd /var/lib/yum/yumdb/s/40adb37f6d058e193fd4af10beb86bff9b5ae44d-samba-client-3.5.8-74.fc14-x86_64 # echo "invalid" | sha256sum > checksum_data
The next 'yum update' succeeded (Note: I left my shell in the yumdb directory and a backup of the corrupt file, which I would not do next time). Yum deleted the old database record entries and created a new directory for the new RPM. Because the sha256 sum didn't match that of the original RPM, or additional files were present the following message was output during the update:
Warning: RPMDB altered outside of yum.
I manually deleted the the '40adb37f6d058e193fd4af10beb86bff9b5ae44d-samba-client-3.5.8-74.fc14-x86_64' directory.
Links
Appendices
Error message
# yum update
Loaded plugins: fastestmirror, kmdl, langpacks, presto, refresh-packagekit
Adding en_US to language list
Loading mirror speeds from cached hostfile
updates/metalink | 2.9 kB 00:00
* fedora: ucmirror.canterbury.ac.nz
* updates: ucmirror.canterbury.ac.nz
atrpms | 3.5 kB 00:00
atrpms/primary_db | 655 kB 00:11
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package samba-client.x86_64 0:3.5.8-76.fc14 set to be updated
---> Package samba-common.x86_64 0:3.5.8-76.fc14 set to be updated
---> Package samba-winbind-clients.x86_64 0:3.5.8-76.fc14 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================
Package Arch Version Repository Size
=========================================================================================================
Updating:
samba-client x86_64 3.5.8-76.fc14 updates 11 M
samba-common x86_64 3.5.8-76.fc14 updates 13 M
samba-winbind-clients x86_64 3.5.8-76.fc14 updates 1.1 M
Transaction Summary
=========================================================================================================
Upgrade 3 Package(s)
Total size: 26 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
/usr/lib/python2.7/site-packages/yum/history.py:321: UnicodeWarning: Unicode equal comparison
failed to convert both arguments to Unicode - interpreting them as being unequal
if checksum == sql_checksum:
Traceback (most recent call last):
File "/usr/bin/yum", line 29, in <module>
yummain.user_main(sys.argv[1:], exit_code=True)
File "/usr/share/yum-cli/yummain.py", line 258, in user_main
errcode = main(args)
File "/usr/share/yum-cli/yummain.py", line 196, in main
return_code = base.doTransaction()
File "/usr/share/yum-cli/cli.py", line 544, in doTransaction
resultobject = self.runTransaction(cb=cb)
File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 1350, in runTransaction
self.skipped_packages, rpmdb_problems, cmdline)
File "/usr/lib/python2.7/site-packages/yum/history.py", line 494, in beg
pid = self.pkg2pid(txmbr.po)
File "/usr/lib/python2.7/site-packages/yum/history.py", line 352, in pkg2pid
return self._ipkg2pid(po)
File "/usr/lib/python2.7/site-packages/yum/history.py", line 349, in _ipkg2pid
return self._pkgtup2pid(po.pkgtup, csum)
File "/usr/lib/python2.7/site-packages/yum/history.py", line 332, in _pkgtup2pid
checksum))
File "/usr/lib/python2.7/site-packages/yum/sqlutils.py", line 168, in executeSQLQmark
return cursor.execute(query, params)
sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory
that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended
that you instead just switch your application to Unicode strings.
yumdb info
The corruption in the checksum_data can be seen for the samba-client package
# yumdb info 'samba*'
Loaded plugins: fastestmirror, kmdl, langpacks, presto, refresh-packagekit
Adding en_US to language list
samba-client-3.5.8-74.fc14.x86_64
changed_by = 501
checksum_data = gqmP
▒▒.,6▒▒▒MK)6▒rNUW▒*▒
checksum_type = sha256
command_line = update
from_repo = updates
from_repo_revision = 1301977831
from_repo_timestamp = 1301979362
installed_by = 4294967295
reason = user
releasever = 14
samba-common-3.5.8-74.fc14.x86_64
changed_by = 501
checksum_data = 782d850baa9ef452a7c4c913e70b77a7bfa23c0d7690977ecd7b4d8f27401f8f
checksum_type = sha256
command_line = update
from_repo = updates
from_repo_revision = 1301977831
from_repo_timestamp = 1301979362
installed_by = 4294967295
reason = dep
releasever = 14
samba-winbind-clients-3.5.8-74.fc14.x86_64
changed_by = 501
checksum_data = 46e6b0195fe1c28feff1eec96d437436fb0abccfe552d5fd57939f72321a4311
checksum_type = sha256
command_line = update
from_repo = updates
from_repo_revision = 1301977831
from_repo_timestamp = 1301979362
installed_by = 4294967295
reason = dep
releasever = 14
yumdb usage
The following usage information is provided from 'yum-utils-1.1.28-1.fc14.noarch':
Loaded plugins: fastestmirror, kmdl, langpacks, presto, refresh-packagekit
Adding en_US to language list
Usage: yumdb <command> ...
get <key> [pkg-wildcard]...
set <key> <value> [pkg-wildcard]...
del <key> [pkg-wildcard]...
rename <key> <key> [pkg-wildcard]...
rename-force <key> <key> [pkg-wildcard]...
copy <key> <key> [pkg-wildcard]...
search <key> <wildcard>...
exist? <key> [pkg-wildcard]...
unset? <key> [pkg-wildcard]...
info [pkg-wildcard]...
shell [filename]...
Options:
--version show program's version number and exit
-h, --help show this help message and exit
--noplugins disable yum plugin support
-c CONFFILE, --config=CONFFILE
config file location

