Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 9797)
+++ wp-includes/post.php	(working copy)
@@ -1677,7 +1677,7 @@
 	if ( empty($tags) )
 		$tags = array();
 	$tags = (is_array($tags)) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") );
-	$tags = array_map('trim', $tags); //Trim whitespace from around the tags.
+	$tags = array_map('wp_type_aware_trim', $tags); //Trim whitespace from around the tags.
 	wp_set_object_terms($post_id, $tags, 'post_tag', $append);
 }
 
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 9797)
+++ wp-includes/functions.php	(working copy)
@@ -2895,5 +2895,26 @@
 	return version_compare(phpversion(), '5.0') < 0 ? $object : clone($object);
 }
 
-
+/**
+ * Trim without making integers to strings
+ *
+ * Returns a trimmed string or a integer
+ *
+ * @since 2.7.0
+ *
+ * @param string $string The string to be trimmed
+ * @param string $charlist Possible charlist parameter for trim command
+ * @return string/integer Trimmed string or integer value
+ */
+function wp_type_aware_trim( $string, $charlist = false ) {
+    if ( is_int( $string ) )
+        return $string;
+    else {
+        if ( $charlist )
+            return trim( $string, $charlist );
+        else
+            return trim( $string );
+    }
+    return $string;
+}
 ?>
