Ticket #3534 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

hSetBinaryMode fails after some input has been read

Reported by: judah Owned by: simonmar
Priority: high Milestone: 6.12.1
Component: libraries/base Version: 6.11
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

For the following program (BadSeek.hs), type a couple characters of input and press return. With ghc-6.10.3, it works fine; with ghc-6.11 it throws an error.

module Main where

import System.IO

main = do   
    getChar >>= print
    hSetBinaryMode stdin True
    getChar >>= print

With ghc-6.10:

$ ./BadSeek 
ab
'a'
'b'

With ghc-6.11:

$ ./BadSeek
ab
'a'
BadSeek: <stdin>: hSetBinaryMode: illegal operation (cannot flush the read buffer of a text-mode handle)

The error goes away if the first 'getChar' is commented out.

For libraries which are not yet using the Unicode I/O layer, having a way to temporarily set stdin to BinaryMode would be useful.

Change History

Changed 4 years ago by simonmar

  • owner set to simonmar
  • difficulty set to Unknown
  • priority changed from normal to high
  • milestone set to 6.12.1

Changed 4 years ago by simonmar

  • status changed from new to closed
  • resolution set to fixed

Fixed

Wed Sep 23 10:04:45 BST 2009  Simon Marlow <marlowsd@gmail.com>
  * Fix #3534: No need to flush the byte buffer when setting binary mode
Note: See TracTickets for help on using tickets.