Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: type object 'NullTranslations' has no attribute '_instance' #21

Closed
tylerjw opened this issue Oct 21, 2019 · 5 comments
Closed
Labels

Comments

@tylerjw
Copy link

tylerjw commented Oct 21, 2019

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'
@davidfoerster
Copy link
Owner

Thanks for your report. I’m investigating the issue.

@ed-dev
Copy link

ed-dev commented Oct 23, 2019

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'

@davidfoerster
Copy link
Owner

davidfoerster commented Oct 24, 2019

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.

@ed-dev
Copy link

ed-dev commented Oct 24, 2019

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

@davidfoerster
Copy link
Owner

davidfoerster commented Oct 24, 2019

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.

davidfoerster added a commit that referenced this issue Oct 27, 2019
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.
davidfoerster added a commit that referenced this issue Oct 27, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants