#Help - Class `UserFlags` received an invalid and unexpected value

1 messages · Page 1 of 1 (latest)

atomic agateBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

ashen nebula
#

Can you send a snippet of your code?

pearl moat
rustic kernel
#

i dont know exactly whats causing this

#

im guessing something in 3.12.3 specifically broke our code

rustic kernel
#

@undone terrace i dont actually have problems with 3.12 necessarily

#

which makes me almost certain its a patch change that caused this

undone terrace
#

I'm getting issues with using 3.12.1 specifically

undone terrace
#

I'll check in case I have a corrupt venv, I'm working with pyenv

rustic kernel
#

well, im not sure if its .3 exactly

#

but my bots on 3.12.0 do not face the issue

undone terrace
#

try patch incrementals and tell me if there's a specific one it starts to error on for you, mine is .1

rustic kernel
#

its either a patch version or a platform thing

#

which is... interesting

undone terrace
#

a temporary workaround would be us needing to add pyver condition checks and exhaustively specifying different logic but i hate the idea of doing that

#

i don't want to start monkey patching for edge cases

rustic kernel
#

3.12.0 - works fine, wsl ubuntu

undone terrace
#

can you cat your os release

rustic kernel
#

in a sec, installing 3.12.1

#
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
undone terrace
#

ty, i'll try keeping our versions the same

rustic kernel
#

okay so my basic code on 3.12.2 is still working the same
its literally

import interactions
interactions.Intents(0)
#

so, uh, this is fun

undone terrace
#

that traceback implies 0 isn't declared

rustic kernel
#

no, take a closer look

#
File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\enum.py", line 1422, in _missing_
    raise ValueError(
ValueError: (0, None) is not a valid Intents
#

thats the actual error

undone terrace
#

no, i hear you

#

that's what i'm saying

rustic kernel
#

(0, None) isnt declared

undone terrace
#

_missing_ within the builtin is used for talking about missing declarations

#

yeah

rustic kernel
#

however 0 is

undone terrace
#

np_raisedeyebrow i see

#

@pearl moat can you send me your code where intents are declared and then inserted into the bot instantiation?

rustic kernel
#

meaning its becoming a tuple somewhere

undone terrace
#

does (intents) do anything..?

#

the value is at some point coerced into a tuple yeah

undone terrace
#

the type still remains <flag 'Intents'>

#

but how is the flag value itself becoming a tuple???

#

that doesn't make any sense whatsoever, our intents decl is explicit to ints

rustic kernel
#

I GOT A HIT!

#

3.12.3 seems to cause it for sure

#

you have no idea how excited i am

undone terrace
#

i'm not excited, idk wtf the people at cpython are thinking lmao

rustic kernel
#

its something to work off of lmao

#

alright gang time to look through the list

undone terrace
#

3.12.3 isn't available in pyenv yet, leaving this one for you

rustic kernel
#

it is

#

you just need to update your pyenv

undone terrace
#

do i need to upgrade

#

ok

rustic kernel
#
GitHub

Bug report Bug description: Hello, I tried to define an enum with custom initializer and tuple values, akin to the Planet example. When instantiating this enum from values it works for some values ...

GitHub

In this StackOverflow answer, Ethan Furman, the author of the enum module, demonstrated how a tuple value is special-cased so that it can be unpacked as arguments to the constructor of the mixin ty...

#

i think i see it

#

the call signature was changed

undone terrace
#

i saw that or None

#

wtf

rustic kernel
#

welp

#

i can reimplement the bug patch easily

#

so this shouldnt be a major issue, but its annoying

undone terrace
#

i can't even import it normally

#
i0@sophia:~$ pip show interactions-py
Name: interactions.py
Version: 5.11.0
Summary: Easy, simple, scalable and modular: a Python API wrapper for interactions.
Home-page: https://github.com/interactions-py/interactions.py
Author: LordOfPolls
Author-email: [email protected]
License:
Location: /home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages
Requires: aiohttp, attrs, discord-typings, emoji, tomli
Required-by:
i0@sophia:~$ pyenv global
3.12.3
>>> import interactions
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/__init__.py", line 2, in <module>
    from .client import (
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/client/__init__.py", line 36, in <module>
    from .client import Client
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/client/client.py", line 33, in <module>
    import interactions.api.events as events
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/api/__init__.py", line 1, in <module>
    from . import events
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/api/events/__init__.py", line 1, in <module>
    from . import processors
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/api/events/processors/__init__.py", line 1, in <module>
    from .channel_events import ChannelEvents
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/api/events/processors/channel_events.py", line 6, in <module>
    from interactions.models.discord.channel import BaseChannel
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/models/__init__.py", line 1, in <module>
    from .discord import (
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/models/discord/__init__.py", line 150, in <module>
    from .modal import InputText, Modal, ParagraphText, ShortText, TextStyles
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/models/discord/modal.py", line 11, in <module>
    from interactions.models.internal.application_commands import CallbackType
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/models/internal/__init__.py", line 13, in <module>
    from .active_voice_state import ActiveVoiceState
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/models/internal/active_voice_state.py", line 8, in <module>
    from interactions.api.voice.player import Player
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/api/voice/player.py", line 11, in <module>
    from interactions.api.voice.audio import BaseAudio, AudioVolume
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/api/voice/audio.py", line 13, in <module>
    from interactions.api.voice.opus import Encoder
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/site-packages/interactions/api/voice/opus.py", line 2, in <module>
    import ctypes
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/ctypes/__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
>>>
rustic kernel
#

that seems like your installation messed up somewhere

undone terrace
#

wacko, i'll try again

#

ig bad tarballs install

#
i0@sophia:~$ pyenv install 3.12.3
pyenv: /home/i0/.pyenv/versions/3.12.3 already exists
continue with installation? (y/N) y
Downloading Python-3.12.3.tar.xz...
-> https://www.python.org/ftp/python/3.12.3/Python-3.12.3.tar.xz
Installing Python-3.12.3...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/bz2.py", line 17, in <module>
    from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/curses/__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'
WARNING: The Python curses extension was not compiled. Missing the ncurses lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/ctypes/__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
WARNING: The Python ctypes extension was not compiled. Missing the libffi lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'readline'
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/sqlite3/__init__.py", line 57, in <module>
    from sqlite3.dbapi2 import *
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/tkinter/__init__.py", line 38, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
    ^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_tkinter'
WARNING: The Python tkinter extension was not compiled and GUI subsystem has been detected. Missing the Tk toolkit?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/i0/.pyenv/versions/3.12.3/lib/python3.12/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'
WARNING: The Python lzma extension was not compiled. Missing the lzma lib?
Installed Python-3.12.3 to /home/i0/.pyenv/versions/3.12.3
#

bad pyenv, count me out

rustic kernel
#

oof

#

this issue is evil

#

we are going to have to use version specific code here

#

oh i am murdering someone tonight

#

they use a fucking is check on a singleton that isnt exposed in the imports

undone terrace
#

sounds like a great opportunity for you to make some prs to cpython and get yourself bragging rights with a profile repo pin LMAO

rustic kernel
#

i dont think cpython is going to expose it

undone terrace
#

nah, but 1 merged pr will at least give you 15 mins of glory

#

fixed pyenv and installed, issue reproduces on my end 🎉

rustic kernel
#

what im likely going to have to do is reproduce __call__

#

if you hated the words i said, good

undone terrace
#

i'll put it in my novel

rustic kernel
#

so that does fix it

#

its terrible, but it works

#

i'll pr my fix soon

rustic kernel
#

#1658

atomic agateBOT
# rustic kernel #1658

• Pull Request Type: Bugfix
• Created: <t:1713379356:R>

Description

On Python 3.12.3 onwards (specifically 3.12.3), a change to EnumType.__call__ messed up our own overriding of the same function at DistinctFlag.__call__, causing issues like those seen in #1657. This PR fixes that with version-specific code.

Changes
  • Make DistinctFlag.__call__ use a separate branch of code for 3.12.3+.
    • This code is forced to recreate the entirety EnumType.__call__ due to a singleton that is not exported. This adds quite a burden to us, but hopefully it should be already.
    • Versions before 3.12.3 should still use the same code as previously.
Related Issues

Fixes #1657.

Test Scenarios

[CODEBLOCK]

Python Compatibility
  • ✅ I've ensured my code works on Python 3.10.x
  • ✅ I've ensured my code works on Python 3.12.3
Checklist
  • ✅ I've run the pre-commit code linter over all edited files
  • ✅ I've tested my changes on supported Python versions
  • ❌ I've added tests for my code, if applicable
  • ❌ I've updated / added documentation, where applicable
rustic kernel
#

in the future we should absolutely rework this logic

#

yeah, i'll probably refactor the entirety of this code in the future

pearl moat
#

probably a better way to do this, but it's what came to mind.
Since we're just calling the super, rather than using version specific handing of the defaults in the function, let the super handle it

    def __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1) -> "DistinctFlag":
        kwargs = {"names":names} if names else {}
        try:
            int_value = int(value)
            return super().__call__(int_value, module=module, qualname=qualname, type=type, start=start, **kwargs)
        except (TypeError, ValueError):
            return _return_cursed_enum(cls, value)
rustic kernel
#

well, we may actually want to use the names (why? i have no idea but still)

#

actually no way you just put it in kwargs

glad dawn
#

Oh, this is wild

rustic kernel
#

i feel like that would cause issues

#

yeah it would

#

the inner functions not checking for a falsey, its specifically checking for a singleton

#

so that input would be treated like an actual name instead of being "empty"

pearl moat
#

if there's any issues, I couldn't see one in testing
by the depth of that was just

>>> import interactions
>>> interactions.Intents(0)
<Intents.NONE: 0>
>>> interactions.Intents(4)
<Intents.GUILD_MODERATION: 4>
>>> interactions.Intents(7)
<Intents.GUILD_MODERATION|GUILD_MEMBERS|GUILDS: 7>
>>> ^Z

on a different versions

rustic kernel
#

even on 3.12.3?

#

oh right

#

okay i see

#

okay im dumb

#

yeah that would fix it

#

...i literally just left my pc though

#

if you open a pr i'll close mine

pearl moat
#

drafting it rn

pearl moat