This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Exception on mode 'br'
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Sworddragon, chris.jerdonek, pitrou
Priority: normal Keywords:

Created on 2012-12-06 06:43 by Sworddragon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
error.log Sworddragon, 2012-12-06 06:43 Exception on open() wth mode 'br'
Messages (3)
msg177028 - (view) Author: (Sworddragon) Date: 2012-12-06 06:43
The mode 'br' on open() can cause an exception with the following message: "ValueError: mode string must begin with one of 'r', 'w', 'a' or 'U', not 'br'". Curriously most times the mode 'br' is working fine and I'm not able to create a simple test case where it fails. Only in one of my scripts it fails with an exception (in the attachments is an example).
msg177031 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-12-06 08:43
Is this issue just for 2.7?  3.3 was selected as the affected version, but the error message text seems limited to 2.7:

http://hg.python.org/cpython/file/0adfbafe8a99/Objects/fileobject.c#l303

The exception can be reproduced simply using 2.7:

>>> open('foo', 'br')
ValueError: mode string must begin with one of 'r', 'w', 'a' or 'U', not 'br'

Moreover, the 2.7 documentation says that "b" must be appended (in particular occurring after "r"), which to me means that the exception and message is correct:

http://docs.python.org/2/library/functions.html#open
msg177032 - (view) Author: (Sworddragon) Date: 2012-12-06 09:00
> Is this issue just for 2.7?  3.3 was selected as the affected version, but the error message text seems limited to 2.7

You have given me a good hint. My script is running on python3 with the shbang line "#!/usr/bin/python3 -OOtt". But it makes a subcall to python (which defaults to python2.7) instead of python3. This explains why I couldn't even reproduce this with a simple script.
History
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60829
2012-12-06 09:02:03ezio.melottisetstage: resolved
2012-12-06 09:00:43Sworddragonsetstatus: open -> closed
resolution: not a bug
messages: + msg177032
2012-12-06 08:43:18chris.jerdoneksetnosy: + chris.jerdonek
messages: + msg177031
2012-12-06 07:28:15ezio.melottisetnosy: + pitrou
2012-12-06 06:43:23Sworddragoncreate