Merge remote-tracking branch 'carlos/pypy'

This commit is contained in:
J. David Ibáñez
2014-01-27 22:58:47 +01:00
6 changed files with 38 additions and 14 deletions

View File

@@ -59,7 +59,7 @@ Config_init(Config *self, PyObject *args, PyObject *kwds)
char *path = NULL; char *path = NULL;
int err; int err;
if (kwds) { if (kwds && PyDict_Size(kwds) > 0) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"Config takes no keyword arguments"); "Config takes no keyword arguments");
return -1; return -1;

View File

@@ -46,7 +46,7 @@ Index_init(Index *self, PyObject *args, PyObject *kwds)
char *path; char *path;
int err; int err;
if (kwds) { if (kwds && PyDict_Size(kwds) > 0) {
PyErr_SetString(PyExc_TypeError, "Index takes no keyword arguments"); PyErr_SetString(PyExc_TypeError, "Index takes no keyword arguments");
return -1; return -1;
} }

View File

@@ -27,7 +27,12 @@
#define PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN
#include <Python.h> #include <Python.h>
#include <osdefs.h>
/* Pypy does not provide this header */
#ifndef PYPY_VERSION
# include <osdefs.h>
#endif
#include <git2.h> #include <git2.h>
#include "error.h" #include "error.h"
#include "types.h" #include "types.h"
@@ -35,6 +40,11 @@
#include "repository.h" #include "repository.h"
#include "oid.h" #include "oid.h"
/* FIXME: This is for pypy */
#ifndef MAXPATHLEN
# define MAXPATHLEN 1024
#endif
extern PyObject *GitError; extern PyObject *GitError;
extern PyTypeObject RepositoryType; extern PyTypeObject RepositoryType;

View File

@@ -77,7 +77,7 @@ Repository_init(Repository *self, PyObject *args, PyObject *kwds)
char *path; char *path;
int err; int err;
if (kwds) { if (kwds && PyDict_Size(kwds) > 0) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"Repository takes no keyword arguments"); "Repository takes no keyword arguments");
return -1; return -1;

View File

@@ -34,6 +34,12 @@ import unittest
from pygit2 import GIT_OBJ_COMMIT, Signature, Oid from pygit2 import GIT_OBJ_COMMIT, Signature, Oid
from . import utils from . import utils
# pypy raises TypeError on writing to read-only, so we need to check
# and change the test accordingly
try:
import __pypy__
except ImportError:
__pypy__ = None
COMMIT_SHA = '5fe808e8953c12735680c257f56600cb0de44b10' COMMIT_SHA = '5fe808e8953c12735680c257f56600cb0de44b10'
@@ -131,12 +137,13 @@ class CommitTest(utils.BareRepoTestCase):
author = ('Jane Doe', 'jdoe2@example.com', 12345) author = ('Jane Doe', 'jdoe2@example.com', 12345)
commit = self.repo[COMMIT_SHA] commit = self.repo[COMMIT_SHA]
self.assertRaises(AttributeError, setattr, commit, 'message', message)
self.assertRaises(AttributeError, setattr, commit, 'committer', error_type = AttributeError if not __pypy__ else TypeError
committer) self.assertRaises(error_type, setattr, commit, 'message', message)
self.assertRaises(AttributeError, setattr, commit, 'author', author) self.assertRaises(error_type, setattr, commit, 'committer', committer)
self.assertRaises(AttributeError, setattr, commit, 'tree', None) self.assertRaises(error_type, setattr, commit, 'author', author)
self.assertRaises(AttributeError, setattr, commit, 'parents', None) self.assertRaises(error_type, setattr, commit, 'tree', None)
self.assertRaises(error_type, setattr, commit, 'parents', None)
if __name__ == '__main__': if __name__ == '__main__':

View File

@@ -34,6 +34,12 @@ import unittest
import pygit2 import pygit2
from . import utils from . import utils
# pypy raises TypeError on writing to read-only, so we need to check
# and change the test accordingly
try:
import __pypy__
except ImportError:
__pypy__ = None
TAG_SHA = '3d2962987c695a29f1f80b6c3aa4ec046ef44369' TAG_SHA = '3d2962987c695a29f1f80b6c3aa4ec046ef44369'
@@ -84,10 +90,11 @@ class TagTest(utils.BareRepoTestCase):
tagger = ('John Doe', 'jdoe@example.com', 12347) tagger = ('John Doe', 'jdoe@example.com', 12347)
tag = self.repo[TAG_SHA] tag = self.repo[TAG_SHA]
self.assertRaises(AttributeError, setattr, tag, 'name', name) error_type = AttributeError if not __pypy__ else TypeError
self.assertRaises(AttributeError, setattr, tag, 'target', target) self.assertRaises(error_type, setattr, tag, 'name', name)
self.assertRaises(AttributeError, setattr, tag, 'tagger', tagger) self.assertRaises(error_type, setattr, tag, 'target', target)
self.assertRaises(AttributeError, setattr, tag, 'message', message) self.assertRaises(error_type, setattr, tag, 'tagger', tagger)
self.assertRaises(error_type, setattr, tag, 'message', message)
def test_get_object(self): def test_get_object(self):
repo = self.repo repo = self.repo