@@ -60,7 +60,7 @@ create_string(const char *str)
6060#else
6161 obj = PyString_FromString (str );
6262#endif
63- assert (obj != NULL );
63+ assert (obj != _Py_NULL );
6464 return obj ;
6565}
6666
@@ -173,27 +173,27 @@ test_frame_getvar(PyFrameObject *frame)
173173
174174 // test PyFrame_GetVar() and PyFrame_GetVarString()
175175 PyObject * attr = PyUnicode_FromString ("name" );
176- assert (attr != NULL );
176+ assert (attr != _Py_NULL );
177177 PyObject * name1 = PyFrame_GetVar (frame , attr );
178178 Py_DECREF (attr );
179- assert (name1 != NULL );
179+ assert (name1 != _Py_NULL );
180180 Py_DECREF (name1 );
181181
182182 PyObject * name2 = PyFrame_GetVarString (frame , "name" );
183- assert (name2 != NULL );
183+ assert (name2 != _Py_NULL );
184184 Py_DECREF (name2 );
185185
186186 // test PyFrame_GetVar() and PyFrame_GetVarString() NameError
187187 PyObject * attr3 = PyUnicode_FromString ("dontexist" );
188- assert (attr3 != NULL );
188+ assert (attr3 != _Py_NULL );
189189 PyObject * name3 = PyFrame_GetVar (frame , attr3 );
190190 Py_DECREF (attr3 );
191- assert (name3 == NULL );
191+ assert (name3 == _Py_NULL );
192192 assert (PyErr_ExceptionMatches (PyExc_NameError ));
193193 PyErr_Clear ();
194194
195195 PyObject * name4 = PyFrame_GetVarString (frame , "dontexist" );
196- assert (name4 == NULL );
196+ assert (name4 == _Py_NULL );
197197 assert (PyErr_ExceptionMatches (PyExc_NameError ));
198198 PyErr_Clear ();
199199}
@@ -438,7 +438,7 @@ test_module_addobjectref(PyObject *module)
438438{
439439 const char * name = "test_module_addobjectref" ;
440440 PyObject * obj = PyUnicode_FromString (name );
441- assert (obj != NULL );
441+ assert (obj != _Py_NULL );
442442#ifdef CHECK_REFCNT
443443 Py_ssize_t refcnt = Py_REFCNT (obj );
444444#endif
@@ -474,7 +474,7 @@ test_module_add(PyObject *module)
474474{
475475 const char * name = "test_module_add" ;
476476 PyObject * obj = PyUnicode_FromString (name );
477- assert (obj != NULL );
477+ assert (obj != _Py_NULL );
478478#ifdef CHECK_REFCNT
479479 Py_ssize_t refcnt = Py_REFCNT (obj );
480480#endif
@@ -508,8 +508,8 @@ static PyObject *
508508test_module (PyObject * Py_UNUSED (module ), PyObject * Py_UNUSED (ignored ))
509509{
510510 PyObject * module = PyImport_ImportModule ("sys" );
511- if (module == NULL ) {
512- return NULL ;
511+ if (module == _Py_NULL ) {
512+ return _Py_NULL ;
513513 }
514514 assert (PyModule_Check (module ));
515515
@@ -611,7 +611,7 @@ test_code(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
611611 // PyCode_GetVarnames
612612 {
613613 PyObject * co_varnames = PyCode_GetVarnames (code );
614- assert (co_varnames != NULL );
614+ assert (co_varnames != _Py_NULL );
615615 assert (PyTuple_CheckExact (co_varnames ));
616616 assert (PyTuple_GET_SIZE (co_varnames ) != 0 );
617617 Py_DECREF (co_varnames );
@@ -620,7 +620,7 @@ test_code(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
620620 // PyCode_GetCellvars
621621 {
622622 PyObject * co_cellvars = PyCode_GetCellvars (code );
623- assert (co_cellvars != NULL );
623+ assert (co_cellvars != _Py_NULL );
624624 assert (PyTuple_CheckExact (co_cellvars ));
625625 assert (PyTuple_GET_SIZE (co_cellvars ) == 0 );
626626 Py_DECREF (co_cellvars );
@@ -629,7 +629,7 @@ test_code(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
629629 // PyCode_GetFreevars
630630 {
631631 PyObject * co_freevars = PyCode_GetFreevars (code );
632- assert (co_freevars != NULL );
632+ assert (co_freevars != _Py_NULL );
633633 assert (PyTuple_CheckExact (co_freevars ));
634634 assert (PyTuple_GET_SIZE (co_freevars ) == 0 );
635635 Py_DECREF (co_freevars );
@@ -715,15 +715,15 @@ static PyObject *
715715test_import (PyObject * Py_UNUSED (module ), PyObject * Py_UNUSED (args ))
716716{
717717 PyObject * mod = PyImport_ImportModule ("sys" );
718- if (mod == NULL ) {
719- return NULL ;
718+ if (mod == _Py_NULL ) {
719+ return _Py_NULL ;
720720 }
721721 Py_ssize_t refcnt = Py_REFCNT (mod );
722722
723723 // test PyImport_AddModuleRef()
724724 PyObject * mod2 = PyImport_AddModuleRef ("sys" );
725- if (mod2 == NULL ) {
726- return NULL ;
725+ if (mod2 == _Py_NULL ) {
726+ return _Py_NULL ;
727727 }
728728 assert (PyModule_Check (mod2 ));
729729 assert (Py_REFCNT (mod ) == (refcnt + 1 ));
@@ -740,11 +740,11 @@ gc_collect(void)
740740{
741741#if defined(PYPY_VERSION )
742742 PyObject * mod = PyImport_ImportModule ("gc" );
743- assert (mod != NULL );
743+ assert (mod != _Py_NULL );
744744
745- PyObject * res = PyObject_CallMethod (mod , "collect" , NULL );
745+ PyObject * res = PyObject_CallMethod (mod , "collect" , _Py_NULL );
746746 Py_DECREF (mod );
747- assert (res != NULL );
747+ assert (res != _Py_NULL );
748748 Py_DECREF (res );
749749#else
750750 PyGC_Collect ();
@@ -755,7 +755,7 @@ gc_collect(void)
755755static PyObject *
756756func_varargs (PyObject * Py_UNUSED (module ), PyObject * args , PyObject * kwargs )
757757{
758- if (kwargs != NULL ) {
758+ if (kwargs != _Py_NULL ) {
759759 return PyTuple_Pack (2 , args , kwargs );
760760 }
761761 else {
@@ -784,20 +784,20 @@ test_weakref(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
784784 // type. This object supports weak references.
785785 PyObject * new_type = PyObject_CallFunction ((PyObject * )& PyType_Type ,
786786 "s(){}" , "TypeName" );
787- if (new_type == NULL ) {
788- return NULL ;
787+ if (new_type == _Py_NULL ) {
788+ return _Py_NULL ;
789789 }
790790 PyObject * obj = PyObject_CallNoArgs (new_type );
791791 Py_DECREF (new_type );
792- if (obj == NULL ) {
793- return NULL ;
792+ if (obj == _Py_NULL ) {
793+ return _Py_NULL ;
794794 }
795795 Py_ssize_t refcnt = Py_REFCNT (obj );
796796
797797 // create a weak reference
798- PyObject * weakref = PyWeakref_NewRef (obj , NULL );
799- if (weakref == NULL ) {
800- return NULL ;
798+ PyObject * weakref = PyWeakref_NewRef (obj , _Py_NULL );
799+ if (weakref == _Py_NULL ) {
800+ return _Py_NULL ;
801801 }
802802
803803 // test PyWeakref_GetRef(), reference is alive
@@ -814,23 +814,23 @@ test_weakref(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
814814 // test PyWeakref_GetRef(), reference is dead
815815 ref = Py_True ;
816816 assert (PyWeakref_GetRef (weakref , & ref ) == 0 );
817- assert (ref == NULL );
817+ assert (ref == _Py_NULL );
818818
819819 // test PyWeakref_GetRef(), invalid type
820820 PyObject * invalid_weakref = Py_None ;
821821 assert (!PyErr_Occurred ());
822822 ref = Py_True ;
823823 assert (PyWeakref_GetRef (invalid_weakref , & ref ) == -1 );
824824 assert (PyErr_ExceptionMatches (PyExc_TypeError ));
825- assert (ref == NULL );
825+ assert (ref == _Py_NULL );
826826 PyErr_Clear ();
827827
828828#ifndef PYPY_VERSION
829829 // test PyWeakref_GetRef(NULL)
830830 ref = Py_True ;
831- assert (PyWeakref_GetRef (NULL , & ref ) == -1 );
831+ assert (PyWeakref_GetRef (_Py_NULL , & ref ) == -1 );
832832 assert (PyErr_ExceptionMatches (PyExc_SystemError ));
833- assert (ref == NULL );
833+ assert (ref == _Py_NULL );
834834 PyErr_Clear ();
835835#endif
836836
@@ -842,8 +842,8 @@ test_weakref(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
842842static void
843843test_vectorcall_noargs (PyObject * func_varargs )
844844{
845- PyObject * res = PyObject_Vectorcall (func_varargs , NULL , 0 , NULL );
846- assert (res != NULL );
845+ PyObject * res = PyObject_Vectorcall (func_varargs , _Py_NULL , 0 , _Py_NULL );
846+ assert (res != _Py_NULL );
847847
848848 assert (PyTuple_Check (res ));
849849 assert (PyTuple_GET_SIZE (res ) == 1 );
@@ -860,13 +860,13 @@ static void
860860test_vectorcall_args (PyObject * func_varargs )
861861{
862862 PyObject * args_tuple = Py_BuildValue ("ii" , 1 , 2 );
863- assert (args_tuple != NULL );
863+ assert (args_tuple != _Py_NULL );
864864 size_t nargs = (size_t )PyTuple_GET_SIZE (args_tuple );
865865 PyObject * * args = & PyTuple_GET_ITEM (args_tuple , 0 );
866866
867- PyObject * res = PyObject_Vectorcall (func_varargs , args , nargs , NULL );
867+ PyObject * res = PyObject_Vectorcall (func_varargs , args , nargs , _Py_NULL );
868868 Py_DECREF (args_tuple );
869- assert (res != NULL );
869+ assert (res != _Py_NULL );
870870
871871 assert (PyTuple_Check (res ));
872872 assert (PyTuple_GET_SIZE (res ) == 1 );
@@ -886,15 +886,15 @@ test_vectorcall_args_offset(PyObject *func_varargs)
886886{
887887 // args contains 3 values, but only pass 2 last values
888888 PyObject * args_tuple = Py_BuildValue ("iii" , 1 , 2 , 3 );
889- assert (args_tuple != NULL );
889+ assert (args_tuple != _Py_NULL );
890890 size_t nargs = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET ;
891891 PyObject * * args = & PyTuple_GET_ITEM (args_tuple , 1 );
892892 PyObject * arg0 = PyTuple_GET_ITEM (args_tuple , 0 );
893893
894- PyObject * res = PyObject_Vectorcall (func_varargs , args , nargs , NULL );
894+ PyObject * res = PyObject_Vectorcall (func_varargs , args , nargs , _Py_NULL );
895895 assert (PyTuple_GET_ITEM (args_tuple , 0 ) == arg0 );
896896 Py_DECREF (args_tuple );
897- assert (res != NULL );
897+ assert (res != _Py_NULL );
898898
899899 assert (PyTuple_Check (res ));
900900 assert (PyTuple_GET_SIZE (res ) == 1 );
@@ -913,7 +913,7 @@ static void
913913test_vectorcall_args_kwnames (PyObject * func_varargs )
914914{
915915 PyObject * args_tuple = Py_BuildValue ("iiiii" , 1 , 2 , 3 , 4 , 5 );
916- assert (args_tuple != NULL );
916+ assert (args_tuple != _Py_NULL );
917917 PyObject * * args = & PyTuple_GET_ITEM (args_tuple , 0 );
918918
919919#ifdef PYTHON3
@@ -923,16 +923,16 @@ test_vectorcall_args_kwnames(PyObject *func_varargs)
923923 PyObject * key1 = PyString_FromString ("key1" );
924924 PyObject * key2 = PyString_FromString ("key2" );
925925#endif
926- assert (key1 != NULL );
927- assert (key2 != NULL );
926+ assert (key1 != _Py_NULL );
927+ assert (key2 != _Py_NULL );
928928 PyObject * kwnames = PyTuple_Pack (2 , key1 , key2 );
929- assert (kwnames != NULL );
929+ assert (kwnames != _Py_NULL );
930930 size_t nargs = (size_t )(PyTuple_GET_SIZE (args_tuple ) - PyTuple_GET_SIZE (kwnames ));
931931
932932 PyObject * res = PyObject_Vectorcall (func_varargs , args , nargs , kwnames );
933933 Py_DECREF (args_tuple );
934934 Py_DECREF (kwnames );
935- assert (res != NULL );
935+ assert (res != _Py_NULL );
936936
937937 assert (PyTuple_Check (res ));
938938 assert (PyTuple_GET_SIZE (res ) == 2 );
@@ -976,14 +976,14 @@ test_vectorcall(PyObject *module, PyObject *Py_UNUSED(args))
976976{
977977#ifndef PYTHON3
978978 module = PyImport_ImportModule (MODULE_NAME_STR );
979- assert (module != NULL );
979+ assert (module != _Py_NULL );
980980#endif
981981 PyObject * func_varargs = PyObject_GetAttrString (module , "func_varargs" );
982982#ifndef PYTHON3
983983 Py_DECREF (module );
984984#endif
985- if (func_varargs == NULL ) {
986- return NULL ;
985+ if (func_varargs == _Py_NULL ) {
986+ return _Py_NULL ;
987987 }
988988
989989 // test PyObject_Vectorcall()
@@ -1003,8 +1003,8 @@ test_getattr(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
10031003 assert (!PyErr_Occurred ());
10041004
10051005 PyObject * obj = PyImport_ImportModule ("sys" );
1006- if (obj == NULL ) {
1007- return NULL ;
1006+ if (obj == _Py_NULL ) {
1007+ return _Py_NULL ;
10081008 }
10091009 PyObject * attr_name ;
10101010 PyObject * value ;
@@ -1013,28 +1013,28 @@ test_getattr(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
10131013 attr_name = create_string ("version" );
10141014 value = Py_True ; // marker value
10151015 assert (PyObject_GetOptionalAttr (obj , attr_name , & value ) == 1 );
1016- assert (value != NULL );
1016+ assert (value != _Py_NULL );
10171017 Py_DECREF (value );
10181018 Py_DECREF (attr_name );
10191019
10201020 // test PyObject_GetOptionalAttrString(): attribute exists
10211021 value = Py_True ; // marker value
10221022 assert (PyObject_GetOptionalAttrString (obj , "version" , & value ) == 1 );
1023- assert (value != NULL );
1023+ assert (value != _Py_NULL );
10241024 Py_DECREF (value );
10251025
10261026 // test PyObject_GetOptionalAttr(): attribute doesn't exist
10271027 attr_name = create_string ("nonexistant_attr_name" );
10281028 value = Py_True ; // marker value
10291029 assert (PyObject_GetOptionalAttr (obj , attr_name , & value ) == 0 );
1030- assert (value == NULL );
1030+ assert (value == _Py_NULL );
10311031 Py_DECREF (attr_name );
10321032 assert (!PyErr_Occurred ());
10331033
10341034 // test PyObject_GetOptionalAttrString(): attribute doesn't exist
10351035 value = Py_True ; // marker value
10361036 assert (PyObject_GetOptionalAttrString (obj , "nonexistant_attr_name" , & value ) == 0 );
1037- assert (value == NULL );
1037+ assert (value == _Py_NULL );
10381038 assert (!PyErr_Occurred ());
10391039
10401040 Py_DECREF (obj );
@@ -1048,9 +1048,9 @@ test_getitem(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
10481048 assert (!PyErr_Occurred ());
10491049
10501050 PyObject * value = Py_BuildValue ("s" , "value" );
1051- assert (value != NULL );
1051+ assert (value != _Py_NULL );
10521052 PyObject * obj = Py_BuildValue ("{sO}" , "key" , value );
1053- assert (obj != NULL );
1053+ assert (obj != _Py_NULL );
10541054 PyObject * key ;
10551055 PyObject * item ;
10561056
@@ -1072,13 +1072,13 @@ test_getitem(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
10721072 key = create_string ("dontexist" );
10731073 item = Py_True ; // marker value
10741074 assert (PyMapping_GetOptionalItem (obj , key , & item ) == 0 );
1075- assert (item == NULL );
1075+ assert (item == _Py_NULL );
10761076 Py_DECREF (key );
10771077
10781078 // test PyMapping_GetOptionalItemString(): missing key
10791079 item = Py_True ; // marker value
10801080 assert (PyMapping_GetOptionalItemString (obj , "dontexist" , & item ) == 0 );
1081- assert (item == NULL );
1081+ assert (item == _Py_NULL );
10821082
10831083 Py_DECREF (obj );
10841084 Py_DECREF (value );
@@ -1172,12 +1172,12 @@ PyMODINIT_FUNC
11721172INIT_FUNC (void )
11731173{
11741174 PyObject * module = PyModule_Create (& module_def );
1175- if (module == NULL ) {
1176- return NULL ;
1175+ if (module == _Py_NULL ) {
1176+ return _Py_NULL ;
11771177 }
11781178 if (module_exec (module ) < 0 ) {
11791179 Py_DECREF (module );
1180- return NULL ;
1180+ return _Py_NULL ;
11811181 }
11821182 return module ;
11831183}
@@ -1197,7 +1197,7 @@ INIT_FUNC(void)
11971197 _Py_NULL ,
11981198 _Py_NULL ,
11991199 PYTHON_API_VERSION );
1200- if (module == NULL ) {
1200+ if (module == _Py_NULL ) {
12011201 return ;
12021202 }
12031203
0 commit comments