Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1898084 - python-django fails to build with Python 3.10: AssertionError: "Error: invalid choice: 'test' (choose from 'foo')" not found in "Error: argument {foo}: invalid choice: 'test' (choose from 'foo')"
Summary: python-django fails to build with Python 3.10: AssertionError: "Error: invali...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-django
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Matthias Runge
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.10 F35FTBFS
TreeView+ depends on / blocked
 
Reported: 2020-11-16 10:43 UTC by Miro Hrončok
Modified: 2022-10-04 19:53 UTC (History)
9 users (show)

Fixed In Version: python-django-3.2.6-1.fc35
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-08-09 09:04:05 UTC
Type: Bug
Embargoed:
thrnciar: needinfo+


Attachments (Terms of Use)

Description Miro Hrončok 2020-11-16 10:43:26 UTC
python-django fails to build with Python 3.10.0a2.

FAIL: test_memoryview_content (httpwrappers.tests.HttpResponseTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.1.2/tests/httpwrappers/tests.py", line 372, in test_memoryview_content
    self.assertEqual(r.content, b'memoryview')
AssertionError: b'109101109111114121118105101119' != b'memoryview'


This has been fixed upstream:

https://github.com/django/django/pull/13648


For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/01756925-python-django/

For all our attempts to build python-django with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/python-django/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Tomáš Hrnčiar 2021-01-05 13:11:36 UTC
I tried to build python-django with 4th alpha and it seems like the above problem is not present anymore. But I ran to another test failure:

======================================================================
ERROR: model_enums.tests (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: model_enums.tests
Traceback (most recent call last):
  File "/usr/lib64/python3.10/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib64/python3.10/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/builddir/build/BUILD/Django-3.1.5/tests/model_enums/tests.py", line 225, in <module>
    class IPv4Network(ipaddress.IPv4Network, models.Choices):
  File "/builddir/build/BUILD/Django-3.1.5/django/db/models/enums.py", line 28, in __new__
    cls = super().__new__(metacls, classname, bases, classdict)
  File "/usr/lib64/python3.10/enum.py", line 239, in __new__
    enum_class.__bases__ = enum_class.__bases__[1:] #or (object, )
  File "/usr/lib64/python3.10/enum.py", line 483, in __setattr__
    super().__setattr__(name, value)
TypeError: __bases__ assignment: 'IPv4Network' object layout differs from '_NoInitSubclass'

https://download.copr.fedorainfracloud.org/results/@python/python3.10/fedora-rawhide-x86_64/01863009-python-django/builder-live.log.gz

Comment 2 Tomáš Hrnčiar 2021-02-08 08:48:43 UTC
Here are new failures with 5th alpha of Python 3.10 (last one should be fixed in upstream).

======================================================================
ERROR: test_integerchoices_functional_api (model_enums.tests.ChoicesTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.1.6/tests/model_enums/tests.py", line 74, in test_integerchoices_functional_api
    Place = models.IntegerChoices('Place', 'FIRST SECOND THIRD')
  File "/usr/lib64/python3.10/enum.py", line 598, in __call__
    return cls._create_(
  File "/usr/lib64/python3.10/enum.py", line 738, in _create_
    return metacls.__new__(metacls, class_name, bases, classdict, boundary=boundary)
TypeError: ChoicesMeta.__new__() got an unexpected keyword argument 'boundary'

======================================================================
ERROR: test_textchoices_functional_api (model_enums.tests.ChoicesTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.1.6/tests/model_enums/tests.py", line 115, in test_textchoices_functional_api
    Medal = models.TextChoices('Medal', 'GOLD SILVER BRONZE')
  File "/usr/lib64/python3.10/enum.py", line 598, in __call__
    return cls._create_(
  File "/usr/lib64/python3.10/enum.py", line 738, in _create_
    return metacls.__new__(metacls, class_name, bases, classdict, boundary=boundary)
TypeError: ChoicesMeta.__new__() got an unexpected keyword argument 'boundary'

======================================================================
FAIL: test_memoryview_content (httpwrappers.tests.HttpResponseTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.1.6/tests/httpwrappers/tests.py", line 372, in test_memoryview_content
    self.assertEqual(r.content, b'memoryview')
AssertionError: b'109101109111114121118105101119' != b'memoryview'

----------------------------------------------------------------------

Comment 3 Ben Cotton 2021-02-09 15:24:51 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 4 Miro Hrončok 2021-02-18 23:02:51 UTC
I still only see:

======================================================================
FAIL: test_memoryview_content (httpwrappers.tests.HttpResponseTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.1.6/tests/httpwrappers/tests.py", line 372, in test_memoryview_content
    self.assertEqual(r.content, b'memoryview')
AssertionError: b'109101109111114121118105101119' != b'memoryview'

----------------------------------------------------------------------
Ran 13829 tests in 527.276s

In the latest Copr build.



The upstream fix is included in 3.2a1, bz1917820.

Comment 5 Tomáš Hrnčiar 2021-05-17 12:33:51 UTC
There are some new failures present in first beta.

======================================================================
FAIL: test_dumpdata_proxy_with_concrete (fixtures.tests.FixtureLoadingTests)
A warning isn't displayed if a proxy model is dumped with its concrete
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.2.1/tests/fixtures/tests.py", line 622, in test_dumpdata_proxy_with_concrete
    self.assertEqual(len(warning_list), 0)
AssertionError: 2 != 0

======================================================================
FAIL: test_repr_with_deferrable (constraints.tests.UniqueConstraintTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.2.1/tests/constraints/tests.py", line 246, in test_repr_with_deferrable
    self.assertEqual(
AssertionError: "<Uni[28 chars], 'bar') name='unique_fields' deferrable=IMMEDIATE>" != "<Uni[28 chars], 'bar') name='unique_fields' deferrable=Deferrable.IMMEDIATE>"
- <UniqueConstraint: fields=('foo', 'bar') name='unique_fields' deferrable=IMMEDIATE>
+ <UniqueConstraint: fields=('foo', 'bar') name='unique_fields' deferrable=Deferrable.IMMEDIATE>
?                                                                          +++++++++++


======================================================================
FAIL: test_validators (validators.tests.TestValidators) [URLValidator] (value='http://www.djangoproject.com/\n')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.2.1/tests/validators/tests.py", line 327, in test_validators
    with self.assertRaises(expected):
AssertionError: ValidationError not raised

======================================================================
FAIL: test_validators (validators.tests.TestValidators) [URLValidator] (value='http://[::ffff:192.9.5.5]\n')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.2.1/tests/validators/tests.py", line 327, in test_validators
    with self.assertRaises(expected):
AssertionError: ValidationError not raised

======================================================================
FAIL: test_integerchoices (model_enums.tests.ChoicesTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.2.1/tests/model_enums/tests.py", line 51, in test_integerchoices
    self.assertEqual(repr(Suit.DIAMOND), '<Suit.DIAMOND: 1>')
AssertionError: 'Suit.DIAMOND' != '<Suit.DIAMOND: 1>'
- Suit.DIAMOND
+ <Suit.DIAMOND: 1>
? +            ++++


======================================================================
FAIL: test_textchoices (model_enums.tests.ChoicesTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.2.1/tests/model_enums/tests.py", line 92, in test_textchoices
    self.assertEqual(repr(YearInSchool.FRESHMAN), "<YearInSchool.FRESHMAN: 'FR'>")
AssertionError: 'YearInSchool.FRESHMAN' != "<YearInSchool.FRESHMAN: 'FR'>"
- YearInSchool.FRESHMAN
+ <YearInSchool.FRESHMAN: 'FR'>
? +                     +++++++


----------------------------------------------------------------------
Ran 14608 tests in 553.444s

FAILED (failures=6, skipped=1166, expected failures=4)

Comment 6 Miro Hrončok 2021-06-04 20:13:58 UTC
This is a mass-posted update. Sorry if it is not 100% accurate to this bugzilla.


The Python 3.10 rebuild is in progress in a Koji side tag. If you manage to fix the problem, please commit the fix in the rawhide branch, but don't build the package in regular rawhide.

You can either build the package in the side tag, with:

    $ fedpkg build --target=f35-python

Or you can the build and we will eventually build it for you.

Note that the rebuild is still in progress, so not all (build) dependencies of this package might be available right away.

Thanks.

See also https://fedoraproject.org/wiki/Changes/Python3.10

If you have general questions about the rebuild, please use this mailing list thread: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/G47SGOYIQLRDTWGOSLSWERZSSHXDEDH5/

Comment 7 Miro Hrončok 2021-06-07 22:58:40 UTC
The f35-python side tag has been merged to Rawhide. From now on, build as you would normally build.

Comment 8 Karthikeyan Singaravelan 2021-07-13 04:36:15 UTC
Enum related changes were reverted in Python 3.10 : https://mail.python.org/archives/list/python-dev@python.org/thread/ZMC67QA2JVQJSWSFWRS6IM6ZX4EK277G/#LSTMFAPSPD3BGZ4D6HQFODXZVB3PLYKF

Comment 9 Karthikeyan Singaravelan 2021-07-13 04:39:26 UTC
Django will use the 3.10 repr format irrespective of the revert in stdlib enum : https://github.com/django/django/pull/14624

Comment 10 Tomáš Hrnčiar 2021-08-05 09:49:53 UTC
A new test failure showed up with Python 3.10.0rc1.

======================================================================
FAIL: test_subparser_invalid_option (user_commands.tests.CommandTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.10/argparse.py", line 1853, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib64/python3.10/argparse.py", line 2065, in _parse_known_args
    stop_index = consume_positionals(start_index)
  File "/usr/lib64/python3.10/argparse.py", line 2021, in consume_positionals
    take_action(action, args)
argparse.ArgumentError: argument {foo}: invalid choice: 'test' (choose from 'foo')
During handling of the above exception, another exception occurred:
django.core.management.base.CommandError: Error: argument {foo}: invalid choice: 'test' (choose from 'foo')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/builddir/build/BUILD/Django-3.2.1/tests/user_commands/tests.py", line 338, in test_subparser_invalid_option
    with self.assertRaisesMessage(CommandError, msg):
  File "/usr/lib64/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/builddir/build/BUILD/Django-3.2.1/django/test/testcases.py", line 693, in _assert_raises_or_warns_cm
    self.assertIn(expected_message, str(getattr(cm, cm_attr)))
AssertionError: "Error: invalid choice: 'test' (choose from 'foo')" not found in "Error: argument {foo}: invalid choice: 'test' (choose from 'foo')"

Comment 11 Fedora Update System 2022-10-04 19:52:14 UTC
FEDORA-2022-0cba1bd104 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2022-0cba1bd104

Comment 12 Fedora Update System 2022-10-04 19:53:25 UTC
FEDORA-2022-0cba1bd104 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.