Skip to content
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

bsddb3 needs to be ported to Python 3.0 #47136

Closed
avassalotti opened this issue May 16, 2008 · 5 comments
Closed

bsddb3 needs to be ported to Python 3.0 #47136

avassalotti opened this issue May 16, 2008 · 5 comments
Assignees
Labels
extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@avassalotti
Copy link
Member

BPO 2887
Nosy @gpshead, @jcea, @avassalotti, @tpn

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/jcea'
closed_at = <Date 2008-09-16.18:19:57.837>
created_at = <Date 2008-05-16.05:27:41.693>
labels = ['extension-modules', 'tests', 'type-feature', 'library']
title = 'bsddb3 needs to be ported to Python 3.0'
updated_at = <Date 2008-09-16.18:19:57.836>
user = 'https://github.com/avassalotti'

bugs.python.org fields:

activity = <Date 2008-09-16.18:19:57.836>
actor = 'jcea'
assignee = 'jcea'
closed = True
closed_date = <Date 2008-09-16.18:19:57.837>
closer = 'jcea'
components = ['Extension Modules', 'Library (Lib)', 'Tests']
creation = <Date 2008-05-16.05:27:41.693>
creator = 'alexandre.vassalotti'
dependencies = []
files = []
hgrepos = []
issue_num = 2887
keywords = []
message_count = 5.0
messages = ['66918', '67320', '67487', '69449', '73306']
nosy_count = 4.0
nosy_names = ['gregory.p.smith', 'jcea', 'alexandre.vassalotti', 'trent']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue2887'
versions = ['Python 3.0']

@avassalotti
Copy link
Member Author

The recent updates to bsddb (r63207, r63210 and r63218) needs to
forward-ported to the py3k branch.

At first glance, here is the things that needs to be done in the test suite:

  • Change the import:
      from test_all import ...
into a relative import:
      from .test_all import ...
  • Replace code incompatible with 3.0, such as changing
    dict.has_key(key) to key in dict.

  • Change str literals to bytes literals where appropriate.

  • Optional: change code like type([]) or type(()) to
    respectively list and tuple.

  • Change print statements into print() calls.

  • Change x != None to x is not None.

In the modules:

  • Change PyInt__* to PyLong_*.

  • Update the PyTypeObject declaration:

    statichere PyTypeObject DB_Type = {
    PyObject_HEAD_INIT(NULL)
    0, /ob_size/
    "DB", /tp_name/
    sizeof(DBObject), /tp_basicsize/
    ...

    to:

    static PyTypeObject DB_Type = {
    PyVarObject_HEAD_INIT(NULL, 0)
    "DB", /tp_name/
    sizeof(DBObject), /tp_basicsize/
    ...

  • Update module init declaration:

    DL_EXPORT(void) init_bsddb(void)
    {
    ...

    to:

    PyMODINIT_FUNC init_bsddb(void)
    {
    ...

  • Remove Py_TPFLAGS_HAVE_WEAKREFS.

  • Change PyString_* calls to PyUnicode_* where appropriate.

There probably other things that I missed, but that should give you a
good start.

@avassalotti avassalotti added extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement labels May 16, 2008
@gpshead
Copy link
Member

gpshead commented May 25, 2008

I believe Jesus wants to do this is such a way that bsddb.h and _bsddb.c
are a single code base with #ifdef's that compiles on 2.x and 3.x at once.

@jcea
Copy link
Member

jcea commented May 29, 2008

Yes. My idea is to port the python code as-is, using "2to3", and update
the C code with conditional compilation, to keep a single codebase.

I'm having issues with the compatibility. In particular, my code has the
following line:

"""
staticforward PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type,
DBTxn_Type, DBLock_Type;
"""

Compiling this code fails with the following error (when compiling
against Python 3.0):

"""
Modules/_bsddb.c:241: error: expected '=', ',', ';', 'asm' or
'__attribute__' before 'PyTypeObject'
"""

Compiling the same code against Python 2.x, works.

Ideas welcomed :).

@jcea jcea changed the title bsddb 4.6.4 needs to be ported to Python 3.0 bsddb3 needs to be ported to Python 3.0 May 29, 2008
@tpn
Copy link
Member

tpn commented Jul 9, 2008

FWIW, I bumped the version of Berkeley DB being used on Windows from
4.4.20 to 4.7.25 in r64555 (trunk). I blocked this from being merged
to py3k. This block should be removed once bsddb has been updated.

@jcea
Copy link
Member

jcea commented Sep 16, 2008

bsddb is officially dropped in Python 3.0. Too bad :(. I close this issue.

bsddb supports Python 3.0 via a separate project, downloadable from PYPI.

@jcea jcea closed this as completed Sep 16, 2008
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants