New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 crashing with bytes decodes #1922

Closed
AngheloAlf opened this Issue Oct 10, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@AngheloAlf

AngheloAlf commented Oct 10, 2017

Hi.
Well, basicly i want to decode a bytes variable into an unicode one, like uni = by.decode("utf-16"). That works on non-compiled python, but crashes with .pyd files. But only in python3. If i compile my code and run it in py2, it works as it should.

Also gcc give me this warnings when compile my code for py3 (but they don't appear when compiling for python2):

src\packages\StatChars.c: In function '__pyx_pf_8packages_9StatChars_9StatChars___init__':
src\packages\StatChars.c:1390:87: warning: passing argument 6 of '__Pyx_decode_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
     __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_self->type, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
                                                                                       ^
src\packages\StatChars.c:857:32: note: expected 'PyObject * (*)(const char *, Py_ssize_t,  const char *) {aka struct _object * (*)(const char *, int,  const char *)}' but argument is of type 'PyObject * (*)(const char *, Py_ssize_t,  const char *, int *) {aka struct _object * (*)(const char *, int,  const char *, int *)}'
 static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
                                ^
src\packages\StatChars.c:1419:91: warning: passing argument 6 of '__Pyx_decode_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
     __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_self->textType, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
                                                                                           ^
src\packages\StatChars.c:857:32: note: expected 'PyObject * (*)(const char *, Py_ssize_t,  const char *) {aka struct _object * (*)(const char *, int,  const char *)}' but argument is of type 'PyObject * (*)(const char *, Py_ssize_t,  const char *, int *) {aka struct _object * (*)(const char *, int,  const char *, int *)}'
 static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
                                ^
src\packages\StatChars.c:1457:89: warning: passing argument 6 of '__Pyx_decode_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
       __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_self->text, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L6_error)
                                                                                         ^
src\packages\StatChars.c:857:32: note: expected 'PyObject * (*)(const char *, Py_ssize_t,  const char *) {aka struct _object * (*)(const char *, int,  const char *)}' but argument is of type 'PyObject * (*)(const char *, Py_ssize_t,  const char *, int *) {aka struct _object * (*)(const char *, int,  const char *, int *)}'
 static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
                                ^
src\packages\StatChars.c: In function '__pyx_f_8packages_9StatChars_9StatChars_getUnicodeList':
src\packages\StatChars.c:1693:85: warning: passing argument 6 of '__Pyx_decode_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
   __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_self->type, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
                                                                                     ^
src\packages\StatChars.c:857:32: note: expected 'PyObject * (*)(const char *, Py_ssize_t,  const char *) {aka struct _object * (*)(const char *, int,  const char *)}' but argument is of type 'PyObject * (*)(const char *, Py_ssize_t,  const char *, int *) {aka struct _object * (*)(const char *, int,  const char *, int *)}'
 static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
                                ^
src\packages\StatChars.c:1726:78: warning: passing argument 6 of '__Pyx_decode_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
     __pyx_t_1 = __Pyx_decode_bytes(__pyx_t_2, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
                                                                              ^
src\packages\StatChars.c:857:32: note: expected 'PyObject * (*)(const char *, Py_ssize_t,  const char *) {aka struct _object * (*)(const char *, int,  const char *)}' but argument is of type 'PyObject * (*)(const char *, Py_ssize_t,  const char *, int *) {aka struct _object * (*)(const char *, int,  const char *, int *)}'
 static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
                                ^
src\packages\StatChars.c:1754:87: warning: passing argument 6 of '__Pyx_decode_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
     __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_self->text, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
                                                                                       ^
src\packages\StatChars.c:857:32: note: expected 'PyObject * (*)(const char *, Py_ssize_t,  const char *) {aka struct _object * (*)(const char *, int,  const char *)}' but argument is of type 'PyObject * (*)(const char *, Py_ssize_t,  const char *, int *) {aka struct _object * (*)(const char *, int,  const char *, int *)}'
 static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Oct 10, 2017

Contributor
Contributor

scoder commented Oct 10, 2017

@AngheloAlf

This comment has been minimized.

Show comment
Hide comment
@AngheloAlf

AngheloAlf Oct 10, 2017

Well, this is embarrassing...
I updated cython and now this doesn't make trouble. c: Thanks a lot, i don't know how i didn't tried that.

Other problem i have with cython (i think i should ask this on another issue...), is always getting this warnings when compiling for py3 (they don't appear when compiling for py2):

In file included from C:\Program Files (x86)\Python36-32\include/Python.h:65:0,
                 from src\main.c:4:
C:\Program Files (x86)\Python36-32\include/pytime.h:112:5: warning: 'struct timeval' declared inside parameter list
     _PyTime_round_t round);
     ^
C:\Program Files (x86)\Python36-32\include/pytime.h:112:5: warning: its scope is only this definition or declaration, which is probably not what you want
C:\Program Files (x86)\Python36-32\include/pytime.h:117:5: warning: 'struct timeval' declared inside parameter list
     _PyTime_round_t round);
     ^

although they appear, it seems to not be affecting in any way.

AngheloAlf commented Oct 10, 2017

Well, this is embarrassing...
I updated cython and now this doesn't make trouble. c: Thanks a lot, i don't know how i didn't tried that.

Other problem i have with cython (i think i should ask this on another issue...), is always getting this warnings when compiling for py3 (they don't appear when compiling for py2):

In file included from C:\Program Files (x86)\Python36-32\include/Python.h:65:0,
                 from src\main.c:4:
C:\Program Files (x86)\Python36-32\include/pytime.h:112:5: warning: 'struct timeval' declared inside parameter list
     _PyTime_round_t round);
     ^
C:\Program Files (x86)\Python36-32\include/pytime.h:112:5: warning: its scope is only this definition or declaration, which is probably not what you want
C:\Program Files (x86)\Python36-32\include/pytime.h:117:5: warning: 'struct timeval' declared inside parameter list
     _PyTime_round_t round);
     ^

although they appear, it seems to not be affecting in any way.

@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Oct 13, 2017

Contributor

These warnings look more like CPython bugs under Windows. Could you please report them on https://bugs.python.org ?

Contributor

scoder commented Oct 13, 2017

These warnings look more like CPython bugs under Windows. Could you please report them on https://bugs.python.org ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment