[File] Question regarding python bytecode mimetypes

Steve Grubb sgrubb at redhat.com
Wed Oct 14 18:02:23 UTC 2020


Hello,

On Wednesday, October 14, 2020 3:15:07 AM EDT Mircea GLIGA wrote:
> I'm reiterating my question here, is this correct behavior?
> For me, considering bytecode as text is a bug and should be fixed.

I think you are right. Back in Feb I reported this issue:
https://mailman.astron.com/pipermail/file/2020-February/000272.html

But I suggested application rather than text since these are compiled. I'm 
guessing it's just a typo.

Best Regards,
-Steve


> On 7/31/20 11:16 AM, Mircea GLIGA wrote:
> > Hello all
> > 
> > I've been debugging a script which tries to identify text files based on
> > their mimetypes in order to do some text replacements.[1]
> > This used to work in the past and now, on a Manjaro machine with
> > `file-5.39` the script incorrectly identifies Python byte code files,
> > *.pyc, as textfiles. So after a text replacement they are rendered
> > useless.
> > 
> > It seems it's related to this commit:
> > https://github.com/file/file/commit/eb373e431ccfeedfbcf497e4da07571d43bdb
> > 9f2
> > 
> > My question is why are byte code files considered of type "text"?
> > In the end, they are binary files, not text files.
> > Is this considered normal behavior? Or a bug?
> > 
> > Comparing the output of two different `file` versions:
> >      $ file --version
> >      file-5.39
> >      $ file -b --mime-type numbers.pyc
> >      text/x-bytecode.python
> > 
> > On a Debian machine:
> >      $ file --version
> >      file-5.35
> >      magic file from /etc/magic:/usr/share/misc/magic
> >      $ file -b --mime-type numbers.pyc
> >      application/octet-stream
> > 
> > Thanks and regards
> > Mircea
> > 
> > [1]
> > https://git.buildroot.net/buildroot/tree/support/misc/relocate-sdk.sh?h=2
> > 020.02.4#n39






More information about the File mailing list