]> granicus.if.org Git - python/commitdiff
Merged revisions 60379-60382 via svnmerge from
authorChristian Heimes <christian@cheimes.de>
Mon, 28 Jan 2008 02:38:20 +0000 (02:38 +0000)
committerChristian Heimes <christian@cheimes.de>
Mon, 28 Jan 2008 02:38:20 +0000 (02:38 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r60381 | christian.heimes | 2008-01-28 03:07:53 +0100 (Mon, 28 Jan 2008) | 1 line

  static PyObject* variables should use PyString_InternFromString() instead of PyObject_FromString() to store a python string in a function level static var.
........

Modules/_ctypes/_ctypes.c
Modules/_ctypes/callbacks.c
Modules/mathmodule.c
Objects/abstract.c
Objects/complexobject.c
Python/bltinmodule.c
Python/compile.c

index 49f55c85d91476954e3ffde4bca3db8e6c166796..c10f627ed7579a89cb5a22b75b46b6952a5b5cf0 100644 (file)
@@ -1530,9 +1530,9 @@ static PyObject *CreateSwappedType(PyTypeObject *type, PyObject *args, PyObject
 
        if (suffix == NULL)
 #ifdef WORDS_BIGENDIAN
-               suffix = PyUnicode_FromString("_le");
+               suffix = PyUnicode_InternFromString("_le");
 #else
-               suffix = PyUnicode_FromString("_be");
+               suffix = PyUnicode_InternFromString("_be");
 #endif
 
        newname = PyUnicode_Concat(name, suffix);
@@ -4276,7 +4276,7 @@ Simple_repr(CDataObject *self)
        }
 
        if (format == NULL) {
-               format = PyUnicode_FromString("%s(%r)");
+               format = PyUnicode_InternFromString("%s(%r)");
                if (format == NULL)
                        return NULL;
        }
index 6a1d2b798c11cfe67647735be5c08e07a82de6f5..964af1bacc1f7c1a7e002d333c66b4eefa417979 100644 (file)
@@ -365,7 +365,7 @@ long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
        static PyObject *context;
 
        if (context == NULL)
-               context = PyUnicode_FromString("_ctypes.DllGetClassObject");
+               context = PyUnicode_InternFromString("_ctypes.DllGetClassObject");
 
        mod = PyImport_ImportModuleNoBlock("ctypes");
        if (!mod) {
@@ -444,7 +444,7 @@ long Call_CanUnloadNow(void)
        static PyObject *context;
 
        if (context == NULL)
-               context = PyUnicode_FromString("_ctypes.DllCanUnloadNow");
+               context = PyUnicode_InternFromString("_ctypes.DllCanUnloadNow");
 
        mod = PyImport_ImportModuleNoBlock("ctypes");
        if (!mod) {
index 873059f4cf98e276279be760f3e208ec1a258ec7..baef56933b9e7b2fb7efe7b34ac89761519ab352 100644 (file)
@@ -131,7 +131,7 @@ static PyObject * math_ceil(PyObject *self, PyObject *number) {
        PyObject *method;
 
        if (ceil_str == NULL) {
-               ceil_str = PyUnicode_FromString("__ceil__");
+               ceil_str = PyUnicode_InternFromString("__ceil__");
                if (ceil_str == NULL)
                        return NULL;
        }
@@ -171,7 +171,7 @@ static PyObject * math_floor(PyObject *self, PyObject *number) {
        PyObject *method;
 
        if (floor_str == NULL) {
-               floor_str = PyUnicode_FromString("__floor__");
+               floor_str = PyUnicode_InternFromString("__floor__");
                if (floor_str == NULL)
                        return NULL;
        }
index 3410dd87629835b7b2b9b4322ca43bfe00760deb..755cb0eabec2039256104ec0509a68fa48788f76 100644 (file)
@@ -2333,7 +2333,7 @@ abstract_get_bases(PyObject *cls)
        PyObject *bases;
 
        if (__bases__ == NULL) {
-               __bases__ = PyUnicode_FromString("__bases__");
+               __bases__ = PyUnicode_InternFromString("__bases__");
                if (__bases__ == NULL)
                        return NULL;
        }
@@ -2413,7 +2413,7 @@ recursive_isinstance(PyObject *inst, PyObject *cls, int recursion_depth)
        int retval = 0;
 
        if (__class__ == NULL) {
-               __class__ = PyUnicode_FromString("__class__");
+               __class__ = PyUnicode_InternFromString("__class__");
                if (__class__ == NULL)
                        return -1;
        }
index a7bf3425ffe9685a9beb632a696f915179626c72..a08253e0dc5a52f808739e636156f5ec318585ac 100644 (file)
@@ -265,13 +265,14 @@ PyComplex_AsCComplex(PyObject *op)
        /* return -1 on failure */
        cv.real = -1.;
        cv.imag = 0.;
-       
+               
+       if (complex_str == NULL) {
+               if (!(complex_str = PyUnicode_FromString("__complex__")))
+                       return cv;
+       }
+
         {
                PyObject *complexfunc;
-               if (!complex_str) {
-                       if (!(complex_str = PyUnicode_FromString("__complex__")))
-                               return cv;
-               }
                complexfunc = _PyType_Lookup(op->ob_type, complex_str);
                /* complexfunc is a borrowed reference */
                if (complexfunc) {
index 2a0376a95d1f80cf5833fe545fb18fc6bd8b2160..05f6a81068aaf89ee7f75e28fcd0f4aa0d52777c 100644 (file)
@@ -1463,7 +1463,7 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
        }
 
        if (round_str == NULL) {
-               round_str = PyUnicode_FromString("__round__");
+               round_str = PyUnicode_InternFromString("__round__");
                if (round_str == NULL)
                        return NULL;
        }
@@ -1582,7 +1582,7 @@ builtin_trunc(PyObject *self, PyObject *number)
        }
 
        if (trunc_str == NULL) {
-               trunc_str = PyUnicode_FromString("__trunc__");
+               trunc_str = PyUnicode_InternFromString("__trunc__");
                if (trunc_str == NULL)
                        return NULL;
        }
index 347a19281e663ba9b6dba51beee996c2c7bf551a..6ce465ccb1f0b644bb872ded3a89d7d941059a15 100644 (file)
@@ -1133,7 +1133,7 @@ compiler_mod(struct compiler *c, mod_ty mod)
        int addNone = 1;
        static PyObject *module;
        if (!module) {
-               module = PyUnicode_FromString("<module>");
+               module = PyUnicode_InternFromString("<module>");
                if (!module)
                        return NULL;
        }
@@ -1477,7 +1477,7 @@ compiler_class(struct compiler *c, stmt_ty s)
 
        /* initialize statics */
        if (locals == NULL) {
-               locals = PyUnicode_FromString("__locals__");
+               locals = PyUnicode_InternFromString("__locals__");
                if (locals == NULL)
                        return 0;
        }
@@ -2177,7 +2177,7 @@ compiler_assert(struct compiler *c, stmt_ty s)
        if (Py_OptimizeFlag)
                return 1;
        if (assertion_error == NULL) {
-               assertion_error = PyUnicode_FromString("AssertionError");
+               assertion_error = PyUnicode_InternFromString("AssertionError");
                if (assertion_error == NULL)
                        return 0;
        }