Git Product home page Git Product logo

Comments (6)

pfmoore avatar pfmoore commented on July 21, 2024

There was a big thread about precisely this on pypa-dev. I went with the recommendation people made there, although I can't say I fully followed all of the points made. The thread is at https://groups.google.com/d/topic/pypa-dev/0PkjVpcxTzQ/discussion and Carl's post that recommended not importing is at https://groups.google.com/d/msg/pypa-dev/0PkjVpcxTzQ/lHp1C9KuayMJ

from sampleproject.

jcjf avatar jcjf commented on July 21, 2024

Is it necessarily the case that init.py will be Latin-1 encoded? The version string itself will be Latin-1 nonetheless.

from sampleproject.

pfmoore avatar pfmoore commented on July 21, 2024

No, but who cares? Latin-1 will ensure no decoding errors, and the version string line will be findable.

This is a classic case of "don't want to care about encoding". We could look for the encoding token in the file, but that's unnecessarily hard. We could assume ASCII or UTF8, but that runs the risk of failing if we guessed wrong. Probably better would be using ascii, errors="surrogateescape", but that's Python 3 only.

Practicality beats purity and all that.

from sampleproject.

pfmoore avatar pfmoore commented on July 21, 2024

BTW, that's what the comment "Open in Latin-1 so that we avoid encoding errors." was intended to convey. If you can suggest better wording (without turning it into an essay, that chunk of code is too long for what it does already :-() then that'd be great.

from sampleproject.

jcjf avatar jcjf commented on July 21, 2024

Thanks for clarifying and the little Python lesson, it makes sense now. The comment describing the intention of the code confused me a little.

I haven't really had to workaround encoding problems as my native language is English. I've always just added .encode('utf-8') or decode('utf-8') in Python 3 as needed.

from sampleproject.

qwcode avatar qwcode commented on July 21, 2024

I added a link to the pypa discussion in the comment above find_version

from sampleproject.

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.