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

Python 3.14.0a3: TypeError: Extra positional arguments provided #795

Open
hroncok opened this issue Jan 6, 2025 · 7 comments · May be fixed by #810
Open

Python 3.14.0a3: TypeError: Extra positional arguments provided #795

hroncok opened this issue Jan 6, 2025 · 7 comments · May be fixed by #810

Comments

@hroncok
Copy link

hroncok commented Jan 6, 2025

Description

Hello. In Fedora, we try to build this package with Python 3.14.0a3.

We see test errors, on 0.19.0 as well as the current main branch. To reproduce, I did:

[msgspec (main)]$ uv venv --python=python3.14 venv3.14
[msgspec (main)]$ . venv/bin/activate
(venv3.14) [msgspec (main)]$ uv pip install .[test]
Using Python 3.14.0a3 environment at: venv3.14
Resolved 9 packages in 1.12s
   Built msgspec @ file:///home/.../msgspec
   Built msgpack==1.1.0
   Built pyyaml==6.0.2
Prepared 5 packages in 5.98s
Installed 9 packages in 8ms
 + attrs==24.3.0
 + iniconfig==2.0.0
 + msgpack==1.1.0
 + msgspec==0.19.0 (from file:///home/.../msgspec)
 + packaging==24.2
 + pluggy==1.5.0
 + pytest==8.3.4
 + pyyaml==6.0.2
 + tomli-w==1.1.0
(venv3.14) [msgspec (main)]$ pytest
============================= test session starts ==============================
platform linux -- Python 3.14.0a3, pytest-8.3.4, pluggy-1.5.0
rootdir: /home/.../msgspec
configfile: setup.cfg
collected 5762 items / 3 errors / 2 skipped

==================================== ERRORS ====================================
____________________ ERROR collecting tests/test_struct.py _____________________
tests/test_struct.py:842: in <module>
    FrozenPoint(1, 2),
E   TypeError: Extra positional arguments provided
_____________________ ERROR collecting tests/test_toml.py ______________________
tests/test_toml.py:125: in <module>
    (ExStruct(1, "two"), ExStruct),
E   TypeError: Extra positional arguments provided
_____________________ ERROR collecting tests/test_yaml.py ______________________
tests/test_yaml.py:105: in <module>
    (ExStruct(1, "two"), ExStruct),
E   TypeError: Extra positional arguments provided
=========================== short test summary info ============================
ERROR tests/test_struct.py - TypeError: Extra positional arguments provided
ERROR tests/test_toml.py - TypeError: Extra positional arguments provided
ERROR tests/test_yaml.py - TypeError: Extra positional arguments provided
!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!
========================= 2 skipped, 3 errors in 0.40s =========================
@hroncok
Copy link
Author

hroncok commented Jan 30, 2025

Same problem with a4

@hroncok
Copy link
Author

hroncok commented Jan 30, 2025

Checking the 2 occurrences of "Extra positional arguments provided" in _core.c and modifying the error message I see now that the error is from this line:

PyErr_SetString(PyExc_TypeError, "Extra positional arguments provided");

@hroncok
Copy link
Author

hroncok commented Jan 30, 2025

The conditional at

if (MS_UNLIKELY(nargs > (nfields - nkwonly))) {

  • on Python 3.13.1 this is 2 > (2 - 0)
  • on Python 3.14.0a4 this is 2 > (0 - 0)

@hroncok
Copy link
Author

hroncok commented Jan 30, 2025

I was trying to bisect CPython to see what happened, but unfortunately, some cache interferes with my efforts and I am getting unstable results :(

@hroncok
Copy link
Author

hroncok commented Feb 4, 2025

The 0 vs 2 difference already exists here:

Py_ssize_t nfields = PyDict_GET_SIZE(info->defaults_lk);

@hroncok
Copy link
Author

hroncok commented Feb 4, 2025

The difference originates in:

msgspec/msgspec/_core.c

Lines 5816 to 5820 in dd965dc

structmeta_collect_fields(StructMetaInfo *info, MsgspecState *mod, bool kwonly) {
PyObject *annotations = PyDict_GetItemString(
info->namespace, "__annotations__"
);
if (annotations == NULL) return 0;

On Python 3.14, this returns 0.

@hroncok
Copy link
Author

hroncok commented Feb 4, 2025

As @befeleme suggested to me earlier, this looks very much related to https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-pep649

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 a pull request may close this issue.

1 participant