Skip to content
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

make Cython understand 'size_t' as a native C type #767

Closed
robertwb opened this issue Feb 6, 2009 · 4 comments
Closed

make Cython understand 'size_t' as a native C type #767

robertwb opened this issue Feb 6, 2009 · 4 comments

Comments

@robertwb
Copy link
Contributor

robertwb commented Feb 6, 2009

http://codespeak.net/pipermail/cython-dev/2009-February/003670.html

At 2009-02-06T21:54:11Z @dalcinl added attachment SIZE_T.diff

Migrated from http://trac.cython.org/ticket/207

@robertwb
Copy link
Contributor Author

robertwb commented Feb 8, 2009

scoder commented

Copying this here from the mailing list:

    static INLINE size_t __pyx_PyInt_AsSize_t(PyObject* b) {
         unsigned PY_LONG_LONG val =
                 __pyx_PyInt_AsUnsignedLongLong(b);
         if (unlikely(val == (unsigned PY_LONG_LONG)-1 &&
                 PyErr_Occurred())) {
               return (size_t)-1;

The (size_t)-1 definitely looks funny. I noticed that (unsigned PY_LONG_LONG)-1 is also used in __pyx_PyInt_AsUnsignedLongLong(), so I just hope it does the right thing.

          } else if (unlikely((unsigned PY_LONG_LONG)(size_t)val
                             != val)) {
               PyErr_SetString(PyExc_OverflowError, "value too
                     large to convert to size_t");

This should return an error value, so it lacks a return (size_t)-1.

          }
          return val;
    }

It would be great if we had tests for the error cases. It's not obvious
that they work as expected. The same applies to the "unsigned long long"
conversion, IMHO.

@robertwb
Copy link
Contributor Author

scoder changed owner from somebody to dalcinl
commented

@robertwb
Copy link
Contributor Author

scoder changed resolution to fixed
status from new to closed
commented

@robertwb
Copy link
Contributor Author

scoder changed milestone from wishlist to 0.11
commented

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

No branches or pull requests

1 participant