Comments (8)
I suggest that we use unicode throughout and fail if something is not unicode and that we also run a CI test matrix covering Python 2 and 3.
from tools-python.
I think it is already supported. For instance, in examples/ write_tv.py
, we are opening the file using codec module with utf-8 encoding. So even if we write out.write(u'# Documenting Information\n\n')
instead of out.write('# Documenting Information\n\n')
in write_document() it will work.
from tools-python.
IIRC I was running into problems with Python 3, where str
is what is unicode
in Python 2. But I don't remember the details anymore.
from tools-python.
@sschuberth yes, str is unicode in Python3. str is Python3 bytes in Python2.
We want unicode throughout here with the right adapters to work on 2 and 3. Such as here: https://github.com/nexB/license-expression/blob/master/src/license_expression/__init__.py#L36
from tools-python.
@rtgdk The point here is to be unicode across the board. e.g. from __future__ import unicode_literals
should be used everywhere. No more u'xxx'
from tools-python.
@pombredanne My point was that codec module is taking care of unicode. Since in the examples/write_tv.py
we are using "utf-8" encoding, so even if we input a Python3 byte(Python2 str) , it is automatically encoded into unicode.
with codecs.open(target, mode='w', encoding='utf-8') as out:
try:
write_document(document, out)
But if the user didn't use codec.open
and used open
, this will not work. For that we can import unicode_literals
which will convert any str to unicode in Python 2 and won't affect str in Python3.
I'll open a PR for that. We can discuss the issue and improvements there.
from tools-python.
This has mostly been merged... but there is some tests that are still needed. In particular the rdf output seems to write bytes at least on Python 2 while the tv output writes happy unicode
from tools-python.
As we don't support Python 2 anymore, I believe this issue can be closed. Please speak up if it should be reopened.
from tools-python.
Related Issues (20)
- Exception not catched with LicenseRef- containing slash HOT 2
- Ugly error for nonexisting file HOT 1
- Valid SPDX cannot be converted from JSON to tag:value HOT 1
- Ugly error message when the JSON syntax is not correct HOT 1
- Question of generation SBOM HOT 3
- Be more lenient when parsing "true" and "false" in tag-value
- Adding NOASSERTION/NONE to DocumentRef in relationships as per the spdx v2.3 spec HOT 3
- Request for Handling Custom Licenses in Document and Package Validators HOT 6
- Converting valid JSON SPDX file to tag:value gives invalid SPDX
- would like to package - but the name is unsuitable HOT 1
- Slow for SBOMs with a large number of files + relationships HOT 1
- F
- Would like an option to omit files from graph
- `create_list_without_duplicates` Function Can be Sped Up By Using Set
- Incorrect cpe23Type validation? HOT 2
- Relationship with Package Section HOT 2
- Failed to convert spdx to xml with Annotation HOT 1
- Error while calling SPDX parse_file() API inside thread function
- Remove unused semantic_version module HOT 1
- Why use uritools instead of the standard library urllib? HOT 1
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 tools-python.