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

Ironpython 3.4:  issue with enum when using its None member ? #1873

Closed
CyrilWaechter opened this issue Jul 19, 2023 · 17 comments · Fixed by #1874
Closed

Ironpython 3.4:  issue with enum when using its None member ? #1873

CyrilWaechter opened this issue Jul 19, 2023 · 17 comments · Fixed by #1874
Labels
Engines Issues related to pyRevit execution engines [subsystem] IronPython Issues related to standalone IronPython installation [subsystem] Python 3 Issues related to cpython engines [subsystem]

Comments

@CyrilWaechter
Copy link
Contributor

CyrilWaechter commented Jul 19, 2023

Describe the bug
Apparently ironpython 3.4 has an issue with some Enum. It might be related to None member.
It affects apparently all script which using a WPFWindow.

from pyrevit.forms import WPFWindow

It triggers an error here:
https://github.com/eirannejad/pyRevit/blob/6aa2c493231f4301125f2570dc5efd644691bbad/pyrevitlib/rpw/ui/forms/taskdialog.py#L140

To Reproduce
Steps to reproduce the behavior:

  1. Use a script including following code:
from Autodesk.Revit.UI import TaskDialogResult
TaskDialogResult.None
  1. You should get an error message like:
TaskDialogResult.None
                 ^
SyntaxError: invalid syntax

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 11
  • pyRevit Version 4.8.13

Additional context
I found no related issue in ironpython repository.

@dosymep
Copy link
Member

dosymep commented Jul 19, 2023

Could you write this import and test?

from Autodesk.Revit.UI import TaskDialogResult

@CyrilWaechter
Copy link
Contributor Author

Could you write this import and test?

from Autodesk.Revit.UI import TaskDialogResult

It is what I did in steps To reproduce. Import works. Error is thrown when calling None member. (You can use revitpythonshell 2.0.1 to test, you get the same result)

@CyrilWaechter
Copy link
Contributor Author

CyrilWaechter commented Jul 19, 2023

Ah… Yes. Now I remember that I already encountered this issue on some of my CPython scripts. Thanks @dosymep

It is an easy fix. As rpw have not been updated for more than 4 years maybe we should commit directly to pyRevit ?
Although I do not understand yet why using WPFWindow needs to be related to rpw at all.

@Cyril-Pop
Copy link

Hi,
for info instead of
self.dialog.DefaultButton = UI.TaskDialogResult.None
you can also use
self.dialog.DefaultButton = UI.TaskDialogResult["None"]

there is an IronPython3 doc about upgrading from ipy2 here
https://github.com/IronLanguages/ironpython3/blob/v3.4.0/Documentation/upgrading-from-ipy2.md#none-is-a-keyword

@nodatasheet
Copy link
Contributor

there is also a method in coreutils for that: get_enum_none

@jmcouffin jmcouffin linked a pull request Aug 7, 2023 that will close this issue
@jmcouffin
Copy link
Contributor

@CyrilWaechter I did merge you PR but you may want to check if @nodatasheet link does the job

@CyrilWaechter
Copy link
Contributor Author

@CyrilWaechter I did merge you PR but you may want to check if @nodatasheet link does the job

The coreutils get_enum_none is using a loop and compare each value to None which is less efficient than a a dict call or whatever is used by standard ironpython function.

@jmcouffin jmcouffin added Python 3 Issues related to cpython engines [subsystem] IronPython Issues related to standalone IronPython installation [subsystem] Engines Issues related to pyRevit execution engines [subsystem] labels Sep 5, 2023
@jbf1212
Copy link
Contributor

jbf1212 commented Feb 7, 2024

The fix that was pushed for this appears to create an issue when the tool is still being run with IronPython 2. You will get the following error:
TypeError: expected Array[Type], got str

Is the plan going forward to deprecate support for IronPython 2?

@CyrilWaechter
Copy link
Contributor Author

The fix that was pushed for this appears to create an issue when the tool is still being run with IronPython 2. You will get the following error: TypeError: expected Array[Type], got str

Is the plan going forward to deprecate support for IronPython 2?

The fix works with ironpython 2. Ironpython 2.7.10 is still default on my setup and it still works fine.

@jbf1212
Copy link
Contributor

jbf1212 commented Feb 7, 2024

Okay, yea I'm seeing the issue on v 2.7.7. I'm not sure what pyRevit assumes the default version to be, but perhaps we can add a check here or something.

@CyrilWaechter
Copy link
Contributor Author

CyrilWaechter commented Feb 8, 2024

Okay, yea I'm seeing the issue on v 2.7.7. I'm not sure what pyRevit assumes the default version to be, but perhaps we can add a check here or something.

From what I remember ironpython 2.7.7 was maintained because it was shipped with Dynamo to ensure compatibility with Dynamo script. Dynamo have been shipping ironpython 2.7.9 from version 2.4.0 and ironpython2 evaluator is not shipped anymore from 2.13. If it is really an ironpython version issue I would vote to deprecate ironpython < 2.7.10.

2.7.7 was released in 2016… 8 years old. It’s time to update.

References:

Edit: also there was so many fixes between 2.7.7 and 2.7.10… When an user have an issue, checking ironpython version is first step to solve many issues.

@jmcouffin jmcouffin reopened this Feb 8, 2024
@jmcouffin
Copy link
Contributor

@CyrilWaechter what action do you suggest on the pyRevit repo side, if any?

@CyrilWaechter
Copy link
Contributor Author

CyrilWaechter commented Feb 8, 2024

@CyrilWaechter what action do you suggest on the pyRevit repo side, if any?

Remove older ironpython engines (At least < 2.7.9). I wonder if there is still a reason to ship multiple ironpython2 engines ? If not maybe it would worth even to ship only 2.7.12 which is the last version available.

On user side there might be a need to push ironpython engine update. Maybe:

  • Step 1 (pyRevit release n): warn user that older engines will be deprecated and propose them to update
  • Step 2 (pyRevit release n+1): remove deprecated engines

@dosymep
Copy link
Member

dosymep commented Feb 8, 2024

@jmcouffin, Maybe good idea support only latest version IronPython2, IronPython3 and PythonNet

@jmcouffin
Copy link
Contributor

Added this item to the next release roadmap. @dosymep
Will discuss at next meetup

@jmcouffin
Copy link
Contributor

Now, the 2711 engine is the only one available for ipy2.
Older engines have been removed.
Closing for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Engines Issues related to pyRevit execution engines [subsystem] IronPython Issues related to standalone IronPython installation [subsystem] Python 3 Issues related to cpython engines [subsystem]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants