Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1040
diff -u -p -r1.1040 common.inc
--- includes/common.inc	3 Nov 2009 06:47:22 -0000	1.1040
+++ includes/common.inc	3 Nov 2009 19:45:30 -0000
@@ -4895,9 +4895,8 @@ function drupal_render_page($page) {
  *   The rendered HTML.
  */
 function drupal_render(&$elements) {
-  static $defaults;
   // Early-return nothing if user does not have access.
-  if (!isset($elements) || (isset($elements['#access']) && !$elements['#access'])) {
+  if (empty($elements) || (isset($elements['#access']) && !$elements['#access'])) {
     return;
   }
 
@@ -4910,7 +4909,7 @@ function drupal_render(&$elements) {
   if (isset($elements['#cache']) && $cached_output = drupal_render_cache_get($elements)) {
     return $cached_output;
   }
-  
+
   // If #markup is not empty, set #type. This allows to specify just #markup on
   // an element without setting #type.
   if (!empty($elements['#markup']) && !isset($elements['#type'])) {
@@ -4922,12 +4921,6 @@ function drupal_render(&$elements) {
   if (isset($elements['#type']) && empty($elements['#defaults_loaded'])) {
     $elements += element_info($elements['#type']);
   }
-  else {
-    if (!isset($defaults)) {
-      $defaults = element_basic_defaults();
-    }
-    $elements += $defaults;
-  }
 
   // Make any final changes to the element before it is rendered. This means
   // that the $element or the children can be altered or corrected before the
@@ -5015,7 +5008,9 @@ function drupal_render_children(&$elemen
   }
   $output = '';
   foreach ($children_keys as $key) {
-    $output .= drupal_render($element[$key]);
+    if (!empty($element[$key])) {
+      $output .= drupal_render($element[$key]);
+    }
   }
   return $output;
 }
@@ -5119,7 +5114,9 @@ function drupal_render_cache_set($markup
 
   $data['#markup'] = $markup;
   // Persist attached data associated with this element.
-  $data['#attached'] = $elements['#attached'];
+  if (isset($elements['#attached'])) {
+    $data['#attached'] = $elements['#attached'];
+  }
   $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
   $expire = isset($elements['#cache']['expire']) ? $elements['#cache']['expire'] : CACHE_PERMANENT;
   cache_set($cid, $data, $bin, $expire);
@@ -5211,10 +5208,9 @@ function element_info($type) {
   $cache = &drupal_static(__FUNCTION__);
 
   if (!isset($cache)) {
-    $basic_defaults = element_basic_defaults();
     $cache = module_invoke_all('element_info');
     foreach ($cache as $element_type => $info) {
-      $cache[$element_type] = array_merge_recursive($basic_defaults, $info);
+      $cache[$element_type] = $info;
       $cache[$element_type]['#type'] = $element_type;
     }
     // Allow modules to alter the element type defaults.
@@ -5225,19 +5221,6 @@ function element_info($type) {
 }
 
 /**
- * Retrieve the basic default properties that are common to all elements.
- */
-function element_basic_defaults() {
-  return array(
-    '#description' => '',
-    '#title' => '',
-    '#attributes' => array(),
-    '#required' => FALSE,
-    '#attached' => array(),
-  );
-}
-
-/**
  * Function used by uasort to sort structured arrays by weight, without the property weight prefix.
  */
 function drupal_sort_weight($a, $b) {
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.391
diff -u -p -r1.391 form.inc
--- includes/form.inc	3 Nov 2009 05:27:18 -0000	1.391
+++ includes/form.inc	3 Nov 2009 19:45:30 -0000
@@ -824,7 +824,7 @@ function _form_validate($elements, &$for
       // A simple call to empty() will not cut it here as some fields, like
       // checkboxes, can return a valid value of '0'. Instead, check the
       // length if it's a string, and the item count if it's an array.
-      if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) {
+      if (!empty($elements['#required']) && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) {
         form_error($elements, $t('!name field is required.', array('!name' => $elements['#title'])));
       }
 
@@ -1008,7 +1008,7 @@ function form_builder($form_id, $element
   $element['#processed'] = FALSE;
 
   // Use element defaults.
-  if ((!empty($element['#type'])) && ($info = element_info($element['#type']))) {
+  if (isset($element['#type']) && ($info = element_info($element['#type']))) {
     // Overlay $info onto $element, retaining preexisting keys in $element.
     $element += $info;
     $element['#defaults_loaded'] = TRUE;
@@ -1737,7 +1737,19 @@ function theme_fieldset($variables) {
   }
   $element['#attributes']['id'] = $element['#id'];
 
-  return '<fieldset' . drupal_attributes($element['#attributes']) . '>' . ($element['#title'] ? '<legend>' . $element['#title'] . '</legend>' : '') . (isset($element['#description']) && $element['#description'] ? '<div class="fieldset-description">' . $element['#description'] . '</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . (isset($element['#value']) ? $element['#value'] : '') . "</fieldset>\n";
+  $output = '<fieldset' . drupal_attributes($element['#attributes']) . '>';
+  if (isset($element['#title'])) {
+    $output .= '<legend>' . $element['#title'] . '</legend>';
+  }
+  if (!empty($element['#description'])) {
+    $output .= '<div class="fieldset-description">' . $element['#description'] . '</div>';
+  }
+  $output .= $element['#children'];
+  if (isset($element['#value'])) {
+    $output .= $element['#value'];
+  }
+  $output .= "</fieldset>\n";
+  return $output;
 }
 
 /**
@@ -1763,7 +1775,8 @@ function theme_radio($variables) {
   $output .= 'value="' . $element['#return_value'] . '" ';
   $output .= (check_plain($element['#value']) == $element['#return_value']) ? ' checked="checked" ' : ' ';
   $output .= drupal_attributes($element['#attributes']) . ' />';
-  if (!is_null($element['#title'])) {
+
+  if (isset($element['#title'])) {
     $output = '<label class="option" for="' . $element['#id'] . '">' . $output . ' ' . $element['#title'] . '</label>';
   }
 
@@ -2113,7 +2126,7 @@ function theme_checkbox($variables) {
   $checkbox .= $element['#value'] ? ' checked="checked" ' : ' ';
   $checkbox .= drupal_attributes($element['#attributes']) . ' />';
 
-  if (!is_null($element['#title'])) {
+  if (isset($element['#title'])) {
     $checkbox = '<label class="option" for="' . $element['#id'] . '">' . $checkbox . ' ' . $element['#title'] . '</label>';
   }
 
@@ -2150,7 +2163,7 @@ function theme_checkboxes($variables) {
  * This is used as a pre render function for checkboxes and radios.
  */
 function form_pre_render_conditional_form_element($element) {
-  if ($element['#title'] || $element['#description']) {
+  if (isset($element['#title']) || isset($element['#description'])) {
     unset($element['#id']);
     $element['#theme_wrappers'][] = 'form_element';
   }
@@ -2817,7 +2830,7 @@ function _form_set_class(&$element, $cla
     }
     $element['#attributes']['class'] = array_merge($element['#attributes']['class'], $class);
   }
-  if ($element['#required']) {
+  if (!empty($element['#required'])) {
     $element['#attributes']['class'][] = 'required';
   }
   if (form_get_error($element)) {
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.836
diff -u -p -r1.836 system.module
--- modules/system/system.module	3 Nov 2009 06:47:23 -0000	1.836
+++ modules/system/system.module	3 Nov 2009 19:45:30 -0000
@@ -292,6 +292,7 @@ function system_element_info() {
     '#method' => 'post',
     '#action' => request_uri(),
     '#theme_wrappers' => array('form'),
+    '#attributes' => array(),
   );
   $types['page'] = array(
     '#show_messages' => TRUE,
@@ -353,6 +354,7 @@ function system_element_info() {
     '#process' => array('form_process_text_format', 'ajax_process_form'),
     '#theme' => 'textfield',
     '#theme_wrappers' => array('form_element'),
+    '#attributes' => array(),
   );
   $types['password'] = array(
     '#input' => TRUE,
@@ -381,6 +383,7 @@ function system_element_info() {
     '#process' => array('form_process_radios'),
     '#theme_wrappers' => array('radios'),
     '#pre_render' => array('form_pre_render_conditional_form_element'),
+    '#attributes' => array(),
   );
   $types['radio'] = array(
     '#input' => TRUE,
@@ -396,6 +399,7 @@ function system_element_info() {
     '#process' => array('form_process_checkboxes'),
     '#theme_wrappers' => array('checkboxes'),
     '#pre_render' => array('form_pre_render_conditional_form_element'),
+    '#attributes' => array(),
   );
   $types['checkbox'] = array(
     '#input' => TRUE,
@@ -440,6 +444,7 @@ function system_element_info() {
     '#options' => array(),
     '#empty' => '',
     '#theme' => 'tableselect',
+    '#attributes' => array(),
   );
 
   // Form structure.
@@ -452,6 +457,7 @@ function system_element_info() {
     '#input' => TRUE,
     '#process' => array('ajax_process_form'),
     '#theme' => 'hidden',
+    '#attributes' => array(),
   );
   $types['value'] = array(
     '#input' => TRUE,
@@ -484,7 +490,8 @@ function system_element_info() {
 
   $types['token'] = array(
     '#input' => TRUE,
-    '#theme' => array('hidden'),
+    '#theme' => 'hidden',
+    '#attributes' => array(),
   );
 
   return $types;
Index: themes/seven/template.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/seven/template.php,v
retrieving revision 1.8
diff -u -p -r1.8 template.php
--- themes/seven/template.php	2 Nov 2009 00:25:32 -0000	1.8
+++ themes/seven/template.php	4 Nov 2009 00:59:26 -0000
@@ -91,5 +91,17 @@ function seven_fieldset($variables) {
   }
   $element['#attributes']['id'] = $element['#id'];
 
-  return '<fieldset' . drupal_attributes($element['#attributes']) . '>' . ($element['#title'] ? '<legend><span>' . $element['#title'] . '</span></legend>' : '') . (isset($element['#description']) && $element['#description'] ? '<div class="fieldset-description">' . $element['#description'] . '</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . (isset($element['#value']) ? $element['#value'] : '') . "</fieldset>\n";
+  $output = '<fieldset' . drupal_attributes($element['#attributes']) . '>';
+  if (isset($element['#title'])) {
+    $output .= '<legend><span>' . $element['#title'] . '</span></legend>';
+  }
+  if (!empty($element['#description'])) {
+    $output .= '<div class="fieldset-description">' . $element['#description'] . '</div>';
+  }
+  $output .= $element['#children'];
+  if (isset($element['#value'])) {
+    $output .= $element['#value'];
+  }
+  $output .= "</fieldset>\n";
+  return $output;
 }
