Skip to content

CPython Issue with pathlib #1287

@CyrilWaechter

Description

@CyrilWaechter

Describe the bug
There is an issue with CPython engine inside Revit only. It looks like it uses an old version of pathlib where exist_ok did not exist. This feature was apparently introduced in python 3.5.

To Reproduce
Steps to reproduce the behavior:

  1. Create a script containing following code:
#! python3
from pathlib import Path

Path("test").mkdir(parents=True, exist_ok=True)
  1. Execute this script
  2. See error:
CPython Traceback:
TypeError : mkdir() got an unexpected keyword argument 'exist_ok'
 File "<path_to_script_folder>\script.py", line 8, in <module>
Path("test").mkdir(parents=True, exist_ok=True)

pyRevitLabs.PythonNet
à Python.Runtime.Runtime.CheckExceptionOccurred()
 à Python.Runtime.PyScope.Exec(String code, IntPtr _globals, IntPtr _locals)
 à PyRevitLabs.PyRevit.Runtime.CPythonEngine.Execute(ScriptRuntime& runtime)

Expected behavior
This should work like when you run it in the python engine directly:

<path_to_pyRevit>\pyRevit\bin\engines\CPY385 (master -> origin)
λ python
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
>>> from pathlib import Path
>>> Path("test").mkdir(parents=True, exist_ok=True)
>>>

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10
  • pyRevit Version: 4.8.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed Old IssueIssue older than a year. Thanks for pointing it out. If you feel it is still relevant, feel free toHeisenbugBug that is very hard to find [class]Python 3Issues related to cpython engines [subsystem]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions