direct.stdpy.file tell() can cause exceptions, and lacks 'with' support

Bug #632883 reported by Craig Macomber
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Panda3D
Fix Released
Undecided
David Rose

Bug Description

from direct.stdpy import file
file.open('test.txt','wb').tell()

"""
Causes this error:
Traceback (most recent call last):
  File "test.py", line 2, in <module>
    file.open('test.txt','wb').tell()
  File "/Developer/Panda3D/lib/direct/stdpy/file.py", line 218, in tell
    raise ValueError
ValueError
"""

with file.open('test.txt','wb') as f:
    pass

"""
Causes this error:
Traceback (most recent call last):
  File "/Users/Craig/Desktop/test.py", line 14, in <module>
    with file.open('test.txt','wb') as f:
AttributeError: file instance has no attribute '__exit__'
"""

# direct.stdpy.file does not support tell() in some cases (perhaps just before any reading or writing?)
# direct.stdpy.file does not support being used with 'with' blocks
# these are supported by python's file objects,
# and losing these features when the runtime replaces the builtin open method can
# cause confusing and annoying issues

# Tested on Mac OS 10.5 and 10.6 (intel) with panda 1.7.0

Revision history for this message
David Rose (droklaunchpad) wrote :

First bug fix committed as version 1.13 of file.py.

Second bug was previously reported and already fixed on trunk.

Changed in panda3d:
status: New → Fix Committed
milestone: none → 1.7.1
rdb (rdb)
Changed in panda3d:
assignee: nobody → David Rose (droklaunchpad)
rdb (rdb)
Changed in panda3d:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.