Giter Club home page Giter Club logo

supporting-python-3's Issues

No mention of Py_FindMethod getattr/setattr for Python extensions

Your book, especially http://python3porting.com/cextensions.html, has already been very helpful to start porting rdiff-backup to Python3, but I'm stuck on the disappearance of Py_FindMethod as used in rdiff_backup/_librsyncmodule.c. According to my research:

  1. the Python documentation isn't too explicit about what this function was used for (no examples)
  2. the subtle difference between tp_getattr/tp_settatr and tp_getattro/tp_setattro could be clearer (beside the fact that the first ones are outdated).
  3. there are two cases: you can use the PyObject_GenericG/SetAttr or not, but the criteria for this decision are unclear to me.
  4. If you can use the Generic functions, you don't need Py_FindMethod so that's easy, but there are no explanations if you can't (which seems to be my specific case) on how to get rid of the method without breaking your code.

So quite a lot of missing explanations, I think, which you could possibly highlight in an update.

Crowdfunding promise delivery

These are the things that I promised to do in the crowd funding campaign, https://github.com/regebro/supporting-python-3/issues/new

  • Clean up the code (done)
  • Document how to generate the HTML for the site (done)
  • Move the code to Github (done)
  • Rename the book into "Supporting Python 3" (done)
  • Update the "About this book" page to reflect the books community status and contributors. (done)
  • Create a contributor licensing scheme
  • Set up automatic testing
  • Set up automatic generation of HTML and PDF's and publish

The current README.rst does not mention epub generation

Currently the README.rst goes into great depth about pdf generation in a number of page layouts but does not mention the fact that the makefile includes targets for html, dirhtml and epub.

This gives the impression that only pdf output is available and that anybody looking for epub support is going to have to do it themselves.

De-emphasize 2to3

2to3 is today only relevant if you still need to support both Python 2.5 and Python 3.2.

sys.version should not be used for version checks

The string sys.version should not be used for version checks as there is no guarantee across implementations that the version number is at the beginning of the string. Instead sys.version_info should be used which is a tuple of integers.

Seems that 2to3 doesn't support issue with Exception object (A.9)

Section A.9 says that the issue with Exception objects that are not iterable and indexable is supported by 2to3.
But it seems that it doesn't. I tried the code presented as the example:

e = Exception('arg1', 'arg2')
e[1]

and found that it is not converted by 2to3. This fix is not mentioned neither in documentation, nor in the code of fix_except fixer.
Maybe am I missing something?

Python 2-style `round()` implementation is not always correct

Thanks for this guide, I've found it a really useful resource when porting some old Python 2 code ❤️

One thing I did notice: the round() substitute given for Python 2-like behaviour in Python 3 is close, but fails to give the exact Python 2 behaviour in a few cases.

For example:

Python 2.7.18 (default, Jul  1 2022, 12:27:04) 
[GCC 9.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> def my_round(x, d=0):
...     p = 10 ** d
...     if x > 0:
...         return float(math.floor((x * p) + 0.5))/p
...     else:
...         return float(math.ceil((x * p) - 0.5))/p
... 
>>> my_round(353.765, 2)
353.77
>>> round(353.765, 2)
353.76

Another implementation that I found seems to be a slight improvement. It is also tested against examples taken from the Python 2 test suite.

>>> round2(353.765, 2)
353.76

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.