-
Notifications
You must be signed in to change notification settings - Fork 44
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
'return' with argument inside generator #353
Comments
Thanks for reporting this @hellohornet. Can you confirm whether this work in Maya less than 2020 (experimental)? I suspect there's some issue there, as I know they are also in the process of upgrading their Python distribution. It should work just find in both 2 and 3, and has been for years. |
I've seen same error when using python2.7 -m pyblish_qml --demo (tested in both CentOS7 & PyQt5 built manually and tested OK In Maya2019.2 (CentOS 7): |
I've got the same error by running the demo with Python 2.7.15 on macOS and CentOS 7. Works great with Python 3 but it doesn't seem to be working in Nuke 10.5/11/12 either... > python -m pyblish_qml --demo
Traceback (most recent call last):
File "/mill3d/server/apps/PYTHON/el7-x86-64/python-2.7.15/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/mill3d/server/apps/PYTHON/el7-x86-64/python-2.7.15/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/mill3d/users/jeremyr/dev/pyblish-qml/pyblish_qml/__main__.py", line 6, in <module>
from . import app
File "pyblish_qml/app.py", line 12, in <module>
from . import util, compat, control, settings, ipc
File "pyblish_qml/control.py", line 380
yield result
SyntaxError: 'return' with argument inside generator |
Were using environment variable |
Was looking at the code, it seems that So replacing those Has a quick test with Python 3.7 and it's working just fine, but I cannot test against Python 2.7 since that would require to build Anyone could help verifying this on Python 2.7 ? 👇
|
Aaah, yes of course. Ok, so workarounds:
The I can't figure out how we're supposed to do it. :S We can't |
Not sure I'm getting this discussion, but to stop an iterator means to just do def custom_iterator(value):
if value == "a":
yield 1
yield 2
yield 3
return
yield 0
for x in custom_iterator("a"):
print(x)
# 1
# 2
# 3
for x in custom_iterator("b"):
print(x)
# 0
This just means you're returning with an argument, which is invalid inside an iterator. To yield one last value before you return the way to do it is: yield last_value
return Or to Or am I stating something obvious and am I missing the point? |
Yeah, that could work in both Python 2.7 and Python 3.7. Anyway, the minimum fix (less code) for this issue was to replace those And it was not only stopping the iterator, but also prompting the message of why it stopped from the iterator, like due to the failed validation or stopped by user. |
Hi, I wanted to use Pyblish with a combination of Windows 10 and Maya2018, but there has error.
Then, I found this article about a similar problem. pyblish-qml/pyblish_qml/control.py Line 1029 in e0a9015
Next, I replaced all returns in control.py with yield.
Could you give me some advice about this? |
My advice would be #353 (comment) NOTE The version of Python you use with QML is independent of the version Maya uses. |
Whenever I run
pyblish_qml.show()
either from maya orpython2 -m pyblish_qml --demo
I successfully load the QML server, then am met withIt is my understanding that this is behavior that works in python3 but not 2.7, which is a necessity for Maya. Do I need to check out a different branch for 2.7 support ?
The text was updated successfully, but these errors were encountered: