{"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,"search_vec":"'0x00':27 '1.2.2':33 '3.6':36 'arbitrari':11 'binari':12 'byte':4,25,45 'byte-stuf':44 'cob':1,6 'communic':48 'communication-protocol':47 'consist':2 'current':31 'data':13 'delimit':24 'develop':37 'embed':50 'encod':10 'form':16 'implement':7 'infrequ':41 'minim':29 'occurr':20 'overhead':3,30 'protocol':49 'python':9,35 'releas':42 'remov':18 'serial':43 'specif':23 'stabl':39 'stuf':5,46 'support':34 'typic':26 'version':32","created_at":"2026-04-27T16:57:50.437785+00:00","updated_at":"2026-04-27T16:57:50.437785+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.2.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/cmcqueen/cobs-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/cobs/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}