Can't disable buffering on std streams in Python 3.

Breakthrough! If I set PYTHONPATH weirdly, I can now start make.py in a directory without a Makefile.

    $ set PYTHONPATH=%PWD%;%PWD%\pymake
    $ which python
    C:\Python33\python.EXE
    $ python make.py
    make.py[0]: Entering directory 'D:\dev\pymake'
    No makefile found
    $

There are still a few ``xrange`` calls in there, that's my next target. Then I'll probably need some help with untangling dependencies so I can start packaging.
On Thu, Jul 3, 2014 at 8:56 AM, Gregory Szorc <notifications@github.com>
wrote:

> In make.py:
>
> > @@ -12,8 +12,13 @@
> >  import gc
> >
> >  if __name__ == '__main__':
> > -  sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
> > -  sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
> > +  if sys.version_info < (3,0):
> > +    sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
> > +    sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
> > +  else:
> > +    # Unbuffered text I/O is not allowed in Python 3.
> > +    sys.stdout = os.fdopen(sys.stdout.fileno(), 'w')
> > +    sys.stderr = os.fdopen(sys.stderr.fileno(), 'w')
>
> What happens if you open the file in 'wb' mode? Unbuffered bytes I/O
> should work. Now, you'll likely get a type mismatch between str and bytes
> writing to stdout and stderr. Perhaps we could install a proxy that will v.encode('utf-8',
> 'ignore') until all output is bytes?
>
I don't fully understand why you want to treat output as bytes. It seems
like a downside to me to explicitly convert rather than having Python do it.

We're not in control of input encodings, so we may run into oddities, but
output should just work, right?

- Kim