This repository was archived by the owner on Mar 8, 2018. It is now read-only.
File tree 2 files changed +8
-9
lines changed
2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -297,8 +297,8 @@ PyObject *py_yajldecoder_decode(PYARGS)
297
297
return NULL ;
298
298
299
299
if (!buflen ) {
300
- /* Raise some sort of exception? */
301
- fprintf ( stderr , "`buflen` == NULL\n" );
300
+ PyErr_SetObject ( PyExc_ValueError ,
301
+ PyString_FromString ( "Cannot parse an empty buffer" ) );
302
302
return NULL ;
303
303
}
304
304
@@ -325,13 +325,14 @@ PyObject *py_yajldecoder_decode(PYARGS)
325
325
326
326
327
327
if (yrc != yajl_status_ok ) {
328
- /* Raise some sort of exception */
329
- fprintf ( stderr , "FAIL : %s\n" , yajl_status_to_string (yrc ));
328
+ PyErr_SetObject ( PyExc_ValueError ,
329
+ PyString_FromString ( yajl_status_to_string (yrc ) ));
330
330
return NULL ;
331
331
}
332
332
333
333
if (decoder -> root == NULL ) {
334
- fprintf (stderr , "FAIL : %s\n" , yajl_status_to_string (yrc ));
334
+ PyErr_SetObject (PyExc_ValueError ,
335
+ PyString_FromString ("The root object is NULL" ));
335
336
return NULL ;
336
337
}
337
338
Original file line number Diff line number Diff line change @@ -50,12 +50,10 @@ def setUp(self):
50
50
self .d = yajl .Decoder ()
51
51
52
52
def test_EmptyString (self ):
53
- rc = self .d .decode ('' )
54
- print ('rc' , rc )
53
+ self .failUnlessRaises (ValueError , self .d .decode , '' )
55
54
56
55
def test_None (self ):
57
- rc = self .d .decode (None )
58
- print ('rc' , rc )
56
+ self .failUnlessRaises (ValueError , self .d .decode , None )
59
57
60
58
61
59
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments