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

Replace _PyLong_Format with PyNumber_ToBase #118

Merged
merged 4 commits into from
Oct 10, 2024

Conversation

musicinmybrain
Copy link
Contributor

_PyLong_Format is in Python’s internal, private API; PyNumber_ToBase belongs to the Stable API, and is a fairly thin wrapper around _PyLong_Format with a bit of extra error checking.

Fixes #116.

`_PyLong_Format` is in Python’s internal, private API; `PyNumber_ToBase`
belongs to the Stable API, and is a fairly thin wrapper around
`_PyLong_Format` with a bit of extra error checking.

Fixes MagicStack#116.
@elprans elprans requested a review from 1st1 June 5, 2024 16:47
hswong3i added a commit to alvistack/MagicStack-immutables that referenced this pull request Jun 13, 2024
    git clean -xdf
    tar zcvf ../python-immutables_0.20.orig.tar.gz --exclude=.git .
    debuild -uc -us
    cp python-immutables.spec ../python-immutables_0.20-1.spec
    cp ../python*-immutables*0.20*.{gz,xz,spec,dsc} /osc/home\:alvistack/MagicStack-immutables-0.20/
    rm -rf ../python*-immutables*0.20*.*

See MagicStack#118

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
@inducer
Copy link

inducer commented Oct 9, 2024

Python 3.13 is out, and immutables won't build on it without this:

Collecting immutables
  Using cached immutables-0.20.tar.gz (88 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: immutables
  Building wheel for immutables (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for immutables (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [37 lines of output]
      /tmp/pip-build-env-5kwi0m9m/overlay/lib/python3.13/site-packages/setuptools/command/easy_install.py:41: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
        import pkg_resources
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/__init__.py -> build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/_protocols.py -> build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/_testutils.py -> build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/_version.py -> build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/map.py -> build/lib.linux-x86_64-cpython-313/immutables
      running egg_info
      writing immutables.egg-info/PKG-INFO
      writing dependency_links to immutables.egg-info/dependency_links.txt
      writing requirements to immutables.egg-info/requires.txt
      writing top-level names to immutables.egg-info/top_level.txt
      reading manifest file 'immutables.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE'
      adding license file 'LICENSE-APACHE'
      adding license file 'NOTICE'
      writing manifest file 'immutables.egg-info/SOURCES.txt'
      copying immutables/_map.pyi -> build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/py.typed -> build/lib.linux-x86_64-cpython-313/immutables
      running build_ext
      building 'immutables._map' extension
      creating build/temp.linux-x86_64-cpython-313/immutables
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -DNDEBUG=1 -I/home/andreas/src/env-3.13/include -I/usr/include/python3.13 -c immutables/_map.c -o build/temp.linux-x86_64-cpython-313/immutables/_map.o -O2 -std=c99 -fsigned-char -Wall -Wsign-compare -Wconversion
      immutables/_map.c: In function ‘map_node_bitmap_dump’:
      immutables/_map.c:1287:12: error: implicit declaration of function ‘_PyLong_Format’; did you mean ‘_PyLong_Copy’? [-Wimplicit-function-declaration]
       1287 |     tmp2 = _PyLong_Format(tmp1, 2);
            |            ^~~~~~~~~~~~~~
            |            _PyLong_Copy
      immutables/_map.c:1287:10: error: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
       1287 |     tmp2 = _PyLong_Format(tmp1, 2);
            |          ^
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for immutables
Failed to build immutables
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (immutables)

I maintain a package that relies on immutables, and this is keeping my package from working with Py3.13.

@inducer
Copy link

inducer commented Oct 9, 2024

For the benefit of anyone else seeing this, this command will get a working immutables in place on 3.13 as a stopgap:

pip install "git+https://github.com/musicinmybrain/immutables.git@python3.13#egg=immutables"

@1st1
Copy link
Member

1st1 commented Oct 9, 2024

cc @fantix

@fantix fantix merged commit 81d7c92 into MagicStack:master Oct 10, 2024
22 checks passed
fantix added a commit that referenced this pull request Oct 10, 2024
Changes
=======

* Drop typing_extensions dependency (#114)
  (by @nicoddemus in 3ba46f7 for #114)

Fixes
=====

* Replace `_PyLong_Format` with `PyNumber_ToBase` (#118)
  (by @musicinmybrain in 81d7c92 for #116)
@fantix fantix mentioned this pull request Oct 10, 2024
@inducer
Copy link

inducer commented Oct 10, 2024

Thank you very much, also for rolling a new release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault with Python 3.13.0b1
4 participants