Index: pyyaml/trunk/ext/_yaml.pyx
===================================================================
--- pyyaml/trunk/ext/_yaml.pyx	(revision 361)
+++ pyyaml/trunk/ext/_yaml.pyx	(revision 366)
@@ -956,5 +956,5 @@
         self.dump_unicode = 0
         if PY_MAJOR_VERSION < 3:
-            if hasattr(stream, 'encoding'):
+            if getattr3(stream, 'encoding', None):
                 self.dump_unicode = 1
         else:
