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

Running upload() on python 3 fails #53

Open
andybelov opened this issue Sep 6, 2017 · 3 comments
Open

Running upload() on python 3 fails #53

andybelov opened this issue Sep 6, 2017 · 3 comments

Comments

@andybelov
Copy link

Running upload() on python 3 leads to the error because basestring is no longer available in Python 3.

Stack trace:

def upload(self, local_path_or_fileobj, remote_path):
--> 153         if isinstance(local_path_or_fileobj, basestring):
    154             with open(local_path_or_fileobj, 'rb') as f:
    155                 self._upload(f, remote_path)

NameError: name 'basestring' is not defined
@afsneto
Copy link

afsneto commented Nov 24, 2017

Just insert at the beginning of the code (after import statements):

try:
    unicode = unicode
except NameError:
    # 'unicode' is undefined, must be Python 3
    str = str
    unicode = str
    bytes = bytes
    basestring = (str,bytes)
else:
    # 'unicode' exists, must be Python 2
    str = str
    unicode = unicode
    bytes = str
    basestring = basestring

@Duaard
Copy link

Duaard commented Jan 15, 2018

Inserting the code snippet after import statements did not work for me, as it only changes the basestring value for the class it is being imported to, where it should be changed inside the easywebdav.py

As a work around I just cloned easywebdav.py and inserted the code snippet after the checking of py_majversion.

@Duaard
Copy link

Duaard commented Jan 15, 2018

My bad, I misunderstood the instruction. It was supposed to be inserted after the import statements IN THE ORIGINAL SCRIPT 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants