classification
Title: global __class__ statement in class declaration
Type: crash Stage: resolved
Components: Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: benjamin.peterson, dwight.guth, python-dev
Priority: normal Keywords:

Created on 2013-05-15 19:00 by dwight.guth, last changed 2013-05-15 21:19 by python-dev. This issue is now closed.

Messages (2)
msg189293 - (view) Author: Dwight Guth (dwight.guth) Date: 2013-05-15 19:00
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 0x00007fc712192700:
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?)
msg189306 - (view) Author: Roundup Robot (python-dev) Date: 2013-05-15 21:19
New changeset cd9141a4f999 by Benjamin Peterson in branch '3.3':
complain about "global __class__" in a class body (closes #17983)
http://hg.python.org/cpython/rev/cd9141a4f999
History
Date User Action Args
2013-05-15 21:19:04python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg189306

resolution: fixed
stage: resolved
2013-05-15 19:02:54benjamin.petersonsetassignee: benjamin.peterson

nosy: + benjamin.peterson
2013-05-15 19:00:10dwight.guthcreate