Created a "file" like command in python (see man 4 magic) and face a showstoper bug

Thomas Mangin thomas.mangin at
Mon Jun 3 15:13:50 EDT 2002


I wrote some code perform "file" like operation and I am facing a
nasty bug.

the files can be found at :

It produce the same output that "file":

# ./ core
core: ELF 32-bit LSB core file of 'vi' (signal 11), Intel 80386,
version 1 (SYSV)

# ./ jpg_good.jpg
jpg_good.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI),
50 x 50

# ./ jpg_bad.jpg
jpg_bad.jpg: JPEG image data, EXIF standard %d.73, 10752 x 2048

Note the %d !

The code causing problem is :

if replace:
    mime = mime % replace

In both case mime is containing the string "%d." and replace is in
both case of type int and valued 1 and 0.

Any idea ?

Thomas Mangin

More information about the Python-list mailing list