Comments (6)
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.
Is it necessarily the case that init.py will be Latin-1 encoded? The version string itself will be Latin-1 nonetheless.
from sampleproject.
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.
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.
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.
I added a link to the pypa discussion in the comment above find_version
from sampleproject.
Related Issues (20)
- packet queue is empty, aborting HOT 2
- How do you test this? HOT 2
- Tools
- How to include non python configuration files HOT 1
- How to control spelling incorrection even if phonetically sound same HOT 1
- pyproject.toml: references a "python_requires" key that does not exist HOT 2
- help! Executing file is not working HOT 2
- sampleproject doesn't include files `setup.py` and `setup.cfg` (and maybe other) one of the latest published guides claims it should have HOT 1
- Unclear description of "readme" field in pyproject.toml HOT 2
- The package name HOT 3
- TypeError: unhashable type: 'dict' HOT 4
- Should development dependencies be included in the optional section?
- Error in documentation regarding Packaging and Distributing projects using Setuptools
- Stop advertising adding `wheel` as an unconditional PEP 517 build dependency HOT 6
- Should PyPUG editors have access to this project? HOT 3
- Remove Python version 3.7 to unblock tests HOT 1
- Update tox version? And tox best practices? HOT 2
- Sample build breaks if LICENSE.txt file contains GPL2 license text (containing 0x0c) HOT 13
- Flake8 configuration should not use select
- pyproject.toml file don't mention anything about the compatible platforms allowed by Wheel?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sampleproject.