Skip to content

isalpha and isdigit do not work correctly with a subscripted input character #25543

Closed as not planned

Description

@kenglander53

Type: Bug

Behaviour

isdigit and isalpha return True incorrectly

Steps to reproduce:

EXAMPLE CODE:

string = "dblcount 12"
items = string.split (" ")
element = items [0]
print (element [0])
if element [0].isalpha:
print ("isalpha is true")
else:
print ("isalpha is false")

if element [0].isdigit:
print ("isdigit is true")
else:
print ("isdigit is false")

element = items [1]
print (element [0])
if element [0].isalpha:
print ("isalpha is true")
else:
print ("isalpha is false")

if element [0].isdigit:
print ("isdigit is true")
else:
print ("isdigit is false")

OUTPUT:

d
isalpha is true
isdigit is true
1
isalpha is true
isdigit is true

Extension version: 2025.16.0
VS Code version: Code 1.105.1 (7d842fb85a0275a4a8e4d7e040d2625abbf7f084, 2025-10-14T22:33:36.618Z)
OS version: Windows_NT x64 10.0.26100
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.13.5
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): System
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
debugpy ms- 2025.14.1
js-debug ms- 1.105.0
js-debug-companion ms- 1.1.3
python ms- 2025.16.0
vscode-js-profile-table ms- 1.0.10
vscode-pylance ms- 2025.8.3
vscode-python-envs ms- 1.10.0
System Info
Item Value
CPUs Intel(R) Core(TM) 7 150U (12 x 2611)
GPU Status 2d_canvas: enabled
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.69GB (2.85GB free)
Process Argv --crash-reporter-id 8fe53d84-2b89-40ee-b241-4fd1371cb725
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vswsl492cf:30256860
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31334701
aj953862:31281341
nes-set-on:31340697
63221493:31336333
envsdeactivate2:31353495
gendocstringf:31405073
0574c672:31404437
cloudbuttont:31379625
todos-1:31405332
v66_all_req:31402695
multireplacestring:31398340
treatment_gpt5applypatchexclusively:31398171
3efgi100_wstrepl:31403338
trigger-command-fix:31379601
auto_model_enabled:31385282
grok-control-prompt:31401224
use-responses-api:31390855
applesignin:31399435
anonusage:31403420
2a0ce269:31405347

Activity

  1. eleanorjboyd commented on Oct 23, 2025

    @eleanorjboyd
    Member

    Hi! Could you elaborate a bit more on the problem you are facing? A screenshot or recording could help me understand how exactly you are seeing this behavior in terms of its correlation to the editor. Thanks

  2. added
    info-neededIssue requires more information from poster
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Oct 23, 2025
  3. kenglander53 commented on Oct 23, 2025

    @kenglander53
    Author
  4. eleanorjboyd commented on Oct 23, 2025

    @eleanorjboyd
    Member

    Hi! Tried this and got the following:

    d
    isalpha is true
    isdigit is false
    1
    isalpha is false
    isdigit is true
    

    if you can try this in your terminal without vscode and see how that goes- we should show the same experience as run from your terminal.

  5. kenglander53 commented on Oct 24, 2025

    @kenglander53
    Author
  6. eleanorjboyd commented on Oct 24, 2025

    @eleanorjboyd
    Member

    Hm not sure but maybe a good thing to try? Sorry I can't help more as it doesn't seem to be an editor issue

  7. kenglander53 commented on Oct 30, 2025

    @kenglander53
    Author

    Hi again - just wanted to send you a "post mortem" note. I finally figured out my problem today and I suspect it is something you just fixed in the code snippet I sent without giving it a moment's thought. I left out the parenthesis after the treatments isdigit and isalpha. I have to admit, it is a puzzle to me why python does not flag this, but I guess it is not something easy to catch!

  8. eleanorjboyd commented on Oct 30, 2025

    @eleanorjboyd
    Member

    Thank you for the update and agreed that should be flagged - wonder if a different linter like ruff would catch it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

info-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions