Issue2290
Created on 2015-03-13.11:28:49 by Arfrever, last changed 2018-03-23.22:26:19 by jeff.allen.
Messages | |||
---|---|---|---|
msg9643 (view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) | Date: 2015-03-13.11:28:48 | |
Setting of attributes of sys module raises internal exceptions (java.lang.IllegalAccessException) in case of some attributes. Amongst non-internal exceptions, there is inconsistency: AttributeError, TypeError. $ cat set_attributes_of_sys_module.py import sys import traceback for x in dir(sys): try: setattr(sys, x, getattr(sys, x)) except: print("\x1B[1;31mSetting of sys.%s failed\x1B[0m" % x) traceback.print_exc() else: print("\x1B[1;32mSetting of sys.%s succeeded\x1B[0m" % x) $ CPython: $ python2.7 set_attributes_of_sys_module.py Setting of sys.__displayhook__ succeeded Setting of sys.__doc__ succeeded Setting of sys.__excepthook__ succeeded Setting of sys.__name__ succeeded Setting of sys.__package__ succeeded Setting of sys.__stderr__ succeeded Setting of sys.__stdin__ succeeded Setting of sys.__stdout__ succeeded Setting of sys._clear_type_cache succeeded Setting of sys._current_frames succeeded Setting of sys._getframe succeeded Setting of sys._mercurial succeeded Setting of sys.api_version succeeded Setting of sys.argv succeeded Setting of sys.builtin_module_names succeeded Setting of sys.byteorder succeeded Setting of sys.call_tracing succeeded Setting of sys.callstats succeeded Setting of sys.copyright succeeded Setting of sys.displayhook succeeded Setting of sys.dont_write_bytecode succeeded Setting of sys.exc_clear succeeded Setting of sys.exc_info succeeded Setting of sys.exc_type succeeded Setting of sys.excepthook succeeded Setting of sys.exec_prefix succeeded Setting of sys.executable succeeded Setting of sys.exit succeeded Setting of sys.flags succeeded Setting of sys.float_info succeeded Setting of sys.float_repr_style succeeded Setting of sys.getcheckinterval succeeded Setting of sys.getdefaultencoding succeeded Setting of sys.getdlopenflags succeeded Setting of sys.getfilesystemencoding succeeded Setting of sys.getprofile succeeded Setting of sys.getrecursionlimit succeeded Setting of sys.getrefcount succeeded Setting of sys.getsizeof succeeded Setting of sys.gettrace succeeded Setting of sys.hexversion succeeded Setting of sys.long_info succeeded Setting of sys.maxint succeeded Setting of sys.maxsize succeeded Setting of sys.maxunicode succeeded Setting of sys.meta_path succeeded Setting of sys.modules succeeded Setting of sys.path succeeded Setting of sys.path_hooks succeeded Setting of sys.path_importer_cache succeeded Setting of sys.platform succeeded Setting of sys.prefix succeeded Setting of sys.py3kwarning succeeded Setting of sys.setcheckinterval succeeded Setting of sys.setdlopenflags succeeded Setting of sys.setprofile succeeded Setting of sys.setrecursionlimit succeeded Setting of sys.settrace succeeded Setting of sys.stderr succeeded Setting of sys.stdin succeeded Setting of sys.stdout succeeded Setting of sys.subversion succeeded Setting of sys.version succeeded Setting of sys.version_info succeeded Setting of sys.warnoptions succeeded Jython: $ jython2.7 set_attributes_of_sys_module.py Setting of sys.JYTHON_DEV_JAR failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final java.lang.String field org.python.core.PySystemState.JYTHON_DEV_JAR to java.lang.String Setting of sys.JYTHON_JAR failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final java.lang.String field org.python.core.PySystemState.JYTHON_JAR to java.lang.String Setting of sys.PYTHON_CACHEDIR failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final java.lang.String field org.python.core.PySystemState.PYTHON_CACHEDIR to java.lang.String Setting of sys.PYTHON_CACHEDIR_SKIP failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final java.lang.String field org.python.core.PySystemState.PYTHON_CACHEDIR_SKIP to java.lang.String Setting of sys.PYTHON_CONSOLE_ENCODING failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final java.lang.String field org.python.core.PySystemState.PYTHON_CONSOLE_ENCODING to java.lang.String Setting of sys.PYTHON_IO_ENCODING failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final java.lang.String field org.python.core.PySystemState.PYTHON_IO_ENCODING to java.lang.String Setting of sys.PYTHON_IO_ERRORS failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final java.lang.String field org.python.core.PySystemState.PYTHON_IO_ERRORS to java.lang.String Setting of sys.__delattr__ succeeded Setting of sys.__dict__ failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) TypeError: readonly attribute Setting of sys.__displayhook__ succeeded Setting of sys.__excepthook__ succeeded Setting of sys.__findattr_ex__ succeeded Setting of sys.__name__ succeeded Setting of sys.__new__ succeeded Setting of sys.__rawdir__ succeeded Setting of sys.__setattr__ succeeded Setting of sys.__stderr__ succeeded Setting of sys.__stdin__ succeeded Setting of sys.__stdout__ succeeded Setting of sys._getframe succeeded Setting of sys._jy_console succeeded Setting of sys._mercurial failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final org.python.core.PyTuple field org.python.core.PySystemState._mercurial to org.python.core.PyTuple Setting of sys._systemRestart succeeded Setting of sys.add_classdir succeeded Setting of sys.add_extdir succeeded Setting of sys.add_package succeeded Setting of sys.argv succeeded Setting of sys.builtin_module_names succeeded Setting of sys.builtins succeeded Setting of sys.byteorder failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final org.python.core.PyString field org.python.core.PySystemState.byteorder to org.python.core.PyString Setting of sys.classDictInit succeeded Setting of sys.classLoader succeeded Setting of sys.cleanup succeeded Setting of sys.close succeeded Setting of sys.codecState failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) AttributeError: read-only attr: codecState Setting of sys.copyright failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final org.python.core.PyObject field org.python.core.PySystemState.copyright to org.python.core.PyString Setting of sys.currentWorkingDir succeeded Setting of sys.defaultencoding failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) AttributeError: read-only attr: defaultencoding Setting of sys.displayhook succeeded Setting of sys.doInitialize succeeded Setting of sys.dont_write_bytecode succeeded Setting of sys.exc_clear succeeded Setting of sys.exc_info succeeded Setting of sys.excepthook succeeded Setting of sys.exec_prefix failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) TypeError: readonly attribute Setting of sys.executable succeeded Setting of sys.exit succeeded Setting of sys.filesystemencoding failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) AttributeError: read-only attr: filesystemencoding Setting of sys.flags failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final java.lang.Class field org.python.core.PySystemState.flags to java.lang.Class Setting of sys.float_info failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final org.python.core.PyObject field org.python.core.PySystemState.float_info to org.python.core.FloatInfo Setting of sys.float_repr_style failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final org.python.core.PyString field org.python.core.PySystemState.float_repr_style to org.python.core.PyString Setting of sys.getBaseProperties succeeded Setting of sys.getBuiltin succeeded Setting of sys.getBuiltins succeeded Setting of sys.getClassLoader succeeded Setting of sys.getCodecState succeeded Setting of sys.getCurrentWorkingDir succeeded Setting of sys.getDefaultBuiltins succeeded Setting of sys.getFile succeeded Setting of sys.getImportLock succeeded Setting of sys.getPath succeeded Setting of sys.getPathLazy succeeded Setting of sys.getPlatform succeeded Setting of sys.getSyspathJavaLoader succeeded Setting of sys.getWarnoptions succeeded Setting of sys.getdefaultencoding succeeded Setting of sys.getfilesystemencoding succeeded Setting of sys.getprofile succeeded Setting of sys.getrecursionlimit succeeded Setting of sys.gettrace succeeded Setting of sys.hexversion failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final int field org.python.core.PySystemState.hexversion to java.lang.Integer Setting of sys.importLock failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) AttributeError: read-only attr: importLock Setting of sys.initialize succeeded Setting of sys.isPackageCacheEnabled succeeded Setting of sys.last_traceback succeeded Setting of sys.last_type succeeded Setting of sys.last_value succeeded Setting of sys.long_info failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final org.python.core.PyObject field org.python.core.PySystemState.long_info to org.python.core.LongInfo Setting of sys.maxint failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final int field org.python.core.PySystemState.maxint to java.lang.Integer Setting of sys.maxsize failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final int field org.python.core.PySystemState.maxsize to java.lang.Integer Setting of sys.maxunicode failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final int field org.python.core.PySystemState.maxunicode to java.lang.Integer Setting of sys.meta_path succeeded Setting of sys.minint failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final int field org.python.core.PySystemState.minint to java.lang.Integer Setting of sys.modules succeeded Setting of sys.modules_reloading succeeded Setting of sys.packageManager failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) TypeError: readonly attribute Setting of sys.path succeeded Setting of sys.path_hooks succeeded Setting of sys.path_importer_cache succeeded Setting of sys.platform succeeded Setting of sys.prefix succeeded Setting of sys.ps1 succeeded Setting of sys.ps2 succeeded Setting of sys.py3kwarning succeeded Setting of sys.recursionlimit succeeded Setting of sys.refersDirectlyTo succeeded Setting of sys.registerCloser succeeded Setting of sys.registry failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) TypeError: readonly attribute Setting of sys.setBuiltins succeeded Setting of sys.setClassLoader succeeded Setting of sys.setCurrentWorkingDir succeeded Setting of sys.setPlatform succeeded Setting of sys.setWarnoptions succeeded Setting of sys.setprofile succeeded Setting of sys.setrecursionlimit succeeded Setting of sys.settrace succeeded Setting of sys.shadow succeeded Setting of sys.stderr succeeded Setting of sys.stdin succeeded Setting of sys.stdout succeeded Setting of sys.subversion failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final org.python.core.PyTuple field org.python.core.PySystemState.subversion to org.python.core.PyTuple Setting of sys.syspathJavaLoader failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) AttributeError: read-only attr: syspathJavaLoader Setting of sys.toString succeeded Setting of sys.traverse succeeded Setting of sys.unregisterCloser succeeded Setting of sys.version failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final org.python.core.PyString field org.python.core.PySystemState.version to org.python.core.PyString Setting of sys.version_info failed Traceback (most recent call last): File "set_attributes_of_sys_module.py", line 5, in <module> setattr(sys, x, getattr(sys, x)) IllegalAccessException: java.lang.IllegalAccessException: Can not set static final org.python.core.PyTuple field org.python.core.PySystemState.version_info to org.python.core.PyTuple |
|||
msg9645 (view) | Author: Jim Baker (zyasoft) | Date: 2015-03-13.18:36:58 | |
Agreed, these should be raised as AttributeError instead of java.lang.IllegalAccessException Should be an easy fix in PySystemState#__setattr__ (and also __delattr__) |
|||
msg9672 (view) | Author: Jim Baker (zyasoft) | Date: 2015-03-18.03:25:04 | |
Defer to 2.7.1 |
History | |||
---|---|---|---|
Date | User | Action | Args |
2018-03-23 22:26:19 | jeff.allen | set | resolution: accepted milestone: Jython 2.7.2 -> |
2015-12-29 23:46:55 | zyasoft | set | milestone: Jython 2.7.1 -> Jython 2.7.2 |
2015-04-20 20:55:35 | zyasoft | set | milestone: Jython 2.7.1 |
2015-03-18 03:25:04 | zyasoft | set | priority: high messages: + msg9672 |
2015-03-13 18:36:58 | zyasoft | set | messages: + msg9645 |
2015-03-13 11:28:49 | Arfrever | create |
Supported by Python Software Foundation,
Powered by Roundup