Skip to content

resolve string index out of range errors #212

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 5 commits into from
Dec 21, 2017
Merged

Conversation

gvoysey
Copy link
Contributor

@gvoysey gvoysey commented Nov 23, 2017

resolves #189, #175, #170, #169, etc.

added clarity and common fixes for PyMySQL#169 related macOS issues.
README.md Outdated
@@ -26,6 +26,23 @@ On Windows, there are binary wheel you can install without MySQLConnector/C or M
`sudo yum install python3-devel ` # Red Hat / CentOS

`brew install mysql-connector-c` # macOS (Homebrew)
#### Note on macOS
homebrew's `mysql-connector-c` may have incorrect configuration options that cause compilation errors. Under the `#create options` comment on or about line 112 of `/usr/local/bin/mysql_config`:
Copy link
Member

Choose a reason for hiding this comment

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

The issue (MySQL's bug) is not homebrew specific.

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'll update to be more general.

setup_posix.py Outdated
if s[0] in "\"'" and s[0] == s[-1]:
s = s[1:-1]
return s
return s.strip("'\"")
Copy link
Member

Choose a reason for hiding this comment

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

I don't like this code.
Raising exception for wrong input is good thing. It's not reason for breaking our code.

Copy link
Contributor Author

@gvoysey gvoysey Nov 27, 2017

Choose a reason for hiding this comment

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

This could change so that line 12 is if s and s[0] in "\"'" and s[0] == s[-1]: .

While I agree that raising exceptions is the way to go:

  1. IndexError is not informative about the root cause -- so this could be caught higher up and rethrown with more context if it is to be preserved.
  2. Removing any possibility of the error (as in my proposed change(s)) allowed me to proceed to install the package, so raising an error may be too conservative in this case.

Copy link
Member

Choose a reason for hiding this comment

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

First of all, this issue is very special. Once MySQL fixed, it never happen. So IndexError is OK.

And "Errors should never pass silently."

You should fix mysql_config side, not here.

clarity in docs.
README.md Outdated
@@ -26,6 +26,25 @@ On Windows, there are binary wheel you can install without MySQLConnector/C or M
`sudo yum install python3-devel ` # Red Hat / CentOS

`brew install mysql-connector-c` # macOS (Homebrew)
#### MySQL note
Copy link
Member

Choose a reason for hiding this comment

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

  • Insert blank line before heading
  • Note for MySQL on macOS, because this issue is macOS specific.

README.md Outdated
@@ -26,6 +26,25 @@ On Windows, there are binary wheel you can install without MySQLConnector/C or M
`sudo yum install python3-devel ` # Red Hat / CentOS

`brew install mysql-connector-c` # macOS (Homebrew)
#### MySQL note
Versions of `mysql`may have incorrect default configuration options that cause compilation errors when `mysqlclient-python` is installed. (As of November 2017, this is known to be true for homebrew's `mysql-connector-c` and `mysql` packages)
Copy link
Member

Choose a reason for hiding this comment

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

Replace "mysql" with MySQL Connector/C.

When you did brew install mysql, it is OK.
When you did brew install mysql-connector-c, mysql_config is broken.

Copy link
Member

Choose a reason for hiding this comment

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

@methane methane merged commit d65e10e into PyMySQL:master Dec 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OSX - installation failed
2 participants