AttributeError: type object 'NullTranslations' has no attribute '_instance'
Closed this issue · 5 comments
Here is the output I get. I'm on Ubuntu 16.04 and am using the built in python3.5.
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "aptsources-cleanup.zip/__main__.py", line 8, in <module>
File "/usr/lib/python3.5/runpy.py", line 192, in run_module
mod_name, mod_spec, code = _get_module_details(mod_name)
File "/usr/lib/python3.5/runpy.py", line 133, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.5/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "aptsources-cleanup.zip/aptsources_cleanup/__init__.py", line 23, in <module>
File "aptsources-cleanup.zip/aptsources_cleanup/util/import_check.py", line 39, in import_check
File "aptsources-cleanup.zip/aptsources_cleanup/util/functools.py", line 137, in <lambda>
def _lt_from_gt(self, other, NotImplemented=NotImplemented):
File "aptsources-cleanup.zip/aptsources_cleanup/util/functools.py", line 102, in __getattr__
return not op_result and self != other
AttributeError: type object 'NullTranslations' has no attribute '_instance'
Thanks for your report. I’m investigating the issue.
Ubuntu 16.04, python 3.5.2
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "aptsources-cleanup.zip/__main__.py", line 8, in <module>
File "/usr/lib/python3.5/runpy.py", line 199, in run_module
return _run_code(code, {}, init_globals, run_name, mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "aptsources-cleanup.zip/aptsources_cleanup/__main__.py", line 365, in <module>
File "aptsources-cleanup.zip/aptsources_cleanup/__main__.py", line 32, in main
File "aptsources-cleanup.zip/aptsources_cleanup/__main__.py", line 196, in parse_args
File "aptsources-cleanup.zip/aptsources_cleanup/util/functools.py", line 137, in <lambda>
def _lt_from_gt(self, other, NotImplemented=NotImplemented):
File "aptsources-cleanup.zip/aptsources_cleanup/util/functools.py", line 102, in __getattr__
return not op_result and self != other
AttributeError: type object 'NullTranslations' has no attribute '_instance'
It took a while but I can reproduce the issue now. I had to install Python v3.5 since this never happens with v3.6. It also only happens when running the ZIP package (instead of unpackaged source code files).
I understand how it happens but not why.
Thanks. Using the source is a good work around. I downloaded the source, followed the README.md and it worked perfectly using v3.5.2
I think this is a bug in (Ubuntu’s) Python v3.5: In the class LazyInstance
, _instance
is a (known) @property
. Known attributes are not supposed to be accessed via the __getattr__
special method. Nonetheless, the attribute (property) access to self._instance
triggers a call to self.__getattr__('_instance')
. Weird. Even weirder that this only happens from within the ZIP code archive.
I worked around the issue with a regular instance method instead of a property and will push an update soon.