[Cython] uvloop issue in Cython3

2023-08-14 Thread matus valo
Hi All,

I was recently migrating uvloop to cython3 [1]. Unfortunately, after
switching to cython3, uvloop testsuite fails [2]. I am puzzled mainly about
following error:

==
ERROR: test_process_delayed_stdio__paused__no_stdin
(test_process.Test_UV_Process_Delayed)
--
Traceback (most recent call last):
  File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 938,
in test_process_delayed_stdio__paused__no_stdin
__uvloop_sleep_after_fork=True))
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
return future.result()
  File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 911,
in run_sub
**kwargs)
  File "uvloop/loop.pyx", line 2808, in subprocess_shell
return await self.__subprocess_run(protocol_factory, args, shell=True,
  File "uvloop/loop.pyx", line 2734, in
uvloop.loop.Loop._Loop__subprocess_run
@cython.iterable_coroutine
TypeError: _Loop__subprocess_run() got an unexpected keyword argument
'__uvloop_sleep_after_fork'

==
ERROR: test_process_delayed_stdio__paused__stdin_pipe
(test_process.Test_UV_Process_Delayed)
--
Traceback (most recent call last):
  File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 919,
in test_process_delayed_stdio__paused__stdin_pipe
__uvloop_sleep_after_fork=True))
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
return future.result()
  File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 911,
in run_sub
**kwargs)
  File "uvloop/loop.pyx", line 2808, in subprocess_shell
return await self.__subprocess_run(protocol_factory, args, shell=True,
  File "uvloop/loop.pyx", line 2734, in
uvloop.loop.Loop._Loop__subprocess_run
@cython.iterable_coroutine
TypeError: _Loop__subprocess_run() got an unexpected keyword argument
'__uvloop_sleep_after_fork'

The issue is regarding calling this method:
https://github.com/MagicStack/uvloop/blob/1dd40f17f3b0d37e3779b6ad5041bab335142337/uvloop/loop.pyx#L2735-L2753

When the same code base is compiled in Cython 0.29.X and the test suite is
run, there is no such error. I tried to create a simple reproducer but
failed.

What do you think? Is it regression in Cython 3.0? Do you have any hint
where the root cause can be? If everything fails, I will try to bisect the
issue.

Matus


[1] https://github.com/MagicStack/uvloop/pull/534
[2] https://github.com/MagicStack/uvloop/pull/534/checks
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] uvloop issue in Cython3

2023-08-14 Thread da-woods

Hi Matus,

This'll be related to 
https://github.com/cython/cython/commit/abeb082098c13e243a2e2658f9eb45f1c151b091


Just an example (in Python, not Cython, but the Cython behaviour should 
now be the same):



 class C:

...   def f(self, __kwd):
... print(locals())
...
>>> C().f(1)
{'self': <__main__.C object at 0x7f299ef878d0>, '_C__kwd': 1}

 C().f(__kwd=1)

Traceback (most recent call last):
 File "", line 1, in 
TypeError: C.f() got an unexpected keyword argument '__kwd'

 C().f(_C__kwd=1)

{'self': <__main__.C object at 0x7f299ef878d0>, '_C__kwd': 1}


I haven't looked in much detail at exactly what's happening in uvloop, 
but I think this is likely the correct (i.e. Python) behaviour that 
you're seeing.


Hopefully that's enough to track it down.

David

On 14/08/2023 18:25, matus valo wrote:

Hi All,

I was recently migrating uvloop to cython3 [1]. Unfortunately, after 
switching to cython3, uvloop testsuite fails [2]. I am puzzled mainly 
about following error:


==
ERROR: test_process_delayed_stdio__paused__no_stdin 
(test_process.Test_UV_Process_Delayed)

--
Traceback (most recent call last):
  File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 
938, in test_process_delayed_stdio__paused__no_stdin

    __uvloop_sleep_after_fork=True))
  File "uvloop/loop.pyx", line 1517, in 
uvloop.loop.Loop.run_until_complete

    return future.result()
  File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 
911, in run_sub

    **kwargs)
  File "uvloop/loop.pyx", line 2808, in subprocess_shell
    return await self.__subprocess_run(protocol_factory, args, shell=True,
  File "uvloop/loop.pyx", line 2734, in 
uvloop.loop.Loop._Loop__subprocess_run

    @cython.iterable_coroutine
TypeError: _Loop__subprocess_run() got an unexpected keyword argument 
'__uvloop_sleep_after_fork'


==
ERROR: test_process_delayed_stdio__paused__stdin_pipe 
(test_process.Test_UV_Process_Delayed)

--
Traceback (most recent call last):
  File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 
919, in test_process_delayed_stdio__paused__stdin_pipe

    __uvloop_sleep_after_fork=True))
  File "uvloop/loop.pyx", line 1517, in 
uvloop.loop.Loop.run_until_complete

    return future.result()
  File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 
911, in run_sub

    **kwargs)
  File "uvloop/loop.pyx", line 2808, in subprocess_shell
    return await self.__subprocess_run(protocol_factory, args, shell=True,
  File "uvloop/loop.pyx", line 2734, in 
uvloop.loop.Loop._Loop__subprocess_run

    @cython.iterable_coroutine
TypeError: _Loop__subprocess_run() got an unexpected keyword argument 
'__uvloop_sleep_after_fork'


The issue is regarding calling this method: 
https://github.com/MagicStack/uvloop/blob/1dd40f17f3b0d37e3779b6ad5041bab335142337/uvloop/loop.pyx#L2735-L2753


When the same code base is compiled in Cython 0.29.X and the test 
suite is run, there is no such error. I tried to create a simple 
reproducer but failed.


What do you think? Is it regression in Cython 3.0? Do you have any 
hint where the root cause can be? If everything fails, I will try to 
bisect the issue.


Matus


[1] https://github.com/MagicStack/uvloop/pull/534
[2] https://github.com/MagicStack/uvloop/pull/534/checks

___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] uvloop issue in Cython3

2023-08-14 Thread matus valo
Thank you David!

I was not aware that method parameters are mangled in python. It seems it
helped.

BTW, I think that the Cython documentation is lacking this change:
https://cython.readthedocs.io/en/latest/src/userguide/migrating_to_cy30.html#python-semantics


Matus

On Mon, 14 Aug 2023 at 19:42, da-woods  wrote:

> Hi Matus,
>
> This'll be related to
> https://github.com/cython/cython/commit/abeb082098c13e243a2e2658f9eb45f1c151b091
>
> Just an example (in Python, not Cython, but the Cython behaviour should
> now be the same):
>
> >>> class C:
> ...   def f(self, __kwd):
> ... print(locals())
> ...
> >>> C().f(1)
> {'self': <__main__.C object at 0x7f299ef878d0>, '_C__kwd': 1}
> >>> C().f(__kwd=1)
> Traceback (most recent call last):
>  File "", line 1, in 
> TypeError: C.f() got an unexpected keyword argument '__kwd'
> >>> C().f(_C__kwd=1)
> {'self': <__main__.C object at 0x7f299ef878d0>, '_C__kwd': 1}
>
>
> I haven't looked in much detail at exactly what's happening in uvloop, but
> I think this is likely the correct (i.e. Python) behaviour that you're
> seeing.
>
> Hopefully that's enough to track it down.
>
> David
>
> On 14/08/2023 18:25, matus valo wrote:
>
> Hi All,
>
> I was recently migrating uvloop to cython3 [1]. Unfortunately, after
> switching to cython3, uvloop testsuite fails [2]. I am puzzled mainly about
> following error:
>
> ==
> ERROR: test_process_delayed_stdio__paused__no_stdin
> (test_process.Test_UV_Process_Delayed)
> --
> Traceback (most recent call last):
>   File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 938,
> in test_process_delayed_stdio__paused__no_stdin
> __uvloop_sleep_after_fork=True))
>   File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
> return future.result()
>   File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 911,
> in run_sub
> **kwargs)
>   File "uvloop/loop.pyx", line 2808, in subprocess_shell
> return await self.__subprocess_run(protocol_factory, args, shell=True,
>   File "uvloop/loop.pyx", line 2734, in
> uvloop.loop.Loop._Loop__subprocess_run
> @cython.iterable_coroutine
> TypeError: _Loop__subprocess_run() got an unexpected keyword argument
> '__uvloop_sleep_after_fork'
>
> ==
> ERROR: test_process_delayed_stdio__paused__stdin_pipe
> (test_process.Test_UV_Process_Delayed)
> --
> Traceback (most recent call last):
>   File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 919,
> in test_process_delayed_stdio__paused__stdin_pipe
> __uvloop_sleep_after_fork=True))
>   File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
> return future.result()
>   File "/home/runner/work/uvloop/uvloop/tests/test_process.py", line 911,
> in run_sub
> **kwargs)
>   File "uvloop/loop.pyx", line 2808, in subprocess_shell
> return await self.__subprocess_run(protocol_factory, args, shell=True,
>   File "uvloop/loop.pyx", line 2734, in
> uvloop.loop.Loop._Loop__subprocess_run
> @cython.iterable_coroutine
> TypeError: _Loop__subprocess_run() got an unexpected keyword argument
> '__uvloop_sleep_after_fork'
>
> The issue is regarding calling this method:
> https://github.com/MagicStack/uvloop/blob/1dd40f17f3b0d37e3779b6ad5041bab335142337/uvloop/loop.pyx#L2735-L2753
>
> When the same code base is compiled in Cython 0.29.X and the test suite is
> run, there is no such error. I tried to create a simple reproducer but
> failed.
>
> What do you think? Is it regression in Cython 3.0? Do you have any hint
> where the root cause can be? If everything fails, I will try to bisect the
> issue.
>
> Matus
>
>
> [1] https://github.com/MagicStack/uvloop/pull/534
> [2] https://github.com/MagicStack/uvloop/pull/534/checks
>
> ___
> cython-devel mailing 
> listcython-devel@python.orghttps://mail.python.org/mailman/listinfo/cython-devel
>
>
> ___
> cython-devel mailing list
> cython-devel@python.org
> https://mail.python.org/mailman/listinfo/cython-devel
>
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] uvloop issue in Cython3

2023-08-14 Thread da-woods

On 14/08/2023 20:06, matus valo wrote:


BTW, I think that the Cython documentation is lacking this change: 
https://cython.readthedocs.io/en/latest/src/userguide/migrating_to_cy30.html#python-semantics


There's a segment further down on "Class-private name mangling". I think 
if we wanted to mention it then it'd go there.  It's probably a detail 
we'd want to keep fairly brief I think.

___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel