Voting starts in March for the Drupal Association Board election.
If you have a valid file_uri_scheme (e.g. public) and the directory exists then an attempt is made to use is_writable('public://mydirectory/myfile') which will return FALSE as we are passing a URI instead of full filename to is_writable
Using drupal_realpath($directory) will not always work either as passing a full filename to drupal_realpath instead of a URI will return FALSE from drupal_realpath.
I would suggest this:
$writable = is_writable(drupal_realpath($directory) == FALSE ? $directory : drupal_realpath($directory));