google-code-export / pymssql

Automatically exported from code.google.com/p/pymssql
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Pymssql doesn't build on Python 3.1 #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Building fails on Lion with Py3.1

pymssql.pyx:89:27: undeclared name not builtin: StandardError

there is also a instance of BaseString in _mssql.pyx that doesn't work in py3x.

even if I fix the type issues, an import gets me 
>>> import pymssql
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_mssql.pxd", line 10, in init pymssql (pymssql.c:8587)
    cdef class MSSQLConnection:
  File "_mssql.pyx", line 65, in init _mssql (_mssql.c:18369)
    cdef bytes HOSTNAME = socket.gethostname()
TypeError: Expected bytes, got str

Original issue reported on code.google.com by rizw...@gmail.com on 20 Aug 2011 at 7:13

GoogleCodeExporter commented 9 years ago
Can you give me the various different versions of applicable software you are 
using to build?  I'm not a Mac guy, so unless you can tell me how to fix this, 
it probably won't get fixed.

Original comment by rsyr...@gmail.com on 4 Oct 2011 at 4:57

GoogleCodeExporter commented 9 years ago
Sure. What software in particular?

Python 3.1.4
Cython 0.15
FreeTDS 0.82
Python-Distribute 0.6.21

Here's the build log and the basic basestring error...

[ rizwank@macbook /tmp/pymssql ] $python3.1 setup.py build
running build
running build_ext
cythoning _mssql.pyx to _mssql.c
warning: _mssql.pyx:1198:51: local variable 'data' referenced before assignment
warning: _mssql.pyx:170:11: Unreachable code

Error compiling Cython file:
------------------------------------------------------------
...
        quoted = _quote_data(params, charset)
    else:
        quoted = _quote_data(params)

    # positional string substitution now requires a tuple
    if isinstance(quoted, basestring):
                                   ^
------------------------------------------------------------

_mssql.pyx:1539:36: undeclared name not builtin: basestring
building '_mssql' extension
creating build/temp.macosx-10.7-x86_64-3.1
/Developer/usr/bin/llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -pipe 
-O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/sw/include 
-I/usr/local/include -I/usr/local/include/freetds -I/usr/include 
-I/usr/include/freetds -I/usr/include/freetds_mssql 
-I/usr/local/freetds/include -I/usr/pkg/freetds/include -I/opt/local/include 
-I/opt/local/include/freetds -I/opt/local/freetds/include 
-I/opt/local/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 
-c _mssql.c -o build/temp.macosx-10.7-x86_64-3.1/_mssql.o -DMSDBLIB
_mssql.c:1:2: error: #error Do not use this file, it is the result of a failed 
Cython compilation.
error: command '/Developer/usr/bin/llvm-gcc-4.2' failed with exit status 1

Original comment by rizw...@gmail.com on 4 Oct 2011 at 5:32

GoogleCodeExporter commented 9 years ago
The TypeError isn't specific to a platform but rather specific to Python 3.  
All str objects in Python 3 are what Python 2 used to call unicode.  To use 
them in the underlying C libraries, they need to be tested to be unicode and 
encoded to bytes.  I'm willing to build/submit a patch, but need to know what 
encoding to use.  utf-8?

FWIW, I get the same results as described in this issue w/ Python 3.2 on Ubuntu 
11.10 w/ latest FreeTDS.

Original comment by david.sm...@cornell.edu on 9 Jan 2012 at 1:15

GoogleCodeExporter commented 9 years ago
See: https://groups.google.com/forum/?fromgroups#!topic/pymssql/QlDvV9rl4Ow

for further discussion on this issue.

Original comment by rsyr...@gmail.com on 8 Mar 2012 at 2:54

GoogleCodeExporter commented 9 years ago
This is a duplicate of issue #26. 

I've done a little bit of work on Python 3.x but it's not ready to be committed 
yet. 

Original comment by msabr...@gmail.com on 7 Jan 2013 at 5:28