Python script mime type is text/x-java !

Bug #518769 reported by Stéphane Brunner
28
This bug affects 4 people
Affects Status Importance Assigned to Milestone
file (Debian)
Fix Released
Unknown
file (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: file

I have a Python script file named oa2osm.py.

I do on it :
$ file oa2osm.py
oa2osm.py: python script text executable
$ file --mime-type oa2osm.py
oa2osm.py: text/x-java

Than it seem that the mime type is missing for python script !

Revision history for this message
Stéphane Brunner (stephane-brunner) wrote :

I think that the line :

!:mime text/x-python

is missing next to the line :

0 string/b #!\ /usr/bin/python python script text executable

in the file /usr/share/file/magic

Lars Ljung (larslj)
Changed in file (Ubuntu):
status: New → Confirmed
Revision history for this message
JustDevZero (justdevzero) wrote :

This still happen on Ubuntu Lucid LTS 10.04
Linux Desktop 2.6.32-24-generic #43-Ubuntu SMP Thu Sep 16 14:17:33 UTC 2010 i686 GNU/Linux

Kenyon Ralph (kralph)
summary: - Python scrypt mime type is text/x-java !
+ Python script mime type is text/x-java !
Changed in file (Debian):
status: Unknown → New
Revision history for this message
Hibou57 (Yannick Duchêne) (yannick-duchene) wrote :

Same for me on Ubuntu Maverick and file-5.03

Revision history for this message
Hibou57 (Yannick Duchêne) (yannick-duchene) wrote :

The workaround suggested in post #1 does not solve the bug.

Further more, this is not just about MIME type of Python files.

ex.
> $ file -b --mime-type JavaScript.js
> text/x-c++

Silly. The file command should not be used at all, it's not reliable.

Revision history for this message
Hibou57 (Yannick Duchêne) (yannick-duchene) wrote :

Workaround which really works.

Use `xdg-mime query filetype FILE_PATH` instead of `file -b --mime-type FILE_PATH`. But you have to ensure you've installed gvfs-bin for it to work, because there is also a bug in xdg-mime, which makes it not working if gvfs-bin is not installed.

See also : http://us.generation-nt.com/answer/bug-618624-xdg-utils-xdg-mime-query-filetype-file-no-output-at-due-missing-recommends-help-202577262.html

Revision history for this message
Neal McBurnett (nealmcb) wrote :

When I checked a collection of python scripts with the "file -i" command, I got a mix of text/plain, text/x-java and a few text/x-python. Even text/x-c++. It isn't immediately evident what might be triggering that.

As noted in comment #5, "xdg-mime query filetype" worked, on all of them. But that doesn't support the "-f" option to read a list of filenames to be checked from a given file.

Revision history for this message
Ken Sharp (kennybobs) wrote :

Has this been sent upstream?
http://bugs.gw.com/view_all_bug_page.php

Changed in file (Debian):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.