GithubHelp home page GithubHelp logo

qchateau / cbitstruct Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 5.0 86 KB

Faster C implementation of the bitstruct Python library

License: Mozilla Public License 2.0

C 55.95% Python 43.80% Shell 0.25%
c bitstruct python fast bit bitfield packing unpacking

cbitstruct's People

Contributors

eerimoq avatar markgras avatar qchateau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cbitstruct's Issues

Redefined "_POSIX_C_SOURCE" Error

I've ran into the following error when compiling the project from source:

In file included from /tmp/hlappimageci/appdirs/hl1001.AppDir/usr/include/python3.7m/Python.h:8:0,
                     from cbitstruct/_cbitstruct.c:8:
    /tmp/hlappimageci/appdirs/hl1001.AppDir/usr/include/python3.7m/pyconfig.h:1522:0: error: "_POSIX_C_SOURCE" redefined [-Werror]
     #define _POSIX_C_SOURCE 200809L
    
    In file included from /usr/include/aarch64-linux-gnu/bits/libc-header-start.h:33:0,
                     from /usr/include/limits.h:26,
                     from /usr/lib/gcc/aarch64-linux-gnu/7/include-fixed/limits.h:194,
                     from /usr/lib/gcc/aarch64-linux-gnu/7/include-fixed/syslimits.h:7,
                     from /usr/lib/gcc/aarch64-linux-gnu/7/include-fixed/limits.h:34,
                     from cbitstruct/_cbitstruct.c:1:
    /usr/include/features.h:294:0: note: this is the location of the previous definition
     # define _POSIX_C_SOURCE 199506L

The error can be resolved by shifting the order of the headers in cbitstruct/_cbitstruct.c, so that #include <Python.h> appears before #include <limits.h>.

limits.h will define _POSIX_C_SOURCE if it is left undefined, but will instead use the pre-defined value if there is one. A quick search about this leads me to believe it's a fairly common occurrence & that re-organizing the headers is the correct solution.

compile error with _PyFloat_Pack2 with 3.11

It seems as if these functions are now private (see python/cpython#91062)

For bitstruct there is eerimoq/bitstruct#26, is something similar needed for cbistruct? If so, I'm happy to supply a PR, but I'm otherwise not that familiar with the C-API.

Without this, I get the following error (on an M1 mac using python 3.11):

Obtaining file:///Users/arun/roots/cbitstruct
  Preparing metadata (setup.py) ... done
Installing collected packages: cbitstruct
  Attempting uninstall: cbitstruct
    Found existing installation: cbitstruct 1.0.7
    Can't uninstall 'cbitstruct'. No files were found to uninstall.
  Running setup.py develop for cbitstruct
    error: subprocess-exited-with-error
    
    × python setup.py develop did not run successfully.
    │ exit code: 1
    ╰─> [31 lines of output]
        running develop
        /opt/homebrew/lib/python3.11/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
          warnings.warn(
        /opt/homebrew/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
          warnings.warn(
        running egg_info
        writing cbitstruct.egg-info/PKG-INFO
        writing dependency_links to cbitstruct.egg-info/dependency_links.txt
        writing top-level names to cbitstruct.egg-info/top_level.txt
        reading manifest template 'MANIFEST.in'
        adding license file 'LICENSE.md'
        writing manifest file 'cbitstruct.egg-info/SOURCES.txt'
        running build_ext
        building 'cbitstruct._cbitstruct' extension
        clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -Icbitstruct/ -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c cbitstruct/_cbitstruct.c -o build/temp.macosx-13-arm64-cpython-311/cbitstruct/_cbitstruct.o -std=c11 -Wall -Werror -O3
        cbitstruct/_cbitstruct.c:502:17: error: implicit declaration of function '_PyFloat_Pack2' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        _PyFloat_Pack2(cv, el->raw, PY_LITTLE_ENDIAN);
                        ^
        cbitstruct/_cbitstruct.c:502:17: note: did you mean 'PyFloat_Pack2'?
        /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/include/python3.11/cpython/floatobject.h:15:17: note: 'PyFloat_Pack2' declared here
        PyAPI_FUNC(int) PyFloat_Pack2(double x, char *p, int le);
                        ^
        cbitstruct/_cbitstruct.c:578:29: error: implicit declaration of function '_PyFloat_Unpack2' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        double cv = _PyFloat_Unpack2(el->raw, PY_LITTLE_ENDIAN);
                                    ^
        cbitstruct/_cbitstruct.c:578:29: note: did you mean 'PyFloat_Unpack2'?
        /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/include/python3.11/cpython/floatobject.h:19:20: note: 'PyFloat_Unpack2' declared here
        PyAPI_FUNC(double) PyFloat_Unpack2(const char *p, int le);
                           ^
        2 errors generated.
        error: command '/opt/homebrew/opt/llvm@11/bin/clang' failed with exit code 1
        [end of output]
    

Nice job :P

How much faster then the Python implementation is it? Any drawbacks/limitations?

Support for Python 3.12 on pypi

Hi, first of all thanks for this project!

Since Python 3.12 has been released on Oct. 2nd, it would be great to have compatible wheels available on pypi.

Unfortunately, building from source doesn't seem to work (at least not with a simple pip install cbitstruct).

Minimal failing example (docker)

FROM python:3.12-bookworm
RUN pip install cbitstruct

When running docker build . it fails with following output:

> docker build .
[+] Building 5.6s (5/5) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                                                                                                   0.1s 
 => => transferring dockerfile: 97B                                                                                                                                                                                                                                                                                                                                                                                          0.0s 
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                                                                                                            0.1s 
 => => transferring context: 35B                                                                                                                                                                                                                                                                                                                                                                                             0.0s 
 => [internal] load metadata for docker.io/library/python:3.12-bookworm                                                                                                                                                                                                                                                                                                                                                      0.6s 
 => CACHED [1/2] FROM docker.io/library/python:3.12-bookworm@sha256:96ee161eee904771a713a7ee01bc0f9a67e01639e45c74df6ffe2535c4af3c72                                                                                                                                                                                                                                                                                         0.0s 
 => ERROR [2/2] RUN pip install cbitstruct                                                                                                                                                                                                                                                                                                                                                                                   4.9s 
------
 > [2/2] RUN pip install cbitstruct:
#5 3.047 Collecting cbitstruct
#5 3.149   Downloading cbitstruct-1.0.9.tar.gz (29 kB)
#5 3.169   Preparing metadata (setup.py): started
#5 3.700   Preparing metadata (setup.py): finished with status 'done'
#5 3.704 Building wheels for collected packages: cbitstruct
#5 3.705   Building wheel for cbitstruct (setup.py): started
#5 4.182   Building wheel for cbitstruct (setup.py): finished with status 'error'
#5 4.233   error: subprocess-exited-with-error
#5 4.233
#5 4.233   × python setup.py bdist_wheel did not run successfully.
#5 4.233   │ exit code: 1
#5 4.233   ╰─> [209 lines of output]
#5 4.233       running bdist_wheel
#5 4.233       running build
#5 4.233       running build_py
#5 4.233       creating build
#5 4.233       creating build/lib.linux-x86_64-cpython-312
#5 4.233       creating build/lib.linux-x86_64-cpython-312/cbitstruct
#5 4.233       copying cbitstruct/__init__.py -> build/lib.linux-x86_64-cpython-312/cbitstruct
#5 4.233       creating build/lib.linux-x86_64-cpython-312/cbitstruct/tests
#5 4.233       copying cbitstruct/tests/test_cornercase.py -> build/lib.linux-x86_64-cpython-312/cbitstruct/tests
#5 4.233       copying cbitstruct/tests/test_perf.py -> build/lib.linux-x86_64-cpython-312/cbitstruct/tests
#5 4.233       copying cbitstruct/tests/__init__.py -> build/lib.linux-x86_64-cpython-312/cbitstruct/tests
#5 4.233       copying cbitstruct/tests/test_bitstruct.py -> build/lib.linux-x86_64-cpython-312/cbitstruct/tests
#5 4.233       copying cbitstruct/tests/test_api.py -> build/lib.linux-x86_64-cpython-312/cbitstruct/tests
#5 4.233       copying cbitstruct/tests/test_against_bitstruct.py -> build/lib.linux-x86_64-cpython-312/cbitstruct/tests
#5 4.233       running build_ext
#5 4.233       building 'cbitstruct._cbitstruct' extension
#5 4.233       creating build/temp.linux-x86_64-cpython-312
#5 4.233       creating build/temp.linux-x86_64-cpython-312/cbitstruct
#5 4.233       gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -Icbitstruct/ -I/usr/local/include/python3.12 -c cbitstruct/_cbitstruct.c -o build/temp.linux-x86_64-cpython-312/cbitstruct/_cbitstruct.o -std=c11 -Wall -Werror -O3
#5 4.233       In file included from cbitstruct/_cbitstruct.c:833:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘CompiledFormat___init__’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:22:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233          22 |     static _PyArg_Parser _parser = {"s:CompiledFormat", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:22:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:22:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:22:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:22:57: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233          22 |     static _PyArg_Parser _parser = {"s:CompiledFormat", _keywords, 0};
#5 4.233             |                                                         ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:22:57: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘CompiledFormat_unpack’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:80:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233          80 |     static _PyArg_Parser _parser = {"y*:unpack", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:80:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:80:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:80:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:80:50: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233          80 |     static _PyArg_Parser _parser = {"y*:unpack", _keywords, 0};
#5 4.233             |                                                  ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:80:50: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘CompiledFormat_unpack_from’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:116:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         116 |     static _PyArg_Parser _parser = {"y*|n:unpack_from", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:116:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:116:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:116:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:116:57: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         116 |     static _PyArg_Parser _parser = {"y*|n:unpack_from", _keywords, 0};
#5 4.233             |                                                         ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:116:57: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘CompiledFormatDict___init__’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:154:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         154 |     static _PyArg_Parser _parser = {"sO:CompiledFormatDict", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:154:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:154:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:154:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:154:62: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         154 |     static _PyArg_Parser _parser = {"sO:CompiledFormatDict", _keywords, 0};
#5 4.233             |                                                              ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:154:62: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘CompiledFormatDict_pack’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:190:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         190 |     static _PyArg_Parser _parser = {"O:pack", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:190:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:190:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:190:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:190:47: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         190 |     static _PyArg_Parser _parser = {"O:pack", _keywords, 0};
#5 4.233             |                                               ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:190:47: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘CompiledFormatDict_pack_into’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:224:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         224 |     static _PyArg_Parser _parser = {"y*nO|$p:pack_into", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:224:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:224:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:224:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:224:58: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         224 |     static _PyArg_Parser _parser = {"y*nO|$p:pack_into", _keywords, 0};
#5 4.233             |                                                          ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:224:58: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘CompiledFormatDict_unpack’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:265:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         265 |     static _PyArg_Parser _parser = {"y*:unpack", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:265:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:265:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:265:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:265:50: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         265 |     static _PyArg_Parser _parser = {"y*:unpack", _keywords, 0};
#5 4.233             |                                                  ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:265:50: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘CompiledFormatDict_unpack_from’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:303:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         303 |     static _PyArg_Parser _parser = {"y*|n:unpack_from", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:303:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:303:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:303:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:303:57: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         303 |     static _PyArg_Parser _parser = {"y*|n:unpack_from", _keywords, 0};
#5 4.233             |                                                         ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:303:57: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘pack_dict’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:342:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         342 |     static _PyArg_Parser _parser = {"sOO:pack_dict", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:342:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:342:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:342:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:342:54: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         342 |     static _PyArg_Parser _parser = {"sOO:pack_dict", _keywords, 0};
#5 4.233             |                                                      ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:342:54: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘pack_into_dict’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:379:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         379 |     static _PyArg_Parser _parser = {"sOy*nO|$p:pack_into_dict", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:379:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:379:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:379:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:379:65: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         379 |     static _PyArg_Parser _parser = {"sOy*nO|$p:pack_into_dict", _keywords, 0};
#5 4.233             |                                                                 ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:379:65: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘unpack’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:419:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         419 |     static _PyArg_Parser _parser = {"sy*:unpack", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:419:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:419:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:419:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:419:51: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         419 |     static _PyArg_Parser _parser = {"sy*:unpack", _keywords, 0};
#5 4.233             |                                                   ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:419:51: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘unpack_from’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:458:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         458 |     static _PyArg_Parser _parser = {"sy*|n:unpack_from", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:458:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:458:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:458:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:458:58: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         458 |     static _PyArg_Parser _parser = {"sy*|n:unpack_from", _keywords, 0};
#5 4.233             |                                                          ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:458:58: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘unpack_dict’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:498:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         498 |     static _PyArg_Parser _parser = {"sOy*:unpack_dict", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:498:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:498:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:498:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:498:57: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         498 |     static _PyArg_Parser _parser = {"sOy*:unpack_dict", _keywords, 0};
#5 4.233             |                                                         ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:498:57: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘unpack_from_dict’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:538:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         538 |     static _PyArg_Parser _parser = {"sOy*|n:unpack_from_dict", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:538:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:538:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:538:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:538:64: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         538 |     static _PyArg_Parser _parser = {"sOy*|n:unpack_from_dict", _keywords, 0};
#5 4.233             |                                                                ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:538:64: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘compile’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:576:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         576 |     static _PyArg_Parser _parser = {"s|O:compile", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:576:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:576:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:576:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:576:52: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         576 |     static _PyArg_Parser _parser = {"s|O:compile", _keywords, 0};
#5 4.233             |                                                    ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:576:52: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘calcsize’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:607:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         607 |     static _PyArg_Parser _parser = {"s:calcsize", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:607:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:607:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:607:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:607:51: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         607 |     static _PyArg_Parser _parser = {"s:calcsize", _keywords, 0};
#5 4.233             |                                                   ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:607:51: note: (near initialization for ‘_parser.format’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘byteswap’:
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:648:37: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
#5 4.233         648 |     static _PyArg_Parser _parser = {"Oy*|n:byteswap", _keywords, 0};
#5 4.233             |                                     ^~~~~~~~~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:648:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:648:37: error: initializer element is not computable at load time
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:648:37: note: (near initialization for ‘_parser.initialized’)
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:648:55: error: initialization of ‘const char *’ from incompatible pointer type ‘const char * const*’ [-Werror=incompatible-pointer-types]
#5 4.233         648 |     static _PyArg_Parser _parser = {"Oy*|n:byteswap", _keywords, 0};
#5 4.233             |                                                       ^~~~~~~~~
#5 4.233       cbitstruct/clinic/_cbitstruct.c.37.h:648:55: note: (near initialization for ‘_parser.format’)
#5 4.233       cc1: all warnings being treated as errors
#5 4.233       error: command '/usr/bin/gcc' failed with exit code 1
#5 4.233       [end of output]
#5 4.233
#5 4.233   note: This error originates from a subprocess, and is likely not a problem with pip.
#5 4.234   ERROR: Failed building wheel for cbitstruct
#5 4.235   Running setup.py clean for cbitstruct
#5 4.448 Failed to build cbitstruct
#5 4.449 ERROR: Could not build wheels for cbitstruct, which is required to install pyproject.toml-based projects
------
executor failed running [/bin/sh -c pip install cbitstruct]: exit code: 1

One more segfault =)

Found a segfault in version 1.0.2:

cbitstruct.byteswap('\x02\x02', b'z')

I'm using pyfuzzer, a fuzz tester I recently implemented, to find all these corner cases. It's actually quite useful =)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.