Comments (11)
Original comment by alex (Bitbucket: alexssb, GitHub: Unknown):
Six not solve the problem below, which causes the test fails
Python 3.4 (Linux)
https://github.com/eduardtomasek/lz-string-python/blob/master/test.py#L9
Python 2.7 (Linux) - * Compatibility using six. *
https://github.com/alexsilva/lz-string-python/blob/master/test.py#L11
s = six.u('Žluťoučký kůň úpěl ďábelské ódy!')
Only works in both cases, when I use the u prefix 'u'
u'Žluťoučký kůň úpěl ďábelské ódy!'
from six.
Original comment by Wouter Bolsterlee (Bitbucket: wbolster, GitHub: wbolster):
@bfschott the file encoding is irrelevant here, and doesn't change whether string literals are bytes/text.
from six.
The best thing to do is to use Python 2 and 3.3+ and use the syntactic
u
prefix.
from six.
Original comment by bfschott (Bitbucket: bfschott, GitHub: Unknown):
I'm hitting this is a third party library:
#!python
return six.u('')
Just realized, of course, that the file is utf-8:
#!python
# -*- coding: utf-8 -*-
Not exactly sure what the proper portable way is to return a unicode literal in a return is with python. I can't do u'', just ''?
from six.
Yes, you want something like Django's smart_unicode
.
from six.
Original comment by Alexander Lukanin (Bitbucket: alexanderlukanin13, GitHub: alexanderlukanin13):
You are misusing six.u
. It should only be used for string literals. It's not a make-unicode-out-of-anything magic function.
from six.
Original comment by James Cleveland (Bitbucket: radiosilence, GitHub: radiosilence):
Exactly - sometimes it's difficult to make sure that a string is ascii, especially when user data etc. are involved.
from six.
Original comment by Vladimir Protasov (Bitbucket: eoranged, GitHub: eoranged):
@gutworth, It's common thing in Python 2 that function result in some conditions is str and on the other is unicode instance, so the call
result = six.u(json.dumps(data, **json_params))
may fail with
TypeError: decoding Unicode is not supported
if someone will pass ensure_ascii=False
in json_params
.
from six.
I don't understand. If 3rd-party libraries are doing six.u(u'mystring')
, they have a bug.
from six.
Original comment by James Cleveland (Bitbucket: radiosilence, GitHub: radiosilence):
If you're using third party libraries, it's kind of a pain due to having to fork them and whatnot. Would this change actually break anything?
It's kind of interesting that this works fine:
unicode(u'hi')
Whereas this breaks:
unicode(u'hi', 'unicode_escape')
Any ideas why?
from six.
Er, how hard is it to just not pass unicode literals?
from six.
Related Issues (20)
- six urlib urlopen faces certificate has expired error HOT 1
- Implement find_spec() for _SixMetaPathImporter
- 1.15.0: pytest warnings HOT 2
- Please make a new release with the py3.10 fixes
- bad magic number in 'six' HOT 4
- What version of collections_abc is supported? HOT 2
- Different versions of packages (geckodriver) can be installed on linux and windows
- can i use six just like run command on cmd like six filename.py? HOT 1
- ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
- RuntimeError: restricted attribute setting __doc__ when being imported in python2.7 in a restricted frame
- Module MD5 could be moved to hashlib.md5? HOT 1
- Python:3.11 failing to install six (pip version: 22.3.1)
- Version 1.16.0 vulnerable to OS Command Injection
- Failure when using six.with_metaclass in python 2.7 when metaclass doesn't directly inherit from type
- SIX new version HOT 4
- six.reraise fails
- repr(six.moves) throws an AttributeError for cpython 3.12 HOT 4
- Why name the tool six ? six = 2x3 ? HOT 2
- Undefined reference to unicode
- Getting Code Vulnerability in "six.py" module file HOT 11
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 six.