diff Objects/bytesobject.c @ 41668:b1bbe8011152

The NULL pointer for empty strings turns out to be a pain. At least for the buffer API, return "" in that case.
author Guido van Rossum <guido@python.org>
date Wed, 09 May 2007 23:36:14 +0000
parents a363cea32b9b
children b29d71d43c80
line wrap: on
line diff
--- a/Objects/bytesobject.c	Wed May 09 23:35:09 2007 +0000
+++ b/Objects/bytesobject.c	Wed May 09 23:36:14 2007 +0000
@@ -950,7 +950,10 @@
                         "accessing non-existent bytes segment");
         return -1;
     }
-    *ptr = (void *)self->ob_bytes;
+    if (self->ob_bytes == NULL)
+        *ptr = "";
+    else
+        *ptr = self->ob_bytes;
     return self->ob_size;
 }