Skip to content

Commit

Permalink
Remove redundant code for dropped Python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored and mkleehammer committed Oct 10, 2023
1 parent ce93b61 commit 885a84c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ def get_compiler_settings():
# made the settings.
# https://lectem.github.io/msvc/reverse-engineering/build/2019/01/21/MSVC-hidden-flags.html

if sys.hexversion >= 0x03050000:
settings['extra_compile_args'].append('/d2FH4-')
settings['extra_link_args'].append('/d2:-FH4-')
settings['extra_compile_args'].append('/d2FH4-')
settings['extra_link_args'].append('/d2:-FH4-')

settings['libraries'].append('odbc32')
settings['libraries'].append('advapi32')
Expand Down
15 changes: 0 additions & 15 deletions src/decimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,13 @@ bool InitializeDecimal() {
if (!point)
return false;

#if PY_MAJOR_VERSION >= 3
pDecimalPoint = PyUnicode_FromString(".");
#else
pDecimalPoint = PyBytes_FromString(".");
#endif

if (!pDecimalPoint)
return false;

#if PY_MAJOR_VERSION >= 3
if (!SetDecimalPoint(point))
return false;
#else
// In 2.7, we only support non-Unicode right now.
if (PyBytes_Check(point))
if (!SetDecimalPoint(point))
return false;
#endif

return true;
}
Expand Down Expand Up @@ -106,11 +95,7 @@ bool SetDecimalPoint(PyObject* pNew)
pLocaleDecimalEscaped = e.Detach();
}

#if PY_MAJOR_VERSION >= 3
Object s(PyUnicode_FromFormat("[^0-9%U-]+", pLocaleDecimal));
#else
Object s(PyBytes_FromFormat("[^0-9%s-]+", PyString_AsString(pLocaleDecimal)));
#endif
if (!s)
return false;

Expand Down
4 changes: 0 additions & 4 deletions src/pyodbcmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,7 @@ static PyObject* mod_setdecimalsep(PyObject* self, PyObject* args)
{
UNUSED(self);

#if PY_MAJOR_VERSION >= 3
const char* type = "U";
#else
const char* type = "S";
#endif

PyObject* p;
if (!PyArg_ParseTuple(args, type, &p))
Expand Down

0 comments on commit 885a84c

Please sign in to comment.