Skip to content

Commit

Permalink
Merge branch 'keyerror-bugfix-0.1.4-3'
Browse files Browse the repository at this point in the history
Conflicts:
	libcomps/src/python/tests/__test.py
	libcomps/version.cmake
  • Loading branch information
midnightercz committed Oct 22, 2013
2 parents 82de4cb + 3b26247 commit a76bbc0
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 24 deletions.
2 changes: 1 addition & 1 deletion libcomps/src/comps_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
COMPS_Str *obj);

typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_ObjDict *objects;
COMPS_Log *log;
COMPS_Str *encoding;
Expand Down
12 changes: 6 additions & 6 deletions libcomps/src/comps_doc_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* @see comps2xml_str
*/
typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_ObjDict *objects;
COMPS_Logger *log;
COMPS_Str *encoding;
Expand All @@ -78,7 +78,7 @@ typedef struct {
* @see comps_doccategory_intersect
*/
typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_ObjDict *properties;
COMPS_ObjDict *name_by_lang;
COMPS_ObjDict *desc_by_lang;
Expand Down Expand Up @@ -108,7 +108,7 @@ typedef struct {
* @see comps_docgroup_intersect
*/
typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_ObjDict *properties;
COMPS_ObjDict *name_by_lang;
COMPS_ObjDict *desc_by_lang;
Expand All @@ -135,7 +135,7 @@ typedef struct {
* @see comps_docenv_intersect
*/
typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_Dict *properties;
COMPS_Dict *name_by_lang;
COMPS_Dict *desc_by_lang;
Expand All @@ -146,7 +146,7 @@ typedef struct {


typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
char *name;
char def;
void *reserved;
Expand All @@ -168,7 +168,7 @@ typedef enum {COMPS_PACKAGE_DEFAULT, COMPS_PACKAGE_OPTIONAL,
* @see comps_docpackage_set_type
*/
typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
//COMPS_Dict *properties;
COMPS_PackageType type;
UNFO_Str *name;
Expand Down
2 changes: 1 addition & 1 deletion libcomps/src/comps_doccategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <assert.h>

typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_ObjDict *properties;
COMPS_ObjDict *name_by_lang;
COMPS_ObjDict *desc_by_lang;
Expand Down
2 changes: 1 addition & 1 deletion libcomps/src/comps_docenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "comps_radix.h"

typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_ObjDict *properties;
COMPS_ObjDict *name_by_lang;
COMPS_ObjDict *desc_by_lang;
Expand Down
2 changes: 1 addition & 1 deletion libcomps/src/comps_docgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <assert.h>

typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_ObjDict *properties;
COMPS_ObjDict *name_by_lang;
COMPS_ObjDict *desc_by_lang;
Expand Down
2 changes: 1 addition & 1 deletion libcomps/src/comps_docgroupid.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "comps_utils.h"

typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_Str *name;
char def;
} COMPS_DocGroupId;
Expand Down
2 changes: 1 addition & 1 deletion libcomps/src/comps_docpackage.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef enum {COMPS_PACKAGE_DEFAULT, COMPS_PACKAGE_OPTIONAL,
COMPS_PACKAGE_UNKNOWN} COMPS_PackageType;

typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_PackageType type;
COMPS_Str *name;
COMPS_Str *requires;
Expand Down
2 changes: 1 addition & 1 deletion libcomps/src/comps_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct COMPS_LogEntry {
};

struct COMPS_Log {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_HSList *entries;
char std_out;
};
Expand Down
2 changes: 1 addition & 1 deletion libcomps/src/comps_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
* behaviour
*/
#define COMPS_Object_HEAD COMPS_RefC *refc;\
COMPS_ObjectInfo *obj_info;
COMPS_ObjectInfo *obj_info

typedef struct COMPS_Object COMPS_Object;
typedef struct COMPS_ObjectInfo COMPS_ObjectInfo;
Expand Down
2 changes: 1 addition & 1 deletion libcomps/src/comps_objlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct COMPS_ObjListIt {
} UnfoObjListIt;

typedef struct COMPS_ObjList {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_ObjListIt *first;
COMPS_ObjListIt *last;
size_t len;
Expand Down
2 changes: 1 addition & 1 deletion libcomps/src/comps_objmradix.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef struct {
} COMPS_ObjMRTreeData;

typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_HSList * subnodes;
unsigned int len;
} COMPS_ObjMRTree;
Expand Down
2 changes: 1 addition & 1 deletion libcomps/src/comps_objradix.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef struct {
} COMPS_ObjRTreeData;

typedef struct {
COMPS_Object_HEAD
COMPS_Object_HEAD;
COMPS_HSList *subnodes;
unsigned int len;
} COMPS_ObjRTree;
Expand Down
25 changes: 24 additions & 1 deletion libcomps/src/python/pycomps_dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,29 @@ PyObject* PyCOMPSDict_get(PyObject *self, PyObject *key) {
}
}

PyObject* PyCOMPSDict_get_(PyObject *self, PyObject *key) {
char *ckey;
COMPS_Object* val;
PyObject *ret;

if (__pycomps_stringable_to_char(key, &ckey)) {
return NULL;
}
val = comps_objdict_get(((PyCOMPS_Dict*)self)->dict, ckey);
if (!val) {
free(ckey);
Py_RETURN_NONE;
}
else {
free(ckey);
ckey = comps_object_tostr(val);
COMPS_OBJECT_DESTROY(val);
ret = PyUnicode_FromString(ckey);
free(ckey);
return ret;
}
}

int PyCOMPSDict_set(PyObject *self, PyObject *key, PyObject *val) {
#define _dict_ ((PyCOMPS_Dict*)self)
char *ckey;
Expand Down Expand Up @@ -321,7 +344,7 @@ PyMemberDef PyCOMPSDict_members[] = {
{NULL}};

PyMethodDef PyCOMPSDict_methods[] = {
{"get", (PyCFunction)PyCOMPSDict_get, METH_O,
{"get", (PyCFunction)PyCOMPSDict_get_, METH_O,
"alias for libcomps.Dict[key]"},
{"has_key", (PyCFunction)PyCOMPSDict_has_key, METH_O,
"alias for key in dict"},
Expand Down
6 changes: 6 additions & 0 deletions libcomps/src/python/tests/__test.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,12 @@ def test_dict(self):
_values.append(v)
self.assertTrue(set(_values) == set(_values2))

def test_keyerror(self):
_dict = libcomps.StrDict()
self.assertTrue(_dict.get("notindict") == None)
with self.assertRaises(KeyError):
x = _dict["notindict"]

class MDictTest(unittest.TestCase):
def test_blacklist(self):
bl1 = libcomps.Blacklist()
Expand Down
10 changes: 5 additions & 5 deletions libcomps/tests/check_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,11 @@ Suite* basic_suite (void)
Suite *s = suite_create ("Basic Tests");
/* Core test case */
TCase *tc_core = tcase_create ("Core");
//tcase_add_test (tc_core, test_comps_parse1);
//tcase_add_test (tc_core, test_comps_parse2);
//tcase_add_test (tc_core, test_comps_parse3);
//tcase_add_test (tc_core, test_comps_parse4);
//tcase_add_test (tc_core, test_comps_parse5);
tcase_add_test (tc_core, test_comps_parse1);
tcase_add_test (tc_core, test_comps_parse2);
tcase_add_test (tc_core, test_comps_parse3);
tcase_add_test (tc_core, test_comps_parse4);
tcase_add_test (tc_core, test_comps_parse5);
tcase_add_test (tc_core, test_comps_fedora_parse);
tcase_set_timeout(tc_core, 15);
suite_add_tcase (s, tc_core);
Expand Down
2 changes: 1 addition & 1 deletion libcomps/version.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set (libcomps_VERSION_MAJOR 0)
set (libcomps_VERSION_MINOR 1)
set (libcomps_VERSION_PATCH 6)
set (libcomps_RELEASE 1)
set (libcomps_RELEASE 2)

0 comments on commit a76bbc0

Please sign in to comment.