Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#20604 closed Bug (fixed)

Managing Files File code example opens file in write-mode, should open in read-mode

Reported by: Chris Lasher <chris.lasher@…> Owned by: nobody
Component: Documentation Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In the second code example in the Managing Files documentation on the File object, the file /tmp/hello.world is shown as being opened in write-mode, but it should actually be opened in read mode. Write-mode would destroy the contents of the file.

In other words, please change this

# Create a Python file object using open() and the with statement
>>> with open('/tmp/hello.world', 'w') as f:
>>>     myfile = File(f)
...

to this

# Create a Python file object using open() and the with statement
>>> with open('/tmp/hello.world') as f:
>>>     myfile = File(f)
...

Change History (2)

comment:1 by Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In a1122e14a6d2ace8907923507e7d31c44a6f7c68:

Fixed #20604 - Fixed file example in docs.

Thanks Chris Lasher for the report.

comment:2 by Tim Graham <timograham@…>, 12 years ago

In e411e9931272cd22247095fc2af8d26d58eeddd6:

[1.5.x] Fixed #20604 - Fixed file example in docs.

Thanks Chris Lasher for the report.

Backport of a1122e14a6 from master

Note: See TracTickets for help on using tickets.
Back to Top