unicode_mayo
unicode_mayo is the mayo in your unicode sandwich. In your development environment, use it as a wrapper around unicode and byte strings to see if they’re accidentally coming in to contact with byte strings. This can help catch unicode encode/decode errors before they happen in production!
unicode_mayo includes two classes: UnicodeSafetyWrapper and BytestringSafetyWrapper. The former is meant to envelope unicode strings, and warns when they come into contact with byte strings; the latter is meant for byte strings, and warns when it comes into contact with unicode. Place these in strategic places (likely in development environments only), like gettext() or all strings from your database.
Installation
Installation via pip:
pip install unicode_mayo
Usage
Something like:
>>> import unicode_mayo
>>> wrapped = unicode_mayo.UnicodeSafetyWrapper(u'safety at last!')
>>> wrapped.encode('utf-8')
'safety at last!'
>>> wrapped + u' woohoo!'
u'safety at last! woohoo!'
>>> wrapped + 'evil bytestring'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/eyalr/personal_work/unicode_mayo/src/unicode_mayo/__init__.py", line 55, in __add__
_fail_on_bytes(other)
File "/Users/eyalr/personal_work/unicode_mayo/src/unicode_mayo/__init__.py", line 90, in _fail_on_bytes
_fail_on_bytes_helper(other)
File "/Users/eyalr/personal_work/unicode_mayo/src/unicode_mayo/__init__.py", line 81, in _fail_on_bytes_helper
'Attempted string formatting without decoding utf-8'
TypeError: Attempted string formatting without decoding utf-8
Metadata
Release files for unicode-mayo 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| unicode_mayo-1.1.0.tar.gz | 3.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| unicode_mayo-1.1.0-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 8.9 kB
Release files / unicode_mayo-1.1.0.tar.gz
| Download URL | unicode_mayo-1.1.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
deb67db1a4d12d634cb21a939f39383b17160fd37ff4cf86075abb24a2578e27
|
|
BLAKE2b-256 checksum How to use checksums |
583f7f00da918abf8003bc52c3bc0301a4c80cd7d216f10ae4468466131ae3c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16
|
Release files / unicode_mayo-1.1.0-py2-none-any.whl
| Download URL | unicode_mayo-1.1.0-py2-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
46f009fbfc50d6b358eb32f249b0ec3f77bf2f5eff70f396cbb60f06f1934ec9
|
|
BLAKE2b-256 checksum How to use checksums |
183f687ee07dc3f980a2b300250ee831d12842c3a715f378234ecf27788cd7a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16
|
Security for unicode-mayo 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.