Code Monkey home page Code Monkey logo

Comments (7)

pooriazmn avatar pooriazmn commented on June 11, 2024 1

Hi @ferstar,
Although this fix addresses this specific issue, not all file-like objects inherit from io.BufferedIOBase; for instance, all file-like objects used in Django.

We have been using this package for a long time to determine uploaded file types, but after upgrading to version 1.1.0, we received the same TypeError. As a workaround, we just read the first 262 bytes and pass them to the guess function and after the new version is released, we can just pass the underlying file object. However, it will be just a specific workaround for django.

Can I ask about the reasoning behind this commit? Since the try clause didn't seek to the start position, I can see that it could introduce unexpected side-effects, but isn't it more useful to check if the object has read, tell, and seek attributes instead of checking inheritance from io.BufferedIOBase?

Thanks

from filetype.py.

hugo-azevedo avatar hugo-azevedo commented on June 11, 2024 1

Hi @ferstar and @h2non
Any idea when we can expect a release to pypi of this fix?
Many thanks

from filetype.py.

h2non avatar h2non commented on June 11, 2024 1

It should be working on v1.2.0, now available on PyPI:
https://pypi.org/project/filetype/

from filetype.py.

ferstar avatar ferstar commented on June 11, 2024

@jams2 I have fix this in fix: restore reader position after retrieving signature bytes

But it seems we need @h2non to push the latest code to pypi

from filetype.py.

jams2 avatar jams2 commented on June 11, 2024

@ferstar that's great, thanks. Looking forward to the release.

from filetype.py.

ferstar avatar ferstar commented on June 11, 2024

@pooriazmn Thanks for pointing this out. Attribute judgment for read/seek/tell should be a better choice to be compatible with more object types. I have fixed it.

from filetype.py.

hugo-azevedo avatar hugo-azevedo commented on June 11, 2024

Thanks for pushing it into PyPI, @h2non ! It works perfectly. Cheers

from filetype.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.