{"id":21051,"library":"cobs","title":"cobs","description":"Consistent Overhead Byte Stuffing (COBS) implementation for Python. Encodes arbitrary binary data into a form that removes any occurrence of a specific delimiter byte (typically 0x00), with minimal overhead. Current version 1.2.2 supports Python >=3.6. Development is stable with infrequent releases.","status":"active","version":"1.2.2","language":"python","source_language":"en","source_url":"https://github.com/cmcqueen/cobs-python","tags":["serialization","byte-stuffing","communication-protocols","embedded"],"install":[{"cmd":"pip install cobs","lang":"bash","label":"Latest stable"}],"dependencies":[],"imports":[{"note":"cobs package has submodules; 'import cobs' only imports the package, not the cobs.encode/decode functions.","wrong":"import cobs","symbol":"cobs","correct":"import cobs.cobs as cobs"},{"note":"cobsr is a submodule; use 'cobs.cobsr' for clarity.","wrong":"from cobs import cobsr","symbol":"cobsr","correct":"import cobs.cobsr as cobsr"}],"quickstart":{"code":"import cobs.cobs as cobs\n\ndata = b'\\x00\\x01\\x02\\x00\\x03'\nencoded = cobs.encode(data)\nprint('Encoded:', list(encoded))\n\ndecoded = cobs.decode(encoded)\nprint('Decoded:', list(decoded))","lang":"python","description":"Encode and decode data using COBS. The delimiter byte (0x00) is removed from the encoded output."},"warnings":[{"fix":"Use cobs.cobs for compatibility unless you specifically need reduced overhead.","message":"COBSR (reducing overhead variant) module cobs.cobsr is less tested and may have edge cases.","severity":"deprecated","affected_versions":"all"},{"fix":"encoded = cobs.encode(data) + b'\\x00'","message":"The encode() function does NOT add a trailing delimiter byte. You must add it yourself if your protocol expects it.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure your encoded data does not include delimiter bytes (except the optional trailing delimiter).","message":"The decode() function expects the encoded data to NOT contain the delimiter byte (except possibly the final byte). Incorrectly encoded data may raise ValueError.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change to 'import cobs.cobs as cobs' or 'from cobs import cobs'","cause":"Imported cobs package instead of cobs.cobs submodule.","error":"AttributeError: module 'cobs' has no attribute 'encode'"},{"fix":"Ensure you pass properly COBS-encoded data. Use cobs.encode() to encode before transmission.","cause":"Encoded data includes a delimiter byte (0x00) that is not the final byte, or the decoder was given raw data.","error":"ValueError: decoded data contains unexpected zero byte"},{"fix":"Check for empty decoded output if protocol expects non-empty data.","cause":"A single 0x00 byte decodes to an empty byte string (valid COBS). This might be unexpected.","error":"cobs.decode() returns empty bytes when input contains only a trailing zero"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}