Skip to content

[lldb][test] Fix type error when calling random.randrange with 'float' arg #97328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

kendalharland
Copy link
Contributor

This test only runs on Windows and fails because we're passing a literal of the wrong type to random.randrange.

Copy link

github-actions bot commented Jul 1, 2024

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@kendalharland kendalharland force-pushed the kendal/fix-type-error branch from b8830b5 to 108865d Compare July 1, 2024 17:35
@llvmbot llvmbot added the lldb label Jul 1, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 1, 2024

@llvm/pr-subscribers-lldb

Author: Kendal Harland (kendalharland)

Changes

This test only runs on Windows and fails because we're passing a literal of the wrong type to random.randrange.


Full diff: https://github.com/llvm/llvm-project/pull/97328.diff

1 Files Affected:

  • (modified) lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py (+1-1)
diff --git a/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py b/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
index 853b7ad5ef290..f31a57b767c72 100644
--- a/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
+++ b/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
@@ -75,7 +75,7 @@ def __init__(self):
     class Pipe(object):
         def __init__(self, prefix):
             while True:
-                self.name = "lldb-" + str(random.randrange(1e10))
+                self.name = "lldb-" + str(random.randrange(int(1e10)))
                 full_name = "\\\\.\\pipe\\" + self.name
                 self._handle = CreateNamedPipe(
                     full_name,

@@ -75,7 +75,7 @@ def __init__(self):
class Pipe(object):
def __init__(self, prefix):
while True:
self.name = "lldb-" + str(random.randrange(1e10))
self.name = "lldb-" + str(random.randrange(int(1e10)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about random.randrange(10000000000)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to leave it as the original author wrote it if that's alright. I'm assuming they found the shorthand more readable

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I find it easier to read e10 than 0000000000, so I'd also keep the style as is.

Copy link
Collaborator

@labath labath Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about 10**10 ?

(As the "original author" ;), I'm not really sure what happened here. I'm pretty sure I did not write a huge blob of windows-specific code without testing it. It could be that newer python versions got more strict about typing or sth...)

@DavidSpickett DavidSpickett changed the title Fix type error when calling random.randrange with 'float' arg [lldb][test] Fix type error when calling random.randrange with 'float' arg Jul 2, 2024
@DavidSpickett
Copy link
Collaborator

I'm confused, I don't see this random call in TestGdbRemoteConnection.py, but I do in lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py.

Is your branch based off something other than the current main?

Copy link
Collaborator

@labath labath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but note that this file was moved (to packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py) recently, so you'll need to rebase this PR to HEAD.

@@ -75,7 +75,7 @@ def __init__(self):
class Pipe(object):
def __init__(self, prefix):
while True:
self.name = "lldb-" + str(random.randrange(1e10))
self.name = "lldb-" + str(random.randrange(int(1e10)))
Copy link
Collaborator

@labath labath Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about 10**10 ?

(As the "original author" ;), I'm not really sure what happened here. I'm pretty sure I did not write a huge blob of windows-specific code without testing it. It could be that newer python versions got more strict about typing or sth...)

@kendalharland kendalharland force-pushed the kendal/fix-type-error branch from 108865d to 9bb6749 Compare July 3, 2024 18:11
@kendalharland kendalharland force-pushed the kendal/fix-type-error branch from 9bb6749 to a3c524b Compare July 3, 2024 18:19
@kendalharland
Copy link
Contributor Author

Using 10**10. Works for me. Updated and rebased on top of main.

@kendalharland
Copy link
Contributor Author

I'll also need help merging this since I don't have write access to the repo.

@labath labath merged commit 857700f into llvm:main Jul 8, 2024
6 checks passed
Copy link

github-actions bot commented Jul 8, 2024

@kendalharland Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@kendalharland kendalharland deleted the kendal/fix-type-error branch July 8, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants