morphys
Smart conversions between unicode and bytes types for common cases
What it is and what it does
Morphys is a lightweight utility library for handling the inconsistency between unicode and bytes types in Python 2, where non-ASCII characters can cause unexpected errors. It provides two main conversion functions—ensure_bytes() and ensure_unicode()—that intelligently convert between types only when necessary, and a StrMorpher class that wraps a string to behave as either type on demand. The library also supports custom encodings and defaults to utf-8.
While the package remains compatible with Python 3, it has received no maintenance since 2017-01-10 and was designed primarily for Python 2's unicode/bytes complexity, making it largely obsolete for new projects.
Use it for:
- Normalize inconsistent string types from libraries that return either bytes or unicode unpredictably
- Handle legacy codebases that mix unicode and bytes strings without explicit type checking
- Wrap strings in StrMorpher when code needs to accept both bytes and unicode interchangeably
- Ensure consistent string type handling before passing data to functions with strict type requirements
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Morphys provides utility functions to convert between unicode and bytes types, handling encoding/decoding transparently and returning objects unchanged if already the correct type.
No. The package is abandoned (last update 2017-01-06) and designed primarily for Python 2. While it has no known vulnerabilities and installs easily, modern Python 3 projects have no practical need for this library. Only consider it for maintaining legacy Python 2 codebases.
Install
morphys on PyPI
pip
pip install morphysuv
uv add morphyspoetry
poetry add morphysInstalling morphys
Before you install
Installation is frictionless with no runtime dependencies. However, the package has been abandoned since its single release with no updates since 2017-01-06, making it unsuitable for active projects.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions, suitable for both open-source and proprietary projects.
Quickstart
pip install morphys
from morphys import ensure_bytes, ensure_unicode
result = ensure_unicode(b'hello')
result = ensure_bytes('hello')
Verify before relying
- Whether ensure_bytes and ensure_unicode handle all edge cases with non-ASCII content reliably
- Whether StrMorpher's lazy conversion approach works correctly across all contexts
- Current compatibility with modern Python 3 versions beyond the unspecified support claim
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 3,503 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 196,578/month — #9,779 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: morphys-1.0-py2.py3-none-any.whl
Keywords: string, unicode, bytes, conversion
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
mbstrdecoderDecodes multi-byte character strings by…
permissive · top 5,000 on PyPI
anyasciiConverts Unicode text to ASCII-only equivalents…
permissive · top 5,000 on PyPI
ftfyDetects and fixes mojibake (garbled Unicode…
permissive · top 5,000 on PyPI
UnidecodeConverts Unicode text to ASCII-safe…
copyleft · top 1,000 on PyPI
latexcodecProvides a Python codec to convert between…
permissive · top 5,000 on PyPI
binapyBinaPy wraps Python's binary-handling libraries…
permissive · top 5,000 on PyPI
unicodecsvDrop-in replacement for Python 2.7's csv module…
permissive · top 5,000 on PyPI
confusablesDetects and matches words that appear identical…
permissive · top 15,000 on PyPI
dicttoxmlConverts Python dictionaries and other native…
copyleft · top 5,000 on PyPI