[issue18082] Inconsistent behavior of IOBase methods on closed files

2013-05-28 Thread Dwight Guth

New submission from Dwight Guth:

Consider the following program:

import io 
class A(io.IOBase): 
  def __init__(self): 
self.x = 5 
  def read(self, limit=-1): 
self.x -= 1 
if self.x > 0: 
  return b"5" 
return b"" 
  def seek(self, offset, whence=0): 
return 0 
  def write(self, b): 
pass 
 
a = A() 
a.close() 
assert a.__next__() == b"" 
assert a.readline() == b"" 
assert a.tell() == 0

These three operations succeed, even though the file is closed. However, these 
two operations fail:

a.readlines()
a.writelines([])

Why do some of the mixin methods on IOBase call _checkClosed and others don't?

--
components: IO
messages: 190224
nosy: dwight.guth
priority: normal
severity: normal
status: open
title: Inconsistent behavior of IOBase methods on closed files
type: behavior
versions: Python 3.3

___
Python tracker 
<http://bugs.python.org/issue18082>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15903] Make rawiobase_read() read directly to bytes object

2013-06-01 Thread Dwight Guth

Dwight Guth added the comment:

I was programming something today and thought I should let you know I came 
across a situation where the current behavior of this function is able to 
expose what seems to be raw memory to the user.

import io
class A(io.RawIOBase):
  def readinto(self, b):
return len(b)

A().read(100)

--
nosy: +dwight.guth

___
Python tracker 
<http://bugs.python.org/issue15903>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17983] global __class__ statement in class declaration

2013-05-15 Thread Dwight Guth

New submission from Dwight Guth:

The following python program causes cpython to crash:

class A:
  global __class__
  def a(self):
super()

I get the following output on the console:

bug.py:2: SyntaxWarning: name '__class__' is assigned to before global 
declaration
  global __class__
lookup '__class__' in � a sequ 2 -1
freevars of A: ('__class__',)
Fatal Python error: compiler_make_closure()

Current thread 0x7fc712192700:
Aborted (core dumped)

This probably happens because __class__ is handled specially by the scoping 
rules and isn't expected to be anything other than a member of co_cellvars. It 
should probably throw an exception instead (SystemError?)

--
messages: 189293
nosy: dwight.guth
priority: normal
severity: normal
status: open
title: global __class__ statement in class declaration
type: crash
versions: Python 3.3

___
Python tracker 
<http://bugs.python.org/issue17983>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com