summaryrefslogtreecommitdiff
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-11-05 10:22:19 +0000
committerGuido van Rossum <guido@python.org>1993-11-05 10:22:19 +0000
commitc60041175547df61e67ff167bd5ad18f7967795d (patch)
treed22af13adf57d915922d4806b79213ad326603ef /Python/ceval.c
parent2e8f8a398e135ce4ec235c33eb64c29e6b6114ea (diff)
downloadcpython-git-c60041175547df61e67ff167bd5ad18f7967795d.tar.gz
* mpzmodule.c: removed redundant mpz_print function.
* object.[ch], bltinmodule.c, fileobject.c: changed str() to call strobject() which calls an object's __str__ method if it has one. strobject() is also called by writeobject() when PRINT_RAW is passed. * ceval.c: rationalize code for PRINT_ITEM (no change in function!) * funcobject.c, codeobject.c: added compare and hash functionality. Functions with identical code objects and the same global dictionary are equal. Code objects are equal when their code, constants list and names list are identical (i.e. the filename and code name don't count). (hash doesn't work yet since the constants are in a list and lists can't be hashed -- suppose this should really be done with a tuple now we have resizetuple!)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 324ecdf97f..425e2a06a6 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;