[issue29252] self in classes missinterpreted as a string.

2017-05-17 Thread Decorater

Changes by Decorater :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29252] self in classes missinterpreted as a string.

2017-01-12 Thread Decorater

Decorater added the comment:

Also in the code I had to subclass it 3 times, 1 time to preserver original 
functionality as if the hook was not inserted in the front of the path hooks, 
another time for 1 format of files it should be able to allow importing of, and 
the other time for another format of files.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29252] self in classes missinterpreted as a string.

2017-01-12 Thread Decorater

Decorater added the comment:

Also I sadly have to make this a dummy class just to add in an actual 
dictionary with the file extensions it supports because I cant use setattr on 
it. It is retarded that you cant use it for builtin types or classes if your 
code actually requires such.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29252] self in classes missinterpreted as a string.

2017-01-12 Thread Decorater

New submission from Decorater:

So, I have a class (it subclasses the zipimporter for my import hook) that 
allows me to not worry about issues when the hook is appended to the beginning 
of the path hooks.

The code to the class as follows:

class OriginalZipImport(zipimport.zipimporter):
"""
Original zipimporter class. Modified for requirements of this import hook.
"""
# Sadly I have to manually specify the file extensions the original
# zipimporter supports to bypass an AttributeError.
# according to https://docs.python.org/3.6/library/zipimport.html
# zipimport only allows importing ``.py`` and ``.pyc`` files from zips.
extensions = ['.py', '.pyc']

def __init__(self, archivepath):
super(OriginalZipImport, self.inst).__init__(self, archivepath)

def find_loader(self, fullname, path=None):
"""
Original find_loader.
"""
self.inst.find_loader(fullname, path=path)

def find_module(self, fullname, path=None):
"""
Original find_module.
"""
self.inst.find_module(self, fullname, path=path)

def load_module(self, fullname):
"""
Original load_module.
"""
self.inst.load_module(self, fullname)

However instead of working like the way I would expect it gives this traceback:

Traceback (most recent call last):
  File "E:\Users\Elsword\Desktop\DecoraterBot\Async\\zipmaker\make_zip.py", 
line 11, in 
from pathlib import Path
  File "", line 961, in _find_and_load
  File "", line 946, in _find_and_load_unlocked
  File "", line 885, in _find_spec
  File "", line 1157, in find_spec
  File "", line 1129, in _get_spec
  File "", line 1273, in find_spec
  File "", line 1229, in _get_spec
  File 
"E:\Users\Elsword\Desktop\DecoraterBot\Async\zipmaker\py2pycx\_pycx_backend.py",
 line 180, in find_loader
self.inst.find_loader(fullname, path=path)
AttributeError: 'str' object has no attribute 'inst'

Note: it does use a slightly modified make_zip.py that is different than the 
one that is on the python source trees. It is specifically for testing the hook 
to see if it works or not.

The hook is supposed to work however it is confusing why it is doing this as I 
did not set self to be an string so it should allow me to do all of this just 
fine.

--
components: Interpreter Core
messages: 285316
nosy: Decorater
priority: normal
severity: normal
status: open
title: self in classes missinterpreted as a string.
versions: Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com