Skip to content

Conversation

fingolfin
Copy link
Contributor

No description provided.

@fchapoton
Copy link
Contributor

well, does not compile

@fchapoton
Copy link
Contributor

I guess GAP_ValueGlobalVariable should be added to the appropriate .pxd file ?

@fingolfin
Copy link
Contributor Author

Huh, GAP_ValueGlobalVariable is already in gap_includes.pxd, and in fact is already being used in element.pyx and util.pyx. Both of these, as well as libgap.pyx (which this PR modifies) also do this:

from .gap_includes cimport *

So I have no idea what the problem is, I am afraid -- my Python / Cython knowledge is just too limited :-(

@fingolfin
Copy link
Contributor Author

It took me some time to find a job which did not fail for other reasons, but now I see this is the error:

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
                sage: libgap.get_global('FooBar')
                Traceback (most recent call last):
                ...
                GAPError: Error, VAL_GVAR: No value bound to FooBar
            """
            return GAP_ValueGlobalVariable(variable)
                                         ^
    ------------------------------------------------------------

    sage/libs/gap/libgap.pyx:542:38: Cannot convert 'Obj' to Python object
    Traceback (most recent call last):
      File "/usr/local/miniconda/envs/sage-build/lib/python3.11/site-packages/Cython/Build/Dependencies.py", line 1262, in cythonize_one_helper
        return cythonize_one(*m)
               ^^^^^^^^^^^^^^^^^
      File "/usr/local/miniconda/envs/sage-build/lib/python3.11/site-packages/Cython/Build/Dependencies.py", line 1238, in cythonize_one

So I guess that means GAP_ValueGlobalVariable is fine, but there needs to be some conversion/wrapping/unwrapping for the argument or the return value?

@fchapoton
Copy link
Contributor

fchapoton commented Jun 14, 2023

now complains about

        return make_any_gap_element(self, GAP_ValueGlobalVariable(variable.value))
    AttributeError: 'str' object has no attribute 'value'

so maybe the .value is not needed ?

trying without .value
@fchapoton
Copy link
Contributor

Now

  File "sage/libs/gap/libgap.pyx", line 542, in sage.libs.gap.libgap.Gap.get_global
    return make_any_gap_element(self, GAP_ValueGlobalVariable(variable))
TypeError: expected bytes, str found

so we need to change the string to bytes. Using str_to_bytes ?

from sage.cpython.string cimport str_to_bytes

adding str_to_bytes
@fingolfin
Copy link
Contributor Author

Using str_to_bytes sounds sensible. Thank you for your help.

@fchapoton
Copy link
Contributor

I have tested locally, and it seems to work.

@fchapoton
Copy link
Contributor

almost there.Should we just change the doctest results from a GAPError to NULL ?

@fingolfin
Copy link
Contributor Author

Fine by me

now returning NULL for undefined GAP variables, instead of raising GapError
@github-actions
Copy link

Documentation preview for this PR (built with commit 7d97f68) is ready! 🎉

@fchapoton
Copy link
Contributor

checks are ok. Shall I approve and set to positive ?

@fingolfin
Copy link
Contributor Author

Fine by me

Copy link
Contributor

@fchapoton fchapoton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good enough, hopefully

@vbraun vbraun merged commit c32c4f0 into sagemath:develop Jun 21, 2023
@fingolfin fingolfin deleted the mh/get_global branch June 22, 2023 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants