8000 sys.argv is not always available by methane · Pull Request #739 · PyMySQL/PyMySQL · GitHub
[go: up one dir, main page]

Skip to content

sys.argv is not always available #739

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
Oct 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
sys.argv is not always available
fixes #736
  • Loading branch information
methane committed Oct 27, 2018
commit 70cef94849d64d1ae3cea5b68552cdd71372ee1a
6 changes: 4 additions & 2 deletions pymysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,12 @@ def _config(key, arg):
'_pid': str(os.getpid()),
'_client_version': VERSION_STRING,
}
if program_name is None:
argv = getattr(sys, "argv")
if argv:
program_name = argv[0]
if program_name:
self._connect_attrs["program_name"] = program_name
elif sys.argv:
self._connect_attrs["program_name"] = sys.argv[0]

if defer_connect:
self._sock = None
Expand Down
0