Giter Club home page Giter Club logo

Comments (4)

benhoyt avatar benhoyt commented on June 2, 2024

Thanks for the report. It looks like in the main scandir code in the CPython repo this is now handled with a preprocessor if/else. See lines 491-501 here:

#ifdef MS_WINDOWS
#  define STAT win32_stat
#  define LSTAT win32_lstat
#  define FSTAT _Py_fstat_noraise
#  define STRUCT_STAT struct _Py_stat_struct
#else
#  define STAT stat
#  define LSTAT lstat
#  define FSTAT fstat
#  define STRUCT_STAT struct stat
#endif

You'd be welcome to submit a PR if you'd like. Seeing scandir is now included in Python 3.x itself, I personally don't have time/motivation to work on this repo much anymore. Either way, I'll leave this open for visibility.

from scandir.

cielavenir avatar cielavenir commented on June 2, 2024

I can see that MS_WINDOWS's _Py_stat_struct definition can be seen from python source code, not 3rdparty modules, so maybe redefining is better

from scandir.

cielavenir avatar cielavenir commented on June 2, 2024

attempted. (our company started Py3 migration this year~~)

from scandir.

benhoyt avatar benhoyt commented on June 2, 2024

@cielavenir, thanks for the PR, and I'll take a look at that separately. However, wouldn't a simpler way to address this in your Python 3 codebase be to just use scandir from the Python 3 stdlib? (It's been in the stdlib since as os.scandir since Python 3.5.)

If you still need Python 2 and Python 3 compatibility, you can do:

try:
    from os import scandir
except ImportError:
    from scandir import scandir   # fallback for Python < 3.5

from scandir.

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.