Skip to content

Commit

Permalink
Move _mysql and _mysql_exceptions into MySQLdb/ (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
methane authored Dec 4, 2018
1 parent bd62c5d commit 833816e
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions MySQLdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from MySQLdb.release import __version__, version_info, __author__

import _mysql
from . import _mysql

if version_info != _mysql.version_info:
raise ImportError("this is MySQLdb version %s, but _mysql is version %r" %
Expand All @@ -25,7 +25,7 @@
apilevel = "2.0"
paramstyle = "format"

from _mysql import *
from ._mysql import *
from MySQLdb.compat import PY2
from MySQLdb.constants import FIELD_TYPE
from MySQLdb.times import Date, Time, Timestamp, \
Expand Down
2 changes: 1 addition & 1 deletion _mysql.c → MySQLdb/_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2746,7 +2746,7 @@ init_mysql(void)
(PyObject *)&_mysql_ResultObject_Type))
goto error;
Py_INCREF(&_mysql_ResultObject_Type);
if (!(emod = PyImport_ImportModule("_mysql_exceptions"))) {
if (!(emod = PyImport_ImportModule("MySQLdb._mysql_exceptions"))) {
PyErr_Print();
goto error;
}
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions MySQLdb/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
import re
import sys

from MySQLdb import cursors
from MySQLdb import cursors, _mysql
from MySQLdb.compat import unicode, PY2
from _mysql_exceptions import (
from MySQLdb._mysql_exceptions import (
Warning, Error, InterfaceError, DataError,
DatabaseError, OperationalError, IntegrityError, InternalError,
NotSupportedError, ProgrammingError,
)
import _mysql


if not PY2:
Expand Down
2 changes: 1 addition & 1 deletion MySQLdb/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
MySQL.connect().
"""

from _mysql import string_literal, escape, NULL
from MySQLdb._mysql import string_literal, escape, NULL
from MySQLdb.constants import FIELD_TYPE, FLAG
from MySQLdb.times import *
from MySQLdb.compat import PY2, long
Expand Down
12 changes: 7 additions & 5 deletions MySQLdb/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import re
import sys

from MySQLdb.compat import unicode
from _mysql_exceptions import (
from .compat import unicode
from ._mysql_exceptions import (
Warning, Error, InterfaceError, DataError,
DatabaseError, OperationalError, IntegrityError, InternalError,
NotSupportedError, ProgrammingError)
Expand Down Expand Up @@ -55,9 +55,11 @@ class BaseCursor(object):
#: Default value of max_allowed_packet is 1048576.
max_stmt_length = 64*1024

from _mysql_exceptions import MySQLError, Warning, Error, InterfaceError, \
DatabaseError, DataError, OperationalError, IntegrityError, \
InternalError, ProgrammingError, NotSupportedError
from ._mysql_exceptions import (
MySQLError, Warning, Error, InterfaceError,
DatabaseError, DataError, OperationalError, IntegrityError,
InternalError, ProgrammingError, NotSupportedError,
)

_defer_warnings = False
connection = None
Expand Down
2 changes: 1 addition & 1 deletion MySQLdb/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
from time import localtime
from datetime import date, datetime, time, timedelta
from _mysql import string_literal
from MySQLdb._mysql import string_literal

Date = date
Time = time
Expand Down
6 changes: 3 additions & 3 deletions doc/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ Installation
The ``README`` file has complete installation instructions.


_mysql
------
MySQLdb._mysql
--------------

If you want to write applications which are portable across databases,
use MySQLdb_, and avoid using this module directly. ``_mysql``
use MySQLdb_, and avoid using this module directly. ``MySQLdb._mysql``
provides an interface which mostly implements the MySQL C API. For
more information, see the `MySQL documentation`_. The documentation
for this module is intentionally weak because you probably should use
Expand Down
2 changes: 1 addition & 1 deletion metadata.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ classifiers:
Topic :: Database
Topic :: Database :: Database Engines/Servers
py_modules:
_mysql_exceptions
MySQLdb._mysql_exceptions
MySQLdb.compat
MySQLdb.connections
MySQLdb.converters
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
readme = f.read()

metadata, options = get_config()
metadata['ext_modules'] = [setuptools.Extension(sources=['_mysql.c'], **options)]
metadata['ext_modules'] = [
setuptools.Extension("MySQLdb._mysql", sources=['MySQLdb/_mysql.c'], **options)
]
metadata['long_description'] = readme
metadata['long_description_content_type'] = "text/markdown"
setuptools.setup(**metadata)
3 changes: 1 addition & 2 deletions setup_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,14 @@ def get_config():
create_release_file(metadata)
del metadata['version_info']
ext_options = dict(
name = "_mysql",
library_dirs = library_dirs,
libraries = libraries,
extra_compile_args = extra_compile_args,
extra_link_args = extra_link_args,
include_dirs = include_dirs,
extra_objects = extra_objects,
define_macros = define_macros,
)
)

# newer versions of gcc require libstdc++ if doing a static build
if static:
Expand Down
3 changes: 1 addition & 2 deletions setup_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ def get_config():
create_release_file(metadata)
del metadata['version_info']
ext_options = dict(
name = "_mysql",
library_dirs = library_dirs,
libraries = libraries,
extra_compile_args = extra_compile_args,
extra_link_args = extra_link_args,
include_dirs = include_dirs,
extra_objects = extra_objects,
define_macros = define_macros,
)
)
return metadata, ext_options

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion tests/test_MySQLdb_nonstandard.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

import _mysql
from MySQLdb import _mysql
import MySQLdb
from MySQLdb.constants import FIELD_TYPE
from configdb import connection_factory
Expand Down
2 changes: 1 addition & 1 deletion tests/test__mysql.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
import _mysql
from MySQLdb import _mysql


def test_result_type():
Expand Down

0 comments on commit 833816e

Please sign in to comment.