[Patches] [ python-Patches-462522 ] code.py softspace attribute fix

noreply@sourceforge.net noreply@sourceforge.net
Thu, 20 Sep 2001 08:26:02 -0700


Patches item #462522, was opened at 2001-09-18 04:55
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=462522&group_id=5470

Category: Modules
Group: None
>Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Michael Hudson (mwh)
Assigned to: Guido van Rossum (gvanrossum)
Summary: code.py softspace attribute fix

Initial Comment:
I *think* this is required as fallout from
the fact that

    ob.foo = 1

can raise AttributeError now.  To someone who
knows, this should be a no-brainer.


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-20 08:26

Message:
Logged In: YES 
user_id=6380

Thanks!

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2001-09-20 08:04

Message:
Logged In: YES 
user_id=6656

How's this?  It's a bit of a noddy exaple, to be sure...

I just remember being worried when I wrote softspace that it was being a bit fragile.

>>> class F(object):
...  def write(self, text):
...   sys.__stdout__.write(text)
...  def flush(self):
...   sys.__stdout__.flush()
...  softspace = property(lambda self:0)
...
>>> sys.stdout = F()
>>> import code
>>> code.interact()
Python 2.2a3+ (#1, Sep 18 2001, 07:44:02)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/crew/mwh/src/python/dist/src/Lib/code.py", line 307, in interact
    console.interact(banner)
  File "/home/crew/mwh/src/python/dist/src/Lib/code.py", line 244, in interact
    more = self.push(line)
  File "/home/crew/mwh/src/python/dist/src/Lib/code.py", line 266, in push
    more = self.runsource(source, self.filename)
  File "/home/crew/mwh/src/python/dist/src/Lib/code.py", line 87, in runsource
    self.runcode(code)
  File "/home/crew/mwh/src/python/dist/src/Lib/code.py", line 109, in runcode
    if softspace(sys.stdout, 0):
  File "/home/crew/mwh/src/python/dist/src/Lib/code.py", line 22, in softspace
    file.softspace = newvalue
AttributeError: can't set attribute
>>>


----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-18 06:34

Message:
Logged In: YES 
user_id=6380

I've checked this in, but I'm leaving it open for now: can
you show me how to reproduce the problem?

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=462522&group_id=5470