[Python] path.py : isdir() raises an error when using python 2.7.3

Loading the same path.py module into a 2.6.4 and 2.7.3 session produces different results when calling Path(path/to/file).isdir()

2.6.4 works as expected - outputs True or False
2.7.3 raises a TypeError: TypeError: _isdir() takes exactly 1 argument (0 given)

Anyone know why the behavior changed?

This is an easy manual fix except that we also use pymel which ships with its own path.py module that pymel calls return. Replacing that on each user’s machine is more involved and I was hoping for an easier solution.

I can’t find any instance of _isdir, so I’m assuming it’s in a binary somewhere. The implementations of os.path.isdir() are the same between python 2.6.4 and 2.7.3

This issue can be simplified to just this:

import os.path
 
path = 'c:\	emp'
class foo(unicode):        
    isdir = os.path.isdir
   
foo(path).isdir()
# 2.6.4 # True
# 2.7.3 # TypeError: _isdir() takes exactly 1 argument (0 given) #
 
print os.path.isdir(path)
# 2.6.4 # True
# 2.7.3 # True

Turns out this was an issue caused by a backported change to os.path.isdir from python3 to 2.7.3.

The old isdir function still works, so to temporarily get around this issue I added this to my userSetup.py:

if sys.version_info >= (2, 7, 3):
    import genericpath
    os.path.isdir = genericpath.isdir

genericpath.isdir is the fallback isdir that was being used prior to 2.7.3.
Details on the change that caused the issue: cpython: f1509fc75435

It also turns out that there is a new version of path.py that fixes this issue (along with others) [GitHub - jaraco/path: Object-oriented file system path manipulation]. This updated path.py has been committed to the master pymel branch (thanks chadrik), which I’m guessing will be included in the next maya release [Commits · LumaPictures/pymel · GitHub].