Skip to content

[BUG] TypeError: expected string or bytes-like object when entering e.g. "ä, ü, ö" #70

@Mangosniper

Description

@Mangosniper

I have issues when entering some characters e.g. into in Input. These characters are not only german umlaute like "ä, ü, ö" but also shift, arrow-up and some more. The error is:

Input two letters: Traceback (most recent call last):
  File "test.py", line 9, in <module>
    prompt()
  File "test.py", line 6, in prompt
    var_two_letters = two_letters.launch()
  File "/home/administrator/.local/lib/python3.6/site-packages/bullet/client.py", line 444, in launch
    if self.valid(result):
  File "/home/administrator/.local/lib/python3.6/site-packages/bullet/client.py", line 417, in valid
    if not bool(re.match(self.pattern, ans)):
  File "/usr/lib/python3.6/re.py", line 172, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object

Minimal code to reproduce ist:

from bullet import Input

two_letters = Input(prompt = "Input two letters: ", pattern="^[A-Z]{2}$")

def prompt():
    var_two_letters = two_letters.launch()
    print(var_two_letters)

prompt()

Actually, I dont even want to enter such characters, as you can see that the regex in the pattern only accepts plain characters. However, the script crashes when I just type in the character, so there is no way for me to sanitize the input before the crash.

Is there anything I can do about this? I tried the native "input" function of pything and here I can add Umlaute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions