"""
Consistent Overhead Byte Stuffing (COBS) encoding and decoding.

Functions are provided for encoding and decoding according to
the basic COBS method.

The COBS variant "Zero Pair Elimination" (ZPE) is not
implemented.

A C extension implementation only is provided.

References:
    http://www.stuartcheshire.org/papers/COBSforSIGCOMM/
    http://www.stuartcheshire.org/papers/COBSforToN.pdf
"""

from cobs._cobsext import *
_using_extension = True

@@ -222,49 +222,169 @@
 %0A%0AA 
-C extension implementation only is provid
+pure Python implementation and a C extension implementation%0Aare provided. If the C extension is not available for some reason,%0Athe pure Python version will be us
 ed.%0A
@@ -514,16 +514,25 @@
 df%0A%22%22%22%0A%0A
+try:%0A    
 from cob
@@ -551,16 +551,20 @@
 mport *%0A
+    
 _using_e
@@ -579,8 +579,88 @@
  = True%0A
+except ImportError:%0A    from cobs._cobspy import *%0A    _using_extension = False%0A

Change Python 2.x import to fall-back to pure Python code if it can't load the C extension.