Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8641721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:36:01+00:00 2026-06-12T11:36:01+00:00

I have a function wrapped in Cython: cdef extern from myheader.h: int c_my_func (const_char

  • 0

I have a function wrapped in Cython:

cdef extern  from "myheader.h":
   int c_my_func (const_char *a, const_char* b)

And a function exposed to Python:

def my_func(a, b):
    c_my_func(a, b)

The function c_my_func accepts NULL for parameters a and b. When I call it from the interpreter:

my_func(None, None)

it throws the exception:

TypeError: expected string or Unicode object, NoneType found

How do I make this function accept the None and pass NULL to the c_my_func ? I don’t want to manually check for the None and then pass NULL. I also tried using default parameters on the cdef of the c_my_func and it doesn’t worked.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:36:03+00:00Added an answer on June 12, 2026 at 11:36 am

    You can find the answer in the Cython FAQ.

    None is not compatible with any C type. To accommodate for this, the
    default behavior is for functions with cdefed parameters to also
    accept None.

    1. If you want to consider None invalid input, then you need to write
      code that checks for it, and raised an appropriate exception.

    The solution is to manually check for None and pass NULL, as you write.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming I have a decorator and a wrapped function like this: def squared(method): def
I have an overloaded function which I want to pass along wrapped in a
I have function LoadTempMovieList(), and need to load movies from sessionStorage. But it seems
i have function public Menu Details(int? id) { return _dataContext.Menu.Include(ChildMenu).FirstOrDefault(m => m.MenuId == id);
In my project I have a function named GetObject that is wrapped in one
I have some code wrapped in $(document).ready(function(){ /*code*/ }); , and all of it
I have this SQL function which is wrapped by a stored procedure: ALTER FUNCTION
Yet another one of my P/Invoke questions! I have this C function: int _ei_x_new(ei_x_buff*
I have function foo take jquery wrapped node as an argument. Is there more
I have written a function in python that takes two arguments one of which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.