Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8178809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:51:20+00:00 2026-06-06T23:51:20+00:00

I am reading EXE (size 2 MB) which have some ASCII text too. Trying

  • 0

I am reading EXE (size 2 MB) which have some ASCII text too. Trying to retrieve data as per matched conditions. In Python 2.6, following code is working fine (give me result in 2 sec) but not in 3.2. In Python 3.2 , it keep running forever no response.

Thanks…

match_str = b"sape"
out= ""
try:
    file_obj = open(exe_filePath,'rb')

    while 1:
        data = file_obj.readline(100)

        if data.count(match_str) > 0:               
            out = data.strip()[9:13]                
        if data=="":
            break

    file_obj.close()
    return out
except:
    file_obj.close()
    raise "Some error occurred"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:51:22+00:00Added an answer on June 6, 2026 at 11:51 pm
    if data=="":
        break
    

    will always fail (meaning that the break will never happen) because

    >>> b"" == ""
    False
    

    and data is a bytes object.

    If you change it to

    if data==b"":
        break
    

    it should work. Although there are many other things that should be fixed here (see my comment to your question).

    I would suggest this:

    match_str = b"sape"
    with open(exe_filePath,'rb') as file_obj: 
        while True:
            data = file_obj.readline(100)
            if data.count(match_str) > 0:
                # This will overwrite any previous "out" from the last match!
                # Do you really want that?
                out = data.strip()[9:13]
            if data==b"":
                break
    return out
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading this article http://support.microsoft.com/kb/813878 I have a question: Where can I get ipseccmd.exe for
I'm trying to run genhtml using perl.exe from Cygwin in Windows. I have installed
I have an application consists of a single EXE and multiple DLLs. After reading
I have a dll(written in vb6) that compiles VB6 code. I'm reading the VB6.exe
I have a BAT file, which creates a number of csv files by reading
I am trying to define a class in the global scope which contains some
I keep reading that I have to use svcUtil.exe, crmSvcUtil.exe and company with tons
I have been reading some of the books by Hoglund and I thought I
I got this error Unhandled exception at 0x0049b946 in Program.exe: 0xC0000005: Access violation reading
Reading some questions here on SO about conversion operators and constructors got me thinking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.