Commits

Alex Gaynor committed 9733b32 Merge

merged default in

  • Participants
  • Parent commits 4f3e2c9, 89c328e
  • Branches jit-dynamic-getarrayitem

Comments (0)

Files changed (10)

pypy/module/cpyext/include/eval.h

 
 PyObject * PyEval_CallFunction(PyObject *obj, const char *format, ...);
 PyObject * PyEval_CallMethod(PyObject *obj, const char *name, const char *format, ...);
-PyObject * PyObject_CallFunction(PyObject *obj, char *format, ...);
-PyObject * PyObject_CallMethod(PyObject *obj, char *name, char *format, ...);
+PyObject * PyObject_CallFunction(PyObject *obj, const char *format, ...);
+PyObject * PyObject_CallMethod(PyObject *obj, const char *name, const char *format, ...);
 PyObject * PyObject_CallFunctionObjArgs(PyObject *callable, ...);
 PyObject * PyObject_CallMethodObjArgs(PyObject *callable, PyObject *name, ...);
 

pypy/module/cpyext/include/pycobject.h

 PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *);
 
 /* Import a pointer to a C object from a module using a PyCObject. */
-PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name);
+PyAPI_FUNC(void *) PyCObject_Import(const char *module_name, const char *cobject_name);
 
 /* Modify a C object. Fails (==0) if object has a destructor. */
 PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj);

pypy/module/cpyext/include/pyerrors.h

     (PyClass_Check((x)) || (PyType_Check((x)) &&                        \
       PyObject_IsSubclass((x), PyExc_BaseException)))
 
-PyObject *PyErr_NewException(char *name, PyObject *base, PyObject *dict);
-PyObject *PyErr_NewExceptionWithDoc(char *name, char *doc, PyObject *base, PyObject *dict);
+PyObject *PyErr_NewException(const char *name, PyObject *base, PyObject *dict);
+PyObject *PyErr_NewExceptionWithDoc(const char *name, const char *doc, PyObject *base, PyObject *dict);
 PyObject *PyErr_Format(PyObject *exception, const char *format, ...);
 
 /* These APIs aren't really part of the error implementation, but

pypy/module/cpyext/modsupport.py

     modname = rffi.charp2str(name)
     state = space.fromcache(State)
     f_name, f_path = state.package_context
-    w_mod = PyImport_AddModule(space, f_name)
+    if f_name is not None:
+        modname = f_name
+    w_mod = PyImport_AddModule(space, modname)
+    state.package_context = None, None
 
-    dict_w = {'__file__': space.wrap(f_path)}
+    if f_path is not None:
+        dict_w = {'__file__': space.wrap(f_path)}
+    else:
+        dict_w = {}
     convert_method_defs(space, dict_w, methods, None, w_self, modname)
     for key, w_value in dict_w.items():
         space.setattr(w_mod, space.wrap(key), w_value)

pypy/module/cpyext/src/cobject.c

 }
 
 void *
-PyCObject_Import(char *module_name, char *name)
+PyCObject_Import(const char *module_name, const char *name)
 {
     PyObject *m, *c;
     void *r = NULL;

pypy/module/cpyext/src/modsupport.c

 }
 
 PyObject *
-PyObject_CallFunction(PyObject *callable, char *format, ...)
+PyObject_CallFunction(PyObject *callable, const char *format, ...)
 {
 	va_list va;
 	PyObject *args;
 }
 
 PyObject *
-PyObject_CallMethod(PyObject *o, char *name, char *format, ...)
+PyObject_CallMethod(PyObject *o, const char *name, const char *format, ...)
 {
 	va_list va;
 	PyObject *args;

pypy/module/cpyext/src/pyerrors.c

 }
 
 PyObject *
-PyErr_NewException(char *name, PyObject *base, PyObject *dict)
+PyErr_NewException(const char *name, PyObject *base, PyObject *dict)
 {
 	char *dot;
 	PyObject *modulename = NULL;
 
 /* Create an exception with docstring */
 PyObject *
-PyErr_NewExceptionWithDoc(char *name, char *doc, PyObject *base, PyObject *dict)
+PyErr_NewExceptionWithDoc(const char *name, const char *doc, PyObject *base, PyObject *dict)
 {
     int result;
     PyObject *ret = NULL;

pypy/rpython/lltypesystem/rstr.py

         # unlike CPython, there is no reason to avoid to return -1
         # but our malloc initializes the memory to zero, so we use zero as the
         # special non-computed-yet value.
+        if not s:
+            return 0
         x = s.hash
         if x == 0:
             x = _hash_string(s.chars)

pypy/rpython/ootypesystem/rstr.py

         return ootype.oounicode(ch, -1)
 
     def ll_strhash(s):
+        if not s:
+            return 0
         return s.ll_hash()
 
     def ll_strfasthash(s):

pypy/rpython/test/test_rtuple.py

         res2 = self.interpret(f, [27, 12])
         assert res1 != res2
 
+    def test_constant_tuple_hash_str(self):
+        from pypy.rlib.objectmodel import compute_hash
+        def f(i):
+            if i:
+                t = (None, "abc")
+            else:
+                t = ("abc", None)
+            return compute_hash(t)
+
+        res1 = self.interpret(f, [0])
+        res2 = self.interpret(f, [1])
+        assert res1 != res2
+
     def test_tuple_to_list(self):
         def f(i, j):
             return list((i, j))