Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-98187

ANSI ESC code from subprocess.run output, causing regex failure to match

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Build
    • ALL
    • Hide

      From the build steps :

      buildscripts/poetry_sync.sh   <= this steps (I think, sorry don't remember)

      python3 buildscripts/scons.py --build-profile=opt

      Show
      From the build steps : buildscripts/poetry_sync.sh   <= this steps (I think, sorry don't remember) python3 buildscripts/scons.py --build-profile=opt

      OS : Ubuntu 24.04

      Python : 3.10

      In mongo/[site_scons|https://github.com/mongodb/mongo/tree/master/site_scons]/[mongo/|https://github.com/mongodb/mongo/tree/master/site_scons/mongo]pip_requirements.py,

       

          match = re.search(
              r"Package operations: (\d+) \w+, (\d+) \w+, (\d+) \w+, (\d+) \w+",
              poetry_dry_run_proc.stdout,
          )
          verbose("Requirements list:")
          verbose(poetry_dry_run_proc.stdout)
          installs = int(match[1])
          updates = int(match[2])
          removals = int(match[3]) 

      int(match[1]) fails (match is set to None),  because regex fails to match "Package operations:", I found that poetry_dry_run_proc.stdout return some non pritable character like ESC  (try to write poetry_dry_run_proc.stdout to a file), there is a non pritable ESC char before ":", so match is None, and can't subscribe a Nonetype var.

       

      poetry_dry_run_proc.stdout is something like : "�[39;1mPackage operations�[39;22m: ..."

       

      See PR1603

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            h.sousou97@gmail.com maths soso N/A
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: