Skip to content

lurking py3 error #25

@CarlFK

Description

@CarlFK

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions