Commit e4dddf15 authored by Kirill Smelkov's avatar Kirill Smelkov

golang.pyx: pyselect: Small cosmetics

Move `ch = py{send,recv}.__self__` to right after case __class__ check.
For now both versions - old and new - can work, but when we'll move
channel implementations to C the new version will be required to access
pychan C-level attribute earlier than where ch is currently initialized.
parent 2fc71566
...@@ -497,10 +497,11 @@ def pyselect(*pycasev): ...@@ -497,10 +497,11 @@ def pyselect(*pycasev):
pysend, tx = pycase pysend, tx = pycase
if pysend.__self__.__class__ is not pychan: if pysend.__self__.__class__ is not pychan:
pypanic("pyselect: send on non-chan: %r" % (pysend.__self__.__class__,)) pypanic("pyselect: send on non-chan: %r" % (pysend.__self__.__class__,))
ch = pysend.__self__
if pysend.__name__ != "send": # XXX better check PyCFunction directly if pysend.__name__ != "send": # XXX better check PyCFunction directly
pypanic("pyselect: send expected: %r" % (pysend,)) pypanic("pyselect: send expected: %r" % (pysend,))
ch = pysend.__self__
if ch is not pynilchan: # nil chan is never ready if ch is not pynilchan: # nil chan is never ready
ch._mu.acquire() ch._mu.acquire()
if 1: if 1:
...@@ -516,6 +517,8 @@ def pyselect(*pycasev): ...@@ -516,6 +517,8 @@ def pyselect(*pycasev):
pyrecv = pycase pyrecv = pycase
if pyrecv.__self__.__class__ is not pychan: if pyrecv.__self__.__class__ is not pychan:
pypanic("pyselect: recv on non-chan: %r" % (pyrecv.__self__.__class__,)) pypanic("pyselect: recv on non-chan: %r" % (pyrecv.__self__.__class__,))
ch = pyrecv.__self__
if pyrecv.__name__ == "recv": # XXX better check PyCFunction directly if pyrecv.__name__ == "recv": # XXX better check PyCFunction directly
commaok = False commaok = False
elif pyrecv.__name__ == "recv_": # XXX better check PyCFunction directly elif pyrecv.__name__ == "recv_": # XXX better check PyCFunction directly
...@@ -523,7 +526,6 @@ def pyselect(*pycasev): ...@@ -523,7 +526,6 @@ def pyselect(*pycasev):
else: else:
pypanic("pyselect: recv expected: %r" % (pyrecv,)) pypanic("pyselect: recv expected: %r" % (pyrecv,))
ch = pyrecv.__self__
if ch is not pynilchan: # nil chan is never ready if ch is not pynilchan: # nil chan is never ready
ch._mu.acquire() ch._mu.acquire()
if 1: if 1:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment