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

Some CPython tests fail in integration_tests with conda-forge lpython #1826

Open
Tracked by #1600
certik opened this issue May 17, 2023 · 5 comments
Open
Tracked by #1600

Some CPython tests fail in integration_tests with conda-forge lpython #1826

certik opened this issue May 17, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@certik
Copy link
Contributor

certik commented May 17, 2023

See #1825 for setup. These fail:

	156 - structs_04 (Failed)
	159 - structs_09 (Failed)
	160 - structs_10 (Failed)
	166 - structs_17 (Failed)
	204 - test_01_goto (Failed)
	225 - lpython_decorator_01 (Failed)

The actual failures are:

ld: library not found for -lpython3.10
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Traceback (most recent call last):
  File "/Users/ondrej/repos/lpython/integration_tests/lpython_decorator_01.py", line 4, in <module>
    @lpython
     ^^^^^^^
  File "/Users/ondrej/repos/lpython/src/runtime/lpython/lpython.py", line 784, in __init__
    assert r == 0, "Failed to create the shared library"
AssertionError: Failed to create the shared library

Here probably python3.11 is used. => must make the decorator more robust

Traceback (most recent call last):
  File "/Users/ondrej/repos/lpython/integration_tests/test_01_goto.py", line 35, in <module>
    test_goto()
  File "/Users/ondrej/repos/lpython/integration_tests/test_01_goto.py", line 29, in test_goto
    print(f())
          ^^^
  File "/Users/ondrej/repos/lpython/integration_tests/test_01_goto.py", line 8, in f
    goto .end
    ^^^^
NameError: name 'goto' is not defined

goto does not work somehow.

Traceback (most recent call last):
  File "/Users/ondrej/repos/lpython/integration_tests/structs_10.py", line 12, in <module>
    @dataclass
     ^^^^^^^^^
  File "/Users/ondrej/repos/lpython/src/runtime/lpython/lpython.py", line 47, in dataclass
    return py_dataclass(arg)
           ^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 1221, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 1211, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 959, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 816, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class '__main__.Mat'> for field mat is not allowed: use default_factory

and:

Traceback (most recent call last):
  File "/Users/ondrej/repos/lpython/integration_tests/structs_17.py", line 3, in <module>
    @dataclass
     ^^^^^^^^^
  File "/Users/ondrej/repos/lpython/src/runtime/lpython/lpython.py", line 47, in dataclass
    return py_dataclass(arg)
           ^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 1221, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 1211, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 959, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 816, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class '__main__.B.C'> for field bc is not allowed: use default_factory

and

Traceback (most recent call last):
  File "/Users/ondrej/repos/lpython/integration_tests/structs_09.py", line 7, in <module>
    @dataclass
     ^^^^^^^^^
  File "/Users/ondrej/repos/lpython/src/runtime/lpython/lpython.py", line 47, in dataclass
    return py_dataclass(arg)
           ^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 1221, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 1211, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 959, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 816, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class '__main__.C'> for field bc is not allowed: use default_factory

and

Traceback (most recent call last):
  File "/Users/ondrej/repos/lpython/integration_tests/structs_04.py", line 9, in <module>
    @dataclass
     ^^^^^^^^^
  File "/Users/ondrej/repos/lpython/src/runtime/lpython/lpython.py", line 47, in dataclass
    return py_dataclass(arg)
           ^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 1221, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 1211, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 959, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ondrej/mambaforge/envs/t1/lib/python3.11/dataclasses.py", line 816, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class '__main__.A'> for field a is not allowed: use default_factory

Some issue in a dataclass.

@certik certik added the bug Something isn't working label May 17, 2023
@Shaikh-Ubaid
Copy link
Collaborator

goto does not work somehow.

I think using .goto in the following place might fix it.

from goto import with_goto

@Shaikh-Ubaid
Copy link
Collaborator

On making src/runtime/lpython a package and using relative import for goto, I receive the following:

$ python integration_tests/test_01_goto.py
Traceback (most recent call last):
  File "/Users/ubaid/Desktop/OpenSource/lpython/integration_tests/test_01_goto.py", line 35, in <module>
    test_goto()
  File "/Users/ubaid/Desktop/OpenSource/lpython/integration_tests/test_01_goto.py", line 29, in test_goto
    print(f())
          ^^^
  File "/Users/ubaid/Desktop/OpenSource/lpython/integration_tests/test_01_goto.py", line 8, in f
    goto .end
    ^^^^
NameError: name 'goto' is not defined

@Shaikh-Ubaid
Copy link
Collaborator

Shaikh-Ubaid commented May 17, 2023

It seems that python 3.11 does not have support for goto (snoack/python-goto#40).

@certik
Copy link
Contributor Author

certik commented May 17, 2023

The goto's implementation has always been a hack, because it depends on internals of Python.

I think we should remove it, because it's impossible to implement without hacking the byte code, which is not a "public" API.

@Thirumalai-Shaktivel
Copy link
Collaborator

Thirumalai-Shaktivel commented Jun 12, 2023

The other error:

...
ValueError: mutable default <class '__main__.A'> for field a is not allowed: use default_factory

seems to be caused by the following initialization, removing it yields the output:

a: A = A(f32(0.0), 0)

Also see: https://stackoverflow.com/a/53633297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants