summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c7
-rw-r--r--Python/ceval.c13
2 files changed, 8 insertions, 12 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 9210bd1..97ed2f4 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1096,12 +1096,7 @@ builtin_str(self, v)
err_badarg();
return NULL;
}
- if (is_stringobject(v)) {
- INCREF(v);
- return v;
- }
- else
- return reprobject(v);
+ return strobject(v);
}
static object *
diff --git a/Python/ceval.c b/Python/ceval.c
index 324ecdf..425e2a0 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -38,6 +38,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "graminit.h"
#include "pythonrun.h"
+#include <ctype.h>
+
/* Turn this on if your compiler chokes on the big switch: */
/* #define CASE_TOO_BIG 1 /**/
@@ -660,16 +662,15 @@ eval_code(co, globals, locals, owner, arg)
w = sysget("stdout");
if (softspace(w, 1))
writestring(" ", w);
- if (is_stringobject(v)) {
+ err = writeobject(v, w, PRINT_RAW);
+ if (err == 0 && is_stringobject(v)) {
+ /* XXX move into writeobject() ? */
char *s = getstringvalue(v);
int len = getstringsize(v);
- err = writeobject(v, w, PRINT_RAW);
- if (err == 0 && len > 0 && s[len-1] == '\n')
+ if (len > 0 && isspace(s[len-1]) &&
+ s[len-1] != ' ')
softspace(w, 0);
}
- else {
- err = writeobject(v, w, 0);
- }
DECREF(v);
break;