skillfed

morphys

Smart conversions between unicode and bytes types for common cases

morphys v1.0 196.6K downloads/30d#9,779 on PyPI1
Permissive license MIT Abandoned released

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 morphys

uv

uv add morphys

poetry

poetry add morphys

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 2.7Programming Language :: Python :: 3Topic :: Utilities

Tags

unicode bytes conversionstring type coercionensure bytes unicodepython 2 string handlingsmart string conversionbytes unicode wrapperencoding decoding utilities
python-2-legacystring-handling

More Utilities packages