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

lurking py3 error #25

Open
CarlFK opened this issue Jun 28, 2016 · 1 comment
Open

lurking py3 error #25

CarlFK opened this issue Jun 28, 2016 · 1 comment

Comments

@CarlFK
Copy link
Contributor

CarlFK commented Jun 28, 2016

I am guessing this is using some undocumented behaviour:

self.HomeDirectory = os.path.join(os.path.split(val)[:-1])[0]
https://github.com/dabodev/dabo/blob/master/dabo/lib/reportWriter.py#L3149

this worked in 2.x and even 3.4.. but in python 3.5...

TypeError: join() argument must be str or bytes, not 'tuple'

in 2.7

os.path.join( ['a', 'b'] )
['a', 'b']

Python 3.5.1+ (default, Mar 30 2016, 22:46:26) 
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.join( ['a', 'b'] )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/veyepar/venvs/veyepar/lib/python3.5/posixpath.py", line 89, in join
    genericpath._check_arg_types('join', a, *p)
  File "/home/veyepar/venvs/veyepar/lib/python3.5/genericpath.py", line 143, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'list'
>>> os.path.join( ['a'] )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/veyepar/venvs/veyepar/lib/python3.5/posixpath.py", line 89, in join
    genericpath._check_arg_types('join', a, *p)
  File "/home/veyepar/venvs/veyepar/lib/python3.5/genericpath.py", line 143, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'list'
>>> 

A simple fix is to move the [0] :

os.path.join(os.path.split(val)[:-1][0])
'/home/veyepar/venvs/veyepar/lib/python3.5/site-packages/dabo-master/ide'
os.path.join(os.path.split(val)[:-1])[0]
'/home/veyepar/venvs/veyepar/lib/python3.5/site-packages/dabo-master/ide'

@jfabiani
Copy link
Contributor

jfabiani commented Aug 31, 2020 via email

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

2 participants