Thursday, May 15, 2008

Best wishes to the victims

Three days passed, the rescue is still in progress. Many people died, but still many people was saved. Anyway, bless people in Sichuan, bless China!


Monday, May 12, 2008

Big earthquake in Sichuan, China!

May 12, Beijing time 14:28, China suffered a big earthquake! Center of the earthquake is on Wenchuan, Sichuan. A county near Chengdu, the magnitude is about 7.8.

Seems the whole China was affected by the earthquake. In Beijing, Shanghai, peoples working in higher floor of tall building felt the buildings swagging. They felt dizzy and ran out. But I was staying on 3rd floor when the earthquake happening, so I felt nothing.

I tried to contact one of my friends who live in Chengdu, but failed. Hopes they are safe...

Anyway, bless my friends, bless China...

May 13, 3:49AM, I received a short message from my friend, saying they are safe. They stay over the night on playground...

Vim tips for SWIG

I've ever annoyed with the mixed tab and spaces in SWIG's code. Just talked it with William Fulton in #swig-gsoc. He suggested some tips.

This is a way to specific coding style by project:

au BufRead */[SWIG|swig]*/* set tabstop=8 | set shiftwidth=2 | set softtabstop=2 | set expandtab " SWIG

And a Syntax file for SWIG, add this in ~/.vimrc or ~/.vim/filetype.vim to use it:

" SWIG filetype file
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.swg setfiletype swig
au! BufRead,BufNewFile *.i setfiletype swig
augroup END

Finally, a big thanks to William! :)

Yeah, sigfaults disappered!

Finally I have solved most of the segmentation faults in yesterday's midnight. Just two lines of code!

Now I understood that PyObject_New() only allocate memory, but haven't do the works like creating the object's __dict__ and etc. We should use PyBaseObject_Type.tp_new() to create a "full" object. Or maybe PyType_GenericNew() also works?

Another mistake I've made is using obj->tp_dict() directly to access the object's dict. *Must* use _PyObject_GetDictPtr() instead! Otherwise, we only get the dict of the object's type!

Well done, now more than 90% test cases passed! Cheers!


Monday, May 5, 2008

Looked into the failed testcases

I've just looked into the failed testcases these days. Reasons of the failures can be fallen into below several categories:
  • PyInstance_NewRaw: should find a replacement
  • A lot of things related to the Unicode string changes
  • IO module changed (see PEP 3116), some PyFile_* dissappeared
  • How to define swig::LANGUAGE_OBJ?
  • Some old testcases code should be rewritten (eg. they should raises an exception object instead of a string)
  • Exception implementation: in Python 3 all excetion classes must inherit from BaseException, so we can't directly use a C/C++ struct as an exception now.
This would be a todo-list for me in the next weeks.

Friday, May 2, 2008

Trying some cool Firefox addons

Every time I browse the Firefox Add-ons page, I can discovery something cool. These are the things I found today:
  • Interclue: It shows a preview window when your mouse stay on a link, so you can see the page behind the link without open it. It also can provide viewing for images, and YouTube videos.
  • YouPlayer: A video palyer with playlist. It stay in a sidebar of Firefox, so you can watch video while browsing web pages. However, I think it is more convenient to play video in a floating window.
  • ScribeFire: Writing blog directly in Firefox, without open a web page. This blog is written using it. It is a bit more powerful than Blogger's blog editor.
  • FaviconizeTab: "Faviconize" the tabs to save the tab bars space. Not sure it is useful, just trying.
These are the new addons in my Firefox. I like to try out various addons, sometime they amazed me a lot.

The test suite and disable 2to3 fixers

I'm writing SWIG makefile rules for testing today. Now I can see the test progress running well when I type "make check-python3-test-suite". It wonders me that so many tests can be passed! However, the failed tests should be the hardest part.

I have spend some time to work on Python 3's relative import, which mentioned on PEP 328, and PEP 366 seems a solution to my problem. But there is no 2to3 fixer to apply the PEP 366, so I had to disable the "import" fixer. The 2to3 has no option to disable a fixer now, so, this is how I did that:

$ 2to3 `2to3 -l | grep -v -E "Available|import$" | awk '{print "-f "$0}'` foo.py

This is the first time I tried to use awk, and the first time to write such a complicated command line. However, there should be a more clever way to do it.

The test suite still running, very slow, maybe due to that awful command line?