| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Jython
Revision: 5215
Author: zyasoft
Date: 20 Aug 2008 02:54:10
Changes:A class definition needs to have __module__ set in frame locals, so
that it is accessible by a metaclass, if defined.
Fixes test_advice in zope.interfaces
Files:| ... | ...@@ -282,6 +282,20 @@ | |
| 282 | 282 | throw Py.NameError(String.format(NAME_ERROR_MSG, index)); |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | public PyObject getname_or_null(String index) { | |
| 286 | PyObject ret; | |
| 287 | if (f_locals == null || f_locals == f_globals) { | |
| 288 | ret = doGetglobal(index); | |
| 289 | } else { | |
| 290 | ret = f_locals.__finditem__(index); | |
| 291 | if (ret != null) { | |
| 292 | return ret; | |
| 293 | } | |
| 294 | ret = doGetglobal(index); | |
| 295 | } | |
| 296 | return ret; | |
| 297 | } | |
| 298 | ||
| 285 | 299 | public PyObject getglobal(String index) { |
| 286 | 300 | PyObject ret = doGetglobal(index); |
| 287 | 301 | if (ret != null) { |
| ... | ...@@ -405,6 +405,29 @@ | |
| 405 | 405 | |
| 406 | 406 | CodeCompiler compiler = new CodeCompiler(this, printResults); |
| 407 | 407 | |
| 408 | if (classBody) { | |
| 409 | Label label_got_name = new Label(); | |
| 410 | int module_tmp = c.getLocal("org/python/core/PyObject"); | |
| 411 | ||
| 412 | c.aload(1); | |
| 413 | c.ldc("__module__"); | |
| 414 | c.invokevirtual("org/python/core/PyFrame", "getname_or_null", "(" + $str + ")" + $pyObj); | |
| 415 | c.dup(); | |
| 416 | c.ifnonnull(label_got_name); | |
| 417 | ||
| 418 | c.pop(); | |
| 419 | c.aload(1); | |
| 420 | c.ldc("__name__"); | |
| 421 | c.invokevirtual("org/python/core/PyFrame", "getname_or_null", "(" + $str + ")" + $pyObj); | |
| 422 | ||
| 423 | c.label(label_got_name); | |
| 424 | c.astore(module_tmp); | |
| 425 | c.aload(1); | |
| 426 | c.ldc("__module__"); | |
| 427 | c.aload(module_tmp); | |
| 428 | c.invokevirtual("org/python/core/PyFrame", "setlocal", "(" + $str + $pyObj + ")V"); | |
| 429 | } | |
| 430 | ||
| 408 | 431 | Label genswitch = new Label(); |
| 409 | 432 | if (scope.generator) { |
| 410 | 433 | c.goto_(genswitch); |